mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-05-19 19:02:21 +02:00
parent
c5872ef5a1
commit
68fb7730b9
@ -2,33 +2,47 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
window.scope = {};
|
const require = function(){
|
||||||
function require(module){
|
|
||||||
"use strict";
|
"use strict";
|
||||||
if (module.startsWith("./")){
|
window.scope = {};
|
||||||
var scopeName = module.substr(2).replace(/\..+/, "");
|
const scope = window.scope;
|
||||||
return window.scope[scopeName];
|
function require(module){
|
||||||
}
|
if (module.startsWith("./")){
|
||||||
else if (module === "sdk/getWrapped"){
|
var scopeName = module.substr(2).replace(/\..+/, "");
|
||||||
return function getWrapped(obj){
|
return scope[scopeName];
|
||||||
return obj.wrappedJSObject || obj;
|
}
|
||||||
};
|
else if (module === "sdk/getWrapped"){
|
||||||
}
|
return function getWrapped(obj){
|
||||||
else if (module === "sdk/simple-prefs"){
|
if (!obj){
|
||||||
return {
|
return obj;
|
||||||
prefs: settings,
|
}
|
||||||
on: function(key, callback){
|
var wrapped;
|
||||||
browser.storage.onChanged.addListener(function(changes, area){
|
try {
|
||||||
if (area === "local"){
|
wrapped = obj.wrappedJSObject || obj;
|
||||||
if (changes.hasOwnProperty(key)){
|
}
|
||||||
callback(changes[key].newValue);
|
catch (e){
|
||||||
|
require("./logging").error("getWrapped failed for", obj, ":", e);
|
||||||
|
wrapped = obj;
|
||||||
|
}
|
||||||
|
return wrapped;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (module === "sdk/simple-prefs"){
|
||||||
|
return {
|
||||||
|
prefs: settings,
|
||||||
|
on: function(key, callback){
|
||||||
|
browser.storage.onChanged.addListener(function(changes, area){
|
||||||
|
if (area === "local"){
|
||||||
|
if (changes.hasOwnProperty(key)){
|
||||||
|
callback(changes[key].newValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
throw new ReferenceError("Unable to get non relative module " + module + "!");
|
||||||
}
|
}
|
||||||
throw new ReferenceError("Unable to get non relative module " + module + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
window.scope.require = require;
|
return require;
|
||||||
|
}();
|
Loading…
x
Reference in New Issue
Block a user