mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Changed library functions that may work in both types.
Added helper scripts for webExtension.
This commit is contained in:
parent
6c3b27e7e4
commit
4ea073132d
6 changed files with 190 additions and 97 deletions
40
lib/require.js
Normal file
40
lib/require.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
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"){
|
||||
if (changes[key]){
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (module === "sdk/l10n"){
|
||||
return {
|
||||
get: function(key){console.log(key);
|
||||
return browser.i18n.getMessage(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (module === "sdk/url"){
|
||||
return {
|
||||
URL
|
||||
}
|
||||
}
|
||||
console.error("Not able to get non relative modules!", module);
|
||||
return undefined;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue