Here's a portion of my manifest.json file:
"content_scripts": [ {
"js": [ "common.js", "generation.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
{
"js": [ "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
Here, I want to run "common.js" before "page_init.js", as common.js contains much shared code and global variables and functions that the other content scripts need to function. I have defined common.js before page_init.js in my manifest, and, in Chrome, doing this results in common.js running before all the other content scripts, which is what I need. However, in Firefox, it doesn't seem to do this.
When I run this extension in Firefox, however, page_init throws an error:
ReferenceError: ReferenceError: href is not defined
"href" is a variable that's defined in common.js.
Do I need to make page_init.js run at document_end in order for common.js to fully run, or is there another way? I need them to both run at document_start.
UPDATE:
I managed to resolve the issue by changing the manifests contents to this:
"content_scripts": [
{
"js": [ "common.js", "generation.js", "page_init.js" ],
"matches": [ "*://www.site.com/*" ],
"run_at": "document_start"
},
From firefox documentation:
js
An array of paths, relative to manifest.json, referencing JavaScript files that will be injected into matching pages.
Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this...
It's probably a firefox bug, you may want to report it.