1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-01-09 13:15:00 +01:00

Activated settings migration to 0.3

This commit is contained in:
kkapsner 2017-12-08 20:25:08 +01:00
parent 74863d3c98
commit d787b84b13
2 changed files with 37 additions and 26 deletions

View File

@ -149,7 +149,7 @@
},
{
name: "storageVersion",
defaultValue: 0.2,
defaultValue: 0.3,
fixed: true
}
];

View File

@ -493,31 +493,42 @@
var urlSettings = {};
(oldStorage.blackList || "").split(",").forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, blockMode: "block"};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
});
(oldStorage.whiteList || "").split(",").forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, blockMode: "allow"};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
});
(oldStorage.ignoreList || "").split(",").forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, showNotifications: false};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
else {
entry.showNotifications = false;
(oldStorage.blackList || "").split(",")
.filter(function(url){return !!url.trim();})
.forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, blockMode: "block"};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
});
(oldStorage.whiteList || "").split(",")
.filter(function(url){return !!url.trim();})
.forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, blockMode: "allow"};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
});
(oldStorage.ignoreList || "").split(",")
.filter(function(url){return !!url.trim();})
.forEach(function(url){
var entry = urlSettings[url];
if (!entry){
entry = {url, showNotifications: false};
urlSettings[url] = entry;
newStorage.urlSettings.push(entry);
}
else {
entry.showNotifications = false;
}
});
["whiteList", "blackList", "ignoreList"].forEach(function(list){
if (oldStorage.hasOwnProperty(list)){
newStorage[list] = "";
}
});