mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
askOnly once extended
API-types can now be combined in "askOnlyOnce". Needed new storage version -> added settings migration
This commit is contained in:
parent
f75189f374
commit
a465303fff
@ -70,14 +70,26 @@
|
||||
"message": "Wollen Sie das Auslesen des rot umrandeten <canvas> erlauben?",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_description": {
|
||||
"message": "Wenn der Blockiermodus des Canvas Blockers auf \"um Erlaubnis fragen\" oder \"bei Auslese-API um Erlaubnis fragen\" gesetzt ist, erscheint jedes Mal ein Abfragedialog, wenn eine Seite versucht, die (Auslese-)API aufzurufen. Diese Einstellung versucht diese Abfrage nur einmal pro Seite anzuzeigen, unabhängig davon wie oft die API aufgerufen wird. Es können trotzdem mehrere Dialoge pro Seite erscheinen.",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_title": {
|
||||
"message": "Nur einmal nachfragen",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_description": {
|
||||
"message": "Wenn der Blockiermodus des Canvas Blockers auf \"um Erlaubnis fragen\" oder \"bei Auslese-API um Erlaubnis fragen\" gesetzt ist, erscheint jedes Mal ein Abfragedialog wenn eine Seite versucht, die (Auslese-)API aufzurufen. Diese Einstellung versucht diese Abfrage nur einmal pro Seite anzuzeigen, unabhängig davon wie oft die API aufgerufen wird. Es können trotzdem mehrere Dialoge pro Seite erscheinen.\nNein: es wird jedes mal gefragt\nIndividuell: jeder API-Typ (Context, Eingabe, Auslese) wird separat abgefragt\nKombiniert: alle API-Typen werden zusammen abgefragt",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.no": {
|
||||
"message": "nein",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.individual": {
|
||||
"message": "individuell",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.combined": {
|
||||
"message": "kombiniert",
|
||||
"description": ""
|
||||
},
|
||||
"askDenyMode_title":{
|
||||
"message": "Nachfrageverweigerungsmodus",
|
||||
"description": ""
|
||||
|
@ -70,14 +70,26 @@
|
||||
"message": "Do you want to allow the readout of the red bordered <canvas>?",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_description": {
|
||||
"message": "When Canvas Blocker's Block mode is set to 'ask permission' or 'ask permission for readout API', a confirm message will appear every time a page tries to access the API or readout API. This setting tries to display the confirm message only once for each page regardless of how many times the page tries to access the API. Nevertheless, multiple confirm messages may still be displayed on some pages.",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_title": {
|
||||
"message": "Ask only once",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_description": {
|
||||
"message": "When Canvas Blocker's Block mode is set to 'ask permission' or 'ask permission for readout API', a confirm message will appear every time a page tries to access the API or readout API. This setting tries to display the confirm message only once for each page regardless of how many times the page tries to access the API. Nevertheless, multiple confirm messages may still be displayed on some pages.\nNo: asking every time\nIndividual: each API-type (context, input, readout) has to be confirmed seperately\ncombined: all API-types get confirmed together",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.no": {
|
||||
"message": "no",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.individual": {
|
||||
"message": "individual",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_options.combined": {
|
||||
"message": "combined",
|
||||
"description": ""
|
||||
},
|
||||
"askDenyMode_title":{
|
||||
"message": "Ask deny mode",
|
||||
"description": ""
|
||||
|
@ -125,7 +125,7 @@
|
||||
var askMode = getAskMode(window, type, _);
|
||||
var askStatus = askMode.askStatus;
|
||||
var appearance = canvasAppearance(window, canvas);
|
||||
if (prefs("askOnlyOnce") && askStatus.alreadyAsked[appearance.askCategory]){
|
||||
if (prefs("askOnlyOnce") !== "no" && askStatus.alreadyAsked[appearance.askCategory]){
|
||||
// already asked
|
||||
appearance.reset();
|
||||
return askStatus.answer[appearance.askCategory];
|
||||
@ -137,8 +137,19 @@
|
||||
msg += parseErrorStack(errorStack).toString(_);
|
||||
}
|
||||
answer = window.confirm(msg)? "allow": prefs("askDenyMode");
|
||||
|
||||
if (prefs("askOnlyOnce") === "combined"){
|
||||
["context", "readout", "input"].forEach(function(type){
|
||||
var askMode = getAskMode(window, type, _);
|
||||
var askStatus = askMode.askStatus;
|
||||
askStatus.alreadyAsked[appearance.text] = true;
|
||||
askStatus.answer[appearance.text] = answer;
|
||||
});
|
||||
}
|
||||
else {
|
||||
askStatus.alreadyAsked[appearance.text] = true;
|
||||
askStatus.answer[appearance.text] = answer;
|
||||
}
|
||||
appearance.reset();
|
||||
return answer;
|
||||
}
|
||||
|
@ -91,13 +91,6 @@
|
||||
|
||||
browser.runtime.onInstalled.addListener(function(){
|
||||
message("CanvasBlocker installed");
|
||||
browser.storage.local.get("storageVersion").then(function(data){
|
||||
if (data.storageVersion !== 0.1){
|
||||
browser.storage.local.set({
|
||||
storageVersion: 0.1
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
message("end");
|
||||
|
@ -74,7 +74,8 @@
|
||||
},
|
||||
{
|
||||
name: "askOnlyOnce",
|
||||
defaultValue: true
|
||||
defaultValue: "individual",
|
||||
options: ["no", "individual", "combined"]
|
||||
},
|
||||
{
|
||||
name: "askDenyMode",
|
||||
@ -123,7 +124,8 @@
|
||||
},
|
||||
{
|
||||
name: "storageVersion",
|
||||
defaultValue: 0.1
|
||||
defaultValue: 0.2,
|
||||
fixed: true
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -48,11 +48,19 @@
|
||||
return settings[name];
|
||||
};
|
||||
settingDefinition.set = function setValue(newValue){
|
||||
if ((typeof newValue) === (typeof settingDefinition.defaultValue)){
|
||||
if (
|
||||
!settingDefinition.options ||
|
||||
settingDefinition.options.includes(newValue)
|
||||
if (settingDefinition.fixed){
|
||||
logging.warning("Trying to set the fixed setting", name, ":", newValue);
|
||||
}
|
||||
else if ((typeof newValue) !== (typeof settingDefinition.defaultValue)){
|
||||
logging.warning("Wrong type provided for setting", name, ":", newValue);
|
||||
}
|
||||
else if (
|
||||
settingDefinition.options &&
|
||||
!settingDefinition.options.includes(newValue)
|
||||
){
|
||||
logging.warning("Provided value outside specified options for ", name, ":", newValue);
|
||||
}
|
||||
else {
|
||||
settings[name] = newValue;
|
||||
if (!settingDefinition.transient){
|
||||
var storeObject = {};
|
||||
@ -61,13 +69,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
logging.warning("Provided value outside specified options for ", name, ":", newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logging.warning("Wrong type provided for setting", name, ":", newValue);
|
||||
}
|
||||
};
|
||||
Object.defineProperty(
|
||||
scope,
|
||||
@ -135,9 +136,55 @@
|
||||
}
|
||||
});
|
||||
|
||||
const settingsMigration = {
|
||||
validVersions: [undefined, 0.1, 0.2],
|
||||
transitions: {
|
||||
"": function(oldStorage){
|
||||
return {
|
||||
storageVersion: 0.2
|
||||
};
|
||||
},
|
||||
0.1: function(oldStorage){
|
||||
var newStorage = {
|
||||
storageVersion: 0.2
|
||||
};
|
||||
if (oldStorage.hasOwnProperty("askOnlyOnce")){
|
||||
newStorage.askOnlyOnce = oldStorage.askOnlyOnce? "individual": "no";
|
||||
}
|
||||
return newStorage;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
logging.verbose("loading settings");
|
||||
scope.loaded = browser.storage.local.get().then(function(storage){
|
||||
logging.message("settings loaded");
|
||||
if (!storage.storageVersion){
|
||||
logging.message("No storage version found. Initializing storage.");
|
||||
browser.storage.local.remove(Object.keys(storage));
|
||||
storage = settingsMigration.transitions[""]({});
|
||||
browser.storage.local.set(storage);
|
||||
}
|
||||
else if (storage.storageVersion !== settings.storageVersion){
|
||||
var toChange = {};
|
||||
while (storage.storageVersion !== settings.storageVersion){
|
||||
logging.message("Old storage found. Storage version", storage.storageVersion);
|
||||
if (settingsMigration.transitions[storage.storageVersion]){
|
||||
var changes = settingsMigration.transitions[storage.storageVersion](storage);
|
||||
Object.entries(changes).forEach(function(entry){
|
||||
const [name, value] = entry;
|
||||
toChange[name] = value;
|
||||
storage[name] = value;
|
||||
});
|
||||
}
|
||||
else {
|
||||
logging.warning("Unable to migrate storage.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
logging.notice("Changed settings:", toChange);
|
||||
browser.storage.local.set(toChange);
|
||||
}
|
||||
Object.entries(storage).forEach(function(entry){
|
||||
const [name, value] = entry;
|
||||
changeValue(name, value);
|
||||
|
@ -7,6 +7,7 @@ Version 0.4.1:
|
||||
new features:
|
||||
- setting to set an interval to clear the persistent random generator data
|
||||
- setting for the ask deny mode
|
||||
- ask only once can now also combine the API-types
|
||||
|
||||
fixes:
|
||||
- unnecessary check for context type in getImageData broke websites
|
||||
|
Loading…
x
Reference in New Issue
Block a user