我创建了一个加载jQuery作为内容脚本的加载项。这是为了确保依赖jQuery的其他内容脚本可以使用它。
在OSX上运行时,扩展按预期工作,并在启动扩展时加载jQuery。然而,在Windows上运行的相同应用程序不会加载jQuery。我在两台机器上都使用Firefox版本40并且我在扩展中尝试了2.0和1.x版本的jQuery以确保它不是这样做。
有没有人想过可能导致这个问题的原因?
main.js
tabs.on('ready', function(tab) {
if(tab.url.indexOf(pageurl) === -1) return;
worker = tab.attach({
contentScriptFile: [
data.url("./app/scripts/jquery.js"),
data.url("./app/scripts/google.js")]
});
worker.port.on("request-cookie", function(){
console.log("index.js received cookie request");
worker.port.emit("response-cookie", getBungieCookies());
});
});
控制台错误
$ jpm run
JPM [info] Starting jpm run on My Jetpack Addon
JPM [warning] Using existing install.rdf. This file is usually auto-generated.
JPM [warning] Using existing bootstrap.js. This file is usually auto-generated.
Creating XPI
JPM [info] XPI created at C:\Users\somalley\AppData\Local\Temp\@testaddon-0.0.1.xpi (31090ms)
Created XPI at C:\Users\somalley\AppData\Local\Temp\@testaddon-0.0.1.xpi
JPM [info] Creating a new profile
console.error: testaddon:
Object
- _errorType = ReferenceError
- message = jQuery is not defined
- fileName = resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/ap
p/scripts/ScrollToFixed.js
- lineNumber = 558
- stack = @resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/app/
scripts/ScrollToFixed.js:558:1|
- name = ReferenceError
console.error: testaddon:
Object
- _errorType = ReferenceError
- message = $ is not defined
- fileName = resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/ap
p/scripts/dimApp.config.js
- lineNumber = 136
- stack = @resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/app/
scripts/dimApp.config.js:136:1|
- name = ReferenceError
console.error: testaddon:
Object
- _errorType = TypeError
- message = s is undefined
- fileName = resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/ap
p/scripts/google.js
- lineNumber = 8
- stack = @resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/data/app/
scripts/google.js:8:55|@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://testaddon/
data/app/scripts/google.js:5:2|
- name = TypeError