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