mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Improved storage of protected API features
This commit is contained in:
parent
1430b89d55
commit
cc776b48de
6 changed files with 73 additions and 37 deletions
|
@ -12,6 +12,9 @@
|
|||
else {
|
||||
scope = require.register("./settingsMigration", {});
|
||||
}
|
||||
|
||||
const settingDefinitions = require("./settingDefinitions");
|
||||
|
||||
scope.validVersions = [undefined, 0.1, 0.2, 0.3, 0.4, 0.5];
|
||||
scope.transitions = {
|
||||
"": function(oldStorage){
|
||||
|
@ -129,7 +132,31 @@
|
|||
}
|
||||
}
|
||||
return newStorage;
|
||||
}
|
||||
},
|
||||
0.5: function(oldStorage){
|
||||
var newStorage = {
|
||||
storageVersion: 0.6
|
||||
};
|
||||
|
||||
if (oldStorage.hasOwnProperty("protectedAPIFeatures")){
|
||||
const protectedAPIFeatures = {};
|
||||
const protectedAPIFeaturesKeys = settingDefinitions.filter(function(definition){
|
||||
return definition.name === "protectedAPIFeatures";
|
||||
})[0].keys.filter(function(key){
|
||||
return typeof key === "string";
|
||||
});
|
||||
Object.keys(oldStorage.protectedAPIFeatures).forEach(function(key){
|
||||
const matchingKeys = protectedAPIFeaturesKeys.filter(function(definedKey){
|
||||
return definedKey.startsWith(key);
|
||||
});
|
||||
if (matchingKeys.length){
|
||||
protectedAPIFeatures[matchingKeys[0]] = oldStorage.protectedAPIFeatures[key];
|
||||
}
|
||||
});
|
||||
newStorage.protectedAPIFeatures = protectedAPIFeatures;
|
||||
}
|
||||
return newStorage;
|
||||
},
|
||||
};
|
||||
|
||||
scope.check = function(storage, {settings, logging, changeValue, urlContainer}){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue