-1

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.

analogbeing
  • 28
  • 1
  • 7

2 Answers2

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

Adam Neuwirth
  • 529
  • 5
  • 10
  • While this code may resolve the OP's issue, it is best to include an explanation as to how your code addresses the OP's issue. In this way, future visitors can learn from your post, and apply it to their own code. SO is not a coding service, but a resource for knowledge. Also, high quality, complete answers are more likely to be upvoted. These features, along with the requirement that all posts are self-contained, are some of the strengths of SO as a platform, that differentiates it from forums. You can edit to add additional info &/or to supplement your explanations with source documentation. – ysf Jun 17 '20 at 18:39
  • Thanks for the tip! – Adam Neuwirth Jun 17 '20 at 19:04
  • I've exited the question, kindly take a look please.@ysf – analogbeing Jun 19 '20 at 16:17
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);
prateek3636
  • 155
  • 1
  • 7