1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02: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

@ -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