我使用webextension模块试图端口Chrome扩展在晚间(现在),但是,当我试图做的要求(“SDK /标签” );为什么需要不使用WebExtension(Chrome扩展的Firefox)定义
var tabs = require("sdk/tabs");
tabs.on("ready",function(tabs) {
if (tabs && tabs.url && tabs.url.match(driveURLpattern) || tabs.url.match(docsURLpattern)) {
currentTabId = tabs.id;
return authentication();
}
});
Console: ReferenceError: require is not defined
但它不起作用...我如何定义它?
更新:为Chrome原始代码是:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status === 'complete') {
if (tab && tab.url && tab.url.match(driveURLpattern) || tab.url.match(docsURLpattern)) {
currentTabId = tab.id;
return authentication();
}
}
});
在此先感谢!
eKivOx
编辑:气相色谱法确认。谢谢你
解决方案是,要求不是在WebExtensions,我们不能像SDK的插件,所以我检查兼容性的ChromeAPi和我看到chrome.tabs.onUpdated()是兼容的! Cya
您使用JPM? –
在我的电脑上?是有它 –
我的意思是,你正在使用JPM创建Firefox扩展 - 你已经使用'JPM init'和使用'JPM run'等我不使用的SDK-插件 –