Search code examples
google-chromegoogle-chrome-extension

Global Variables in Chrome Extensions


Is there a simple way where I can access a global javascript variable through content-scripts in chrome extensions?

Accessing global object from content script in chrome extension

I followed the steps mentioned in the above link, but it did not work out for me. Any help would be much appreciated.

Thanks, Shankar


Solution

  • I managed to complete it. Thanks for the help. I used simple message passing to retrieve the value from the extension script to the content script. The place where I had missed was, the listener at the extension script needs to be at the background page (I think so). Once I changed that, it worked.