0

How can I access a window variable from a chrome extension?

For example, I want my extension to just log window.variable?

Is this at all possible?

d-_-b
  • 21,536
  • 40
  • 150
  • 256
  • 1
    If its really a dup, the dup title (about gmail) doesnt help at all in finding it. So im not marking it dup – Zig Mandel Apr 19 '14 at 14:25

1 Answers1

2

You need to inject the script at runtime (as opposed to doing it from the content script). From the injected script use either messages to pass it to the extension, or (easier) write what you need in a DOM element and read it from the DOM (but changing the dom might break the original page) In the official samples shows how to inject the script by writting a tag.

I know this is a dup of the pointed gmail question but that question has a title that makes it hard to know its about injected scripts.

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36