2017-10-03 15:35:31 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-06-25 22:22:17 +02:00
|
|
|
window.scope = {};
|
|
|
|
function require(module){
|
2017-10-03 15:35:31 +02:00
|
|
|
"use strict";
|
2017-06-25 22:22:17 +02:00
|
|
|
if (module.startsWith("./")){
|
|
|
|
var scopeName = module.substr(2).replace(/\..+/, "");
|
|
|
|
return window.scope[scopeName];
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-10-03 15:35:31 +02:00
|
|
|
};
|
2017-06-25 22:22:17 +02:00
|
|
|
}
|
2017-10-03 15:35:31 +02:00
|
|
|
throw new ReferenceError("Unable to get non relative module " + module + "!");
|
2017-09-23 23:47:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
window.scope.require = require;
|