2017-06-25 22:22:17 +02:00
|
|
|
window.scope = {};
|
|
|
|
function require(module){
|
|
|
|
if (module.startsWith("./")){
|
|
|
|
var scopeName = module.substr(2).replace(/\..+/, "");
|
|
|
|
return window.scope[scopeName];
|
|
|
|
}
|
|
|
|
else if (module === "chrome"){
|
|
|
|
return {
|
|
|
|
Cu: {exportFunction}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else if (module === "sdk/simple-prefs"){
|
|
|
|
return {
|
|
|
|
prefs: settings,
|
|
|
|
on: function(key, callback){
|
|
|
|
browser.storage.onChanged.addListener(function(changes, area){
|
|
|
|
if (area === "local"){
|
2017-07-02 12:21:16 +02:00
|
|
|
if (changes.hasOwnProperty(key)){
|
2017-09-23 23:47:44 +02:00
|
|
|
callback(changes[key].newValue);
|
2017-06-25 22:22:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (module === "sdk/l10n"){
|
|
|
|
return {
|
2017-07-07 08:50:23 +02:00
|
|
|
get: function(key){
|
2017-06-25 22:22:17 +02:00
|
|
|
return browser.i18n.getMessage(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (module === "sdk/url"){
|
|
|
|
return {
|
|
|
|
URL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.error("Not able to get non relative modules!", module);
|
|
|
|
return undefined;
|
2017-09-23 23:47:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
window.scope.require = require;
|