1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Added ask deny mode

Fixes #142 and some minor bugs.
This commit is contained in:
kkapsner 2017-11-09 00:53:52 +01:00
parent e539a893b4
commit f75189f374
8 changed files with 224 additions and 95 deletions

View File

@ -78,6 +78,22 @@
"message": "Nur einmal nachfragen", "message": "Nur einmal nachfragen",
"description": "" "description": ""
}, },
"askDenyMode_title":{
"message": "Nachfrageverweigerungsmodus",
"description": ""
},
"askDenyMode_description":{
"message": "Welcher Modus soll gewählt werden, wenn die Erlaubnis verweigert wird.",
"description": ""
},
"askDenyMode_options.block":{
"message": "blockieren",
"description": ""
},
"askDenyMode_options.fake":{
"message": "vortäuschen",
"description": ""
},
"blackList_description": { "blackList_description": {
"message": "Domänen oder URLs, die die <canvas>-API niemals verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt werden.", "message": "Domänen oder URLs, die die <canvas>-API niemals verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt werden.",
"description": "" "description": ""

View File

@ -78,6 +78,22 @@
"message": "Ask only once", "message": "Ask only once",
"description": "" "description": ""
}, },
"askDenyMode_title":{
"message": "Ask deny mode",
"description": ""
},
"askDenyMode_description":{
"message": "Which mode should be used when the permission is denied.",
"description": ""
},
"askDenyMode_options.block":{
"message": "block",
"description": ""
},
"askDenyMode_options.fake":{
"message": "fake",
"description": ""
},
"blackList_description": { "blackList_description": {
"message": "Domains or URLs where the <canvas>-API should always be blocked. To add multiple entries, separate them by commas.", "message": "Domains or URLs where the <canvas>-API should always be blocked. To add multiple entries, separate them by commas.",
"description": "" "description": ""

View File

@ -136,7 +136,7 @@
if (prefs("showCallingFile")){ if (prefs("showCallingFile")){
msg += parseErrorStack(errorStack).toString(_); msg += parseErrorStack(errorStack).toString(_);
} }
answer = window.confirm(msg)? "allow": "block"; answer = window.confirm(msg)? "allow": prefs("askDenyMode");
askStatus.alreadyAsked[appearance.text] = true; askStatus.alreadyAsked[appearance.text] = true;
askStatus.answer[appearance.text] = answer; askStatus.answer[appearance.text] = answer;
appearance.reset(); appearance.reset();

View File

@ -62,7 +62,9 @@
if (siteStatus.mode !== "allow"){ if (siteStatus.mode !== "allow"){
apiNames.forEach(function(name){ apiNames.forEach(function(name){
var changedFunction = changedFunctions[name]; var changedFunction = changedFunctions[name];
if (changedFunction.getStatus(undefined, siteStatus).active){ var functionStatus = changedFunction.getStatus(undefined, siteStatus);
logging.verbose("status for", name, ":", functionStatus);
if (functionStatus.active){
( (
Array.isArray(changedFunction.object)? Array.isArray(changedFunction.object)?
changedFunction.object: changedFunction.object:

View File

@ -166,7 +166,7 @@
} }
else if (hasType(status, "context") || hasType(status, "input")){ else if (hasType(status, "context") || hasType(status, "input")){
return { return {
mode: (status.mode === "block")? "block": "fake", mode: status.mode,
type: status.type, type: status.type,
active: true active: true
}; };
@ -189,13 +189,11 @@
type: "readout", type: "readout",
getStatus: function(obj, status){ getStatus: function(obj, status){
status = Object.create(status); status = Object.create(status);
if (hasType(status, "input")){ status.active = hasType(status, "readout");
if (!status.active && hasType(status, "input")){
var contextType = canvasContextType.get(obj); var contextType = canvasContextType.get(obj);
status.active = contextType !== "2d"; status.active = contextType !== "2d";
} }
else {
status.active = hasType(status, "readout");
}
return status; return status;
}, },
object: "HTMLCanvasElement", object: "HTMLCanvasElement",
@ -215,13 +213,11 @@
type: "readout", type: "readout",
getStatus: function(obj, status){ getStatus: function(obj, status){
status = Object.create(status); status = Object.create(status);
if (hasType(status, "input")){ status.active = hasType(status, "readout");
if (!status.active && hasType(status, "input")){
var contextType = canvasContextType.get(obj); var contextType = canvasContextType.get(obj);
status.active = contextType !== "2d"; status.active = contextType !== "2d";
} }
else {
status.active = hasType(status, "readout");
}
return status; return status;
}, },
object: "HTMLCanvasElement", object: "HTMLCanvasElement",
@ -242,13 +238,11 @@
type: "readout", type: "readout",
getStatus: function(obj, status){ getStatus: function(obj, status){
status = Object.create(status); status = Object.create(status);
if (hasType(status, "input")){ status.active = hasType(status, "readout");
if (!status.active && hasType(status, "input")){
var contextType = canvasContextType.get(obj); var contextType = canvasContextType.get(obj);
status.active = contextType !== "2d"; status.active = contextType !== "2d";
} }
else {
status.active = hasType(status, "readout");
}
return status; return status;
}, },
object: "HTMLCanvasElement", object: "HTMLCanvasElement",

View File

@ -76,6 +76,11 @@
name: "askOnlyOnce", name: "askOnlyOnce",
defaultValue: true defaultValue: true
}, },
{
name: "askDenyMode",
defaultValue: "block",
options: ["block", "fake"]
},
{ {
name: "showNotifications", name: "showNotifications",
defaultValue: true defaultValue: true

View File

@ -22,73 +22,6 @@
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "ask", "allow"] "blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "ask", "allow"]
} }
}, },
{
"name": "minFakeSize",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
}
},
{
"name": "maxFakeSize",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
}
},
{
"name": "rng",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
}
},
{
"name": "storePersistentRnd",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
},
{
"name": "persistentRndClearInterval",
"inputs": ["persistentRndClearIntervalValue", "persistentRndClearIntervalUnit"],
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
},
{
"name": "clearPersistentRnd",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
},
{
"name": "ignoreFrequentColors",
"displayDependencies": {
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
}
},
{
"name": "fakeAlphaChannel",
"displayDependencies": {
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
}
},
{
"name": "useCanvasCache",
"displayDependencies": {
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
}
},
{ {
"name": "askOnlyOnce", "name": "askOnlyOnce",
"displayDependencies": { "displayDependencies": {
@ -96,25 +29,186 @@
} }
}, },
{ {
"name": "showNotifications", "name": "askDenyMode",
"displayDependencies": { "displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"] "blockMode": ["askReadout", "ask"],
}
},
{
"name": "storeImageForInspection",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"showNotifications": [true],
"displayAdvancedSettings": [true] "displayAdvancedSettings": [true]
} }
}, },
{
"name": "minFakeSize",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "maxFakeSize",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "rng",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "storePersistentRnd",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "persistentRndClearInterval",
"inputs": ["persistentRndClearIntervalValue", "persistentRndClearIntervalUnit"],
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "clearPersistentRnd",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"rng": ["persistent"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "ignoreFrequentColors",
"displayDependencies": [
{
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "fakeAlphaChannel",
"displayDependencies": [
{
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "useCanvasCache",
"displayDependencies": [
{
"blockMode": ["fakeReadout"],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"displayAdvancedSettings": [true]
}
]
},
{
"name": "showNotifications",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"]
}
]
},
{
"name": "storeImageForInspection",
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"showNotifications": [true],
"displayAdvancedSettings": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"showNotifications": [true],
"displayAdvancedSettings": [true]
}
]
},
{ {
"name": "ignoreList", "name": "ignoreList",
"displayDependencies": { "displayDependencies": [
"blockMode": ["fakeReadout", "fakeInput"], {
"showNotifications": [true] "blockMode": ["fakeReadout", "fakeInput"],
} "showNotifications": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"showNotifications": [true]
}
]
}, },
{ {
"name": "showCallingFile", "name": "showCallingFile",

View File

@ -6,9 +6,11 @@ Version 0.4.1:
new features: new features:
- setting to set an interval to clear the persistent random generator data - setting to set an interval to clear the persistent random generator data
- setting for the ask deny mode
fixes: fixes:
- unnecessary check for context type in getImageData broke websites - unnecessary check for context type in getImageData broke websites
- getContext was not asked in ask mode.
Version 0.4.0.2: Version 0.4.0.2:
fixes: fixes: