1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-01 02:48:44 +01:00

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": "" "description": ""
}, },
"apiWhiteList_title": { "protectedAPIFeatures_title": {
"message": "API Whitelist", "message": "Geschützte API Funktionen",
"description": "" "description": ""
}, },
"apiWhiteList_description": { "protectedAPIFeatures_description": {
"message": "Erlaubt ausgewählte Teile der APIs. Wenn eine der Boxen markiert wird, wird dieser Teil der API nicht geschützt.", "message": "Liste der geschützten Funktionen der APIs. Wenn eine der Boxen demarkiert wird, wird dieser Teil der API nicht geschützt.",
"description": "" "description": ""
}, },

View File

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

View File

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

View File

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

View File

@ -530,7 +530,7 @@
} }
const settingsMigration = { const settingsMigration = {
validVersions: [undefined, 0.1, 0.2], validVersions: [undefined, 0.1, 0.2, 0.3, 0.4],
transitions: { transitions: {
"": function(oldStorage){ "": function(oldStorage){
return { return {
@ -600,7 +600,20 @@
}); });
return newStorage; 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){ else if (storage.storageVersion !== settings.storageVersion){
var toChange = {}; var toChange = {};
while (storage.storageVersion !== settings.storageVersion){ 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]){ if (settingsMigration.transitions[storage.storageVersion]){
var changes = settingsMigration.transitions[storage.storageVersion](storage); var changes = settingsMigration.transitions[storage.storageVersion](storage);
Object.entries(changes).forEach(function(entry){ Object.entries(changes).forEach(function(entry){

View File

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

View File

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