Reputation: 41
i'm trying to port Chrome Extension on Nightly(for now) using webextension module , but , when i'm trying to do require("sdk/tabs");
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
But it doesn't work...How can i define it ?
UPDATE: Original code for Chrome is:
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();
}
}
});
Thanks in advance !
eKivOx
EDIT : SOLUTION WAS FOUND. THANK YOU
The solution is , require isn't in WebExtensions, we can't do like the SDK-addons , so i've check compatibilities of ChromeAPi and i saw chrome.tabs.onUpdated() is compatible !Cya
Upvotes: 1
Views: 2339
Reputation: 808
require is used in context of CommonJS modules. It imports the methods exported by library modules. You cannot port your chrome extension to FF-addon as is. You need to create a new Firefox extension using JPM, and within the add-on script, use require
HTH
Upvotes: 1