Converted apiWhiteList to protectedAPIFeatures

For #247
This commit is contained in:
kkapsner 2018-09-07 23:52:29 +02:00
parent 2138467fd3
commit fa92c15dab
7 changed files with 32 additions and 17 deletions

View File

@ -502,12 +502,12 @@
"description": ""
},
"apiWhiteList_title": {
"message": "API Whitelist",
"protectedAPIFeatures_title": {
"message": "Geschützte API Funktionen",
"description": ""
},
"apiWhiteList_description": {
"message": "Erlaubt ausgewählte Teile der APIs. Wenn eine der Boxen markiert wird, wird dieser Teil der API nicht geschützt.",
"protectedAPIFeatures_description": {
"message": "Liste der geschützten Funktionen der APIs. Wenn eine der Boxen demarkiert wird, wird dieser Teil der API nicht geschützt.",
"description": ""
},

View File

@ -502,12 +502,12 @@
"description": ""
},
"apiWhiteList_title": {
"message": "API whitelist",
"protectedAPIFeatures_title": {
"message": "Protected API features",
"description": ""
},
"apiWhiteList_description": {
"message": "Allows certain parts of the APIs. When ticking a checkbox this feature of the API will not be protected.",
"protectedAPIFeatures_description": {
"message": "List of protected API features. When unticking a checkbox this feature of the API will not be protected.",
"description": ""
},

View File

@ -234,7 +234,7 @@
});
}
if (funcStatus.active && !prefs("apiWhiteList")[name]){
if (funcStatus.active && prefs("protectedAPIFeatures")[name]){
if (funcStatus.mode === "ask"){
funcStatus.mode = ask({
window: window,

View File

@ -74,7 +74,7 @@
options: ["white", "nonPersistent", "constant", "persistent"]
},
{
name: "apiWhiteList",
name: "protectedAPIFeatures",
defaultValue: {},
keys: [
{name: "Canvas-API", level: 1},
@ -105,7 +105,7 @@
"boundingClientRect",
"rootBounds",
],
defaultKeyValue: false
defaultKeyValue: true
},
{
name: "useCanvasCache",
@ -298,7 +298,7 @@
},
{
name: "storageVersion",
defaultValue: 0.3,
defaultValue: 0.4,
fixed: true
}
];

View File

@ -530,7 +530,7 @@
}
const settingsMigration = {
validVersions: [undefined, 0.1, 0.2],
validVersions: [undefined, 0.1, 0.2, 0.3, 0.4],
transitions: {
"": function(oldStorage){
return {
@ -600,7 +600,20 @@
});
return newStorage;
}
},
0.3: function(oldStorage){
var newStorage = {
storageVersion: 0.4
};
if (oldStorage.hasOwnProperty("apiWhiteList")){
const protectedAPIFeatures = {};
Object.keys(oldStorage.apiWhiteList).forEach(function(key){
protectedAPIFeatures[key] = !oldStorage.apiWhiteList[key];
});
newStorage.protectedAPIFeatures = protectedAPIFeatures;
}
return newStorage;
},
}
};
@ -622,7 +635,9 @@
else if (storage.storageVersion !== settings.storageVersion){
var toChange = {};
while (storage.storageVersion !== settings.storageVersion){
logging.message("Old storage found. Storage version", storage.storageVersion);
logging.message("Old storage found (",
storage.storageVersion, "expected", settings.storageVersion,
")");
if (settingsMigration.transitions[storage.storageVersion]){
var changes = settingsMigration.transitions[storage.storageVersion](storage);
Object.entries(changes).forEach(function(entry){

View File

@ -184,7 +184,7 @@
]
},
{
"name": "apiWhiteList",
"name": "protectedAPIFeatures",
"displayDependencies": [
{
"displayAdvancedSettings": [true]

View File

@ -1,6 +1,6 @@
Version 0.5.4:
changes:
-
- converted "API whitelist" to "protected API features" (automatic settings migration)
new features:
- added save/load directly to/from file option