1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +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",
"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": {
"message": "Domänen oder URLs, die die <canvas>-API niemals verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt werden.",
"description": ""

View File

@ -78,6 +78,22 @@
"message": "Ask only once",
"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": {
"message": "Domains or URLs where the <canvas>-API should always be blocked. To add multiple entries, separate them by commas.",
"description": ""

View File

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

View File

@ -62,7 +62,9 @@
if (siteStatus.mode !== "allow"){
apiNames.forEach(function(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)?
changedFunction.object:

View File

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

View File

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

View File

@ -22,73 +22,6 @@
"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",
"displayDependencies": {
@ -96,25 +29,186 @@
}
},
{
"name": "showNotifications",
"name": "askDenyMode",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"]
}
},
{
"name": "storeImageForInspection",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"showNotifications": [true],
"blockMode": ["askReadout", "ask"],
"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",
"displayDependencies": {
"blockMode": ["fakeReadout", "fakeInput"],
"showNotifications": [true]
}
"displayDependencies": [
{
"blockMode": ["fakeReadout", "fakeInput"],
"showNotifications": [true]
},
{
"blockMode": ["askReadout", "ask"],
"askDenyMode": ["fake"],
"showNotifications": [true]
}
]
},
{
"name": "showCallingFile",

View File

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