我使用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-插件 –