0

I am making a chrome extension.

I would like to be able to access the underlying browser page's window object, basically at-will.

I don't directly control the page in question, so I need some way to inject a script into the DOM, which will respond with the window object whenever it's queried.

I want to do this in a cleaner fashion than just stringifying a function and injecting it as a <script> into the DOM.

Is there a clean, standard way to do this?

I have tried to follow the instructions in http://waitingphoenix.com/how-to-make-your-chrome-extension-access-webpage/

but I cannot get a GET_DUCK event to fire anywhere.

Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78
  • Don't content scripts already have this ability? – Barmar Jul 31 '20 at 20:46
  • I don't think so? Everything I've googled says that the extension can't access page variables directly and instead has to communicate with the page. – Daniel Paczuski Bak Jul 31 '20 at 20:51
  • Right, I was thinking of `document`. – Barmar Jul 31 '20 at 20:52
  • In Chrome the only way is using a script element, see the linked topic for examples and methods of communication. In Firefox you can use wrappedJSObject to access the page context directly, see MDN site if needed. – wOxxOm Aug 01 '20 at 04:46

0 Answers0