这始于2016年11月2日 - firefox开发者版(但显然也是主要的)
代码:
var self = require("sdk/self");
var tabs = require("sdk/tabs");
tabs.on('ready', function(tab){
tab.attach({
contentScriptFile: [self.data.url('js/my-file.js')]
})
});
console.error:
JPM [error] Message: Error: Creating URI from string failed
Stack:
sandbox@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js:32:17
WorkerSandbox@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/sandbox.js:145:19
constructor@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/core/heritage.js:146:23
initialize@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/worker-child.js:52:20
constructor@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/core/heritage.js:146:23
@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/tab-events.js:51:3
emitOnObject@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
emitOnObject@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
emitOnObject@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:123:45
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
messageReceived@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/remote/child.js:67:37
第一次附加时工作正常,但当您导航到同一选项卡中的另一个URL时,我得到上述错误。因此,在分离和重新附加脚本时,可能会失败。任何帮助或想法都非常感谢,非常欢迎!
答案 0 :(得分:0)
Soo ..如果你没有" jpm init"在新文件夹中,并复制粘贴另一个,以前初始化的文件夹的内容 - 你得到上述错误。我的错误。