I need to be able to read a variable set on a google chrome extension from any web page.
For example on a firefox extension I am doing this :
XPCNativeWrapper.unwrap(contentWindow).myExtensionName_varName = "value";
Then on any web page if I do alert(myExtensionName_varName); I get the correct value.
How could I achieve the same thing on a chrome extension?
Everything in Chrome is sandboxed for security and to avoid conflicts, so you don’t have direct access from extension to any variable created by website scripts.
Check out ‘Communication with the embedding page’ section here to learn how to communicate between scripts on webpages and extension content scripts.