mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
a4d9be9bd5
commit
f3a6031f5a
14
lib/main.js
14
lib/main.js
@ -95,11 +95,11 @@
|
||||
allFrames: true,
|
||||
runAt: "document_start",
|
||||
js: [{
|
||||
code: `(function(){
|
||||
code: `(function(settingsData){
|
||||
if (typeof require !== "undefined"){
|
||||
const settings = require("./settings");
|
||||
const logging = require("./logging");
|
||||
if (settings.init(${JSON.stringify(data)})){
|
||||
if (settings.init(settingsData)){
|
||||
logging.message("Initialized settings by dynamic content script.");
|
||||
}
|
||||
else {
|
||||
@ -107,12 +107,16 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error(
|
||||
"[CanvasBlocker] invalid content scripts: require not defined at",
|
||||
if (!window.scope){
|
||||
window.scope = {};
|
||||
}
|
||||
window.scope.settingsData = settingsData;
|
||||
console.warn(
|
||||
"[CanvasBlocker] invalid content script order: require not defined at",
|
||||
window.location.href
|
||||
);
|
||||
}
|
||||
}())`
|
||||
}(${JSON.stringify(data)}))`
|
||||
}]
|
||||
}).then(function(api){
|
||||
logging.verbose("Content script registered.");
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
const require = function(){
|
||||
"use strict";
|
||||
window.scope = {};
|
||||
if (!window.scope){
|
||||
window.scope = {};
|
||||
}
|
||||
const scope = window.scope;
|
||||
|
||||
function getScopeName(module){
|
||||
|
@ -415,7 +415,13 @@
|
||||
initEvents.forEach(function(callback){callback();});
|
||||
return true;
|
||||
};
|
||||
scope.loaded = browser.storage.local.get().then(scope.init);
|
||||
if (window.scope.settingsData){
|
||||
scope.init(window.scope.settingsData);
|
||||
scope.loaded = Promise.resolve(false);
|
||||
}
|
||||
else {
|
||||
scope.loaded = browser.storage.local.get().then(scope.init);
|
||||
}
|
||||
scope.onloaded = function(callback){
|
||||
if (scope.isStillDefault){
|
||||
initEvents.push(callback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user