skip to Main Content

I am working on a chrome-extension using Js, I want to post image automatically at my wall without using mouse etc., .
I tried different method, I use to click photo upload button(which on top of the video upload button ) using Js
click()
method there occurs an error File chooser dialog can only be show with user activation.
Another method I tried was by pasting the image link (image link from website) as you know when we paste image link in the wall status textarea of facebook even before clicking the submit button it loads the image on the bottom of the link instantly,
but as I am doing this automatically so when I use to paste the link using
textBox.value= '<link>'
.When I do this without clicking mouse, this doesnt make our photo to be loaded before clicking the submit button. Even I tried to focus and click by using
textBox.focus()

textBox.click()
textBox.focused = true;

Then I found something from the chrome, when I inspect page there in chrome some boxes open i.e., console, element, sources,Network, Performance etc., There I found that in Application there is a part called Frame > Top > Images , here in images part all images are stored. And I found the image of which’s URL I pasted in the textBox was also there.

So the Question is: Is there any way to directly access the photo which is there in Application > Frame > Top >Images in chrome? If so how and if not then How I can do that.
Can background.js access those parts of browser?
I want to do this task without using facebook graph api.
The thing I want my extension to do is it automatically Post Some text and images and post those to my wall and I don’t need to use mouse.

Note: Here textBox is the area where we use to post/write our status text.

2

Answers


  1. You need to use focus event on that text area and after that you can call click event without mouse click:

    setTimeout(function() {
     $('#textarea#uniqid_1').focus();
    }, 0);
    
    Login or Signup to reply.
  2. You can try $("textarea#uniqid_1").trigger("click");

    This has worked for me in cases that using click() didn’t (especially in Chrome). It’s worth noting that .trigger("click") is also faster see this answer

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search