0

I am still learning about all the Chrome Extension scheme, with background/content/popup scripts.

I have a page that runs some script on $(document).ready() and it sets a new variable in the window, that i can access in the website like "window.newVariableHere". I want to be able to echo the content of this variable whenever i open the Extension popup.

I tried, in the popup.js (which is being called in my popup.html) do a:

chrome.extension.getBackgroundPage()

But it wont show the new variable (that i am sure it was created). Any ideas on a better way to do this?

Thanks for all the ideas

Mauricio Vargas
  • 130
  • 1
  • 13

1 Answers1

1

chrome.extension.getBackgroundPage() gives you the window object of the background page, not the actual displayed website in the current tab.

Please read the Architecture Overview. (All Chrome extension developers must read and understand that)

You will need a content script, and worse than that, you will need a page-level script since window object of the page is isolated from content scripts.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • That's basically exactly what i was looking for, i was just kinda lost on where/what to look after in the documentation. Thank you very much. – Mauricio Vargas Nov 13 '14 at 11:52