In my chrome's manifest file, I have a content_scripts declaration to call a js file on a certain site e.g.:
"content_scripts": [
{
"matches": ["https://example.com/*"],
"js": ["jquery-1.11.3.js", "myjs.js"]
}
The matched site I am testing this extension on contains a javascript file which declares a global variable, var 'Foo'. I want to access this variable in my extension's own myjs.js file. However, when I attempt to reference the variable, I get an error in the console:
Uncaught ReferenceError: Foo is not defined
I attempted to add a setTimeout of 2 seconds before using the variable, but it still produces the same error. If I open up Chrome's Developer tools (F12) Console and simply type the variable name 'Foo', it actually returns the variable without issues.
How can I get my chrome extension's js file to access the site's global js variable?