0

I have a page where i need to auto fill a form.But that page contains jquery slider, jquery dropdown. The submit button contains validation of the form.

But i can't access the page's jquery object. Also i tried to execute jquery and jquery ui through manifest file.but it wont change real jquery object of a page.

(Chrome exetention javascript is executing in seperate context)

Is it possible to trigger click at perticular position (eg: X : 20px, Y : 50px) of document in chrome extention.

sathishkumar
  • 1,780
  • 4
  • 20
  • 31

1 Answers1

1

Instead of triggering a click event, I believe it better suits your purpose to access the jQuery object directly.

As you correctly mentioned, content scripts are executed in a sandboxed environment.
Still, you can access the web-pages JS context through the shared DOM. All you need to do is add a script node including the necessary code, e.g.:

var script = document.createElement("script");
script.type = "text/javascript";
script.textContent =
        "// Accessing the web-page's JS contex\n" +
        "$(\"#myElem\").doSomething();";

document.body.appendChild(script);
script.parentNode.removeChild(script);

There is, also, this very detailed answer, describing the various JS injection methods (including bonus tips and tricks).

Community
  • 1
  • 1
gkalpak
  • 47,844
  • 8
  • 105
  • 118