mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-03-03 06:42:41 +01:00
Settings only need to be loaded when still in default state.
This commit is contained in:
parent
a4a92fc2f9
commit
2b1a32e078
32
lib/frame.js
32
lib/frame.js
@ -75,9 +75,8 @@
|
||||
port.postMessage({"canvasBlocker-notify": data});
|
||||
}
|
||||
|
||||
const preferences = require("sdk/simple-prefs");
|
||||
function prefs(name){
|
||||
return preferences.prefs[name];
|
||||
return settings[name];
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +92,7 @@
|
||||
catch (e){
|
||||
// we are unable to read the location due to SOP
|
||||
// therefore we also can not intercept anything.
|
||||
warning("NOT intercepting window du to SOP", window);
|
||||
warning("NOT intercepting window due to SOP", window);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -139,7 +138,25 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
interceptWindow(window);
|
||||
if (settings.isStillDefault){
|
||||
message("load settings");
|
||||
browser.storage.local.get().then(function(data){
|
||||
Object.keys(data).forEach(function(key){
|
||||
notice("loaded setting:", key, ":", data[key]);
|
||||
settings[key] = data[key];
|
||||
var match = key.match(/^(.+)list$/i);
|
||||
if (match){
|
||||
lists.update(match[1]);
|
||||
}
|
||||
});
|
||||
settings.isStillDefault = false;
|
||||
logging.clearQueue();
|
||||
interceptWindow(window);
|
||||
});
|
||||
}
|
||||
else {
|
||||
interceptWindow(window);
|
||||
}
|
||||
|
||||
message("register listener for messages from background script");
|
||||
browser.runtime.onMessage.addListener(function(data){
|
||||
@ -156,13 +173,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
message("load settings");
|
||||
browser.storage.local.get().then(function(data){
|
||||
Object.keys(data).forEach(function(key){
|
||||
notice("loaded setting:", key, ":", data[key]);
|
||||
settings[key] = data[key];
|
||||
});
|
||||
});
|
||||
|
||||
message("register listener for settings changes");
|
||||
browser.storage.onChanged.addListener(function(change, area){
|
||||
|
Loading…
x
Reference in New Issue
Block a user