1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-06-14 00:49:52 +02:00

Fixed bug that the update of the lists sometimes did not use the new value but the old one.

This commit is contained in:
kkapsner 2017-09-23 23:47:44 +02:00
parent 2b1a32e078
commit 26c5968b64
2 changed files with 18 additions and 14 deletions

View File

@ -67,24 +67,26 @@
black: [] black: []
}; };
function updateList(type){ function updateList(type, value){
"use strict"; "use strict";
if (typeof value === "undefined"){
lists[type] = getDomainRegExpList(prefs[type + "List"]); value = prefs[type + "List"];
}
lists[type] = getDomainRegExpList(value);
} }
Object.keys(lists).forEach(function(type){ Object.keys(lists).forEach(function(type){
"use strict"; "use strict";
preferences.on(type + "List", function(){ preferences.on(type + "List", function(value){
updateList(type); updateList(type, value);
}); });
updateList(type); updateList(type, prefs[type + "List"]);
}); });
function updateStackList(){ function updateStackList(value){
var list; var list;
try { try {
var data = JSON.parse(prefs.stackList); var data = JSON.parse(value);
if (!Array.isArray(data)){ if (!Array.isArray(data)){
data = [data]; data = [data];
} }
@ -103,10 +105,10 @@
lists.stack = list; lists.stack = list;
} }
lists.stack = []; lists.stack = [];
preferences.on("stackList", function(){ preferences.on("stackList", function(value){
updateStackList(); updateStackList(value);
}); });
updateStackList(); updateStackList(prefs.stackList);
scope.get = function getList(type){ scope.get = function getList(type){
"use strict"; "use strict";
@ -127,6 +129,6 @@
updateList("white"); updateList("white");
updateList("ignore"); updateList("ignore");
updateList("black"); updateList("black");
updateStackList(); updateStackList(prefs.stackList);
}; };
}()); }());

View File

@ -16,7 +16,7 @@ function require(module){
browser.storage.onChanged.addListener(function(changes, area){ browser.storage.onChanged.addListener(function(changes, area){
if (area === "local"){ if (area === "local"){
if (changes.hasOwnProperty(key)){ if (changes.hasOwnProperty(key)){
callback(); callback(changes[key].newValue);
} }
} }
}); });
@ -37,4 +37,6 @@ function require(module){
} }
console.error("Not able to get non relative modules!", module); console.error("Not able to get non relative modules!", module);
return undefined; return undefined;
} }
window.scope.require = require;