mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Added setting to whitelist parts of the canvas API
This commit is contained in:
parent
9d0cd04fc3
commit
f02246128e
@ -394,6 +394,15 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"apiWhiteList_title": {
|
||||||
|
"message": "API Whitelist",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"apiWhiteList_description": {
|
||||||
|
"message": "Erlaubt ausgewählte Teile der Canvas-API.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"disableNotifications": {
|
"disableNotifications": {
|
||||||
"message": "Benachrichtigungen deaktivieren",
|
"message": "Benachrichtigungen deaktivieren",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -393,6 +393,15 @@
|
|||||||
"message": "Enables the canvas cache. This can prevent detection and increases the performance when small canvas are read several times but decreases it for big canvas.",
|
"message": "Enables the canvas cache. This can prevent detection and increases the performance when small canvas are read several times but decreases it for big canvas.",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"apiWhiteList_title": {
|
||||||
|
"message": "API whitelist",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"apiWhiteList_description": {
|
||||||
|
"message": "Allows certain parts of the canvas API.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"disableNotifications": {
|
"disableNotifications": {
|
||||||
"message": "disable notifications",
|
"message": "disable notifications",
|
||||||
|
@ -227,7 +227,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcStatus.active){
|
if (funcStatus.active && !prefs("apiWhiteList")[name]){
|
||||||
if (funcStatus.mode === "ask"){
|
if (funcStatus.mode === "ask"){
|
||||||
funcStatus.mode = ask({
|
funcStatus.mode = ask({
|
||||||
window: window,
|
window: window,
|
||||||
|
@ -59,6 +59,18 @@
|
|||||||
defaultValue: "nonPersistent",
|
defaultValue: "nonPersistent",
|
||||||
options: ["white", "nonPersistent", "constant", "persistent"]
|
options: ["white", "nonPersistent", "constant", "persistent"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "apiWhiteList",
|
||||||
|
defaultValue: {},
|
||||||
|
keys: [
|
||||||
|
"getContext",
|
||||||
|
"toDataURL", "toBlob", "mozGetAsFile", "getImageData",
|
||||||
|
"isPointInPath", "isPointInStroke",
|
||||||
|
"fillText", "strokeText",
|
||||||
|
"readPixels"
|
||||||
|
],
|
||||||
|
defaultKeyValue: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "useCanvasCache",
|
name: "useCanvasCache",
|
||||||
defaultValue: true
|
defaultValue: true
|
||||||
|
@ -127,6 +127,47 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (setting.keys){
|
||||||
|
input = document.createElement("table");
|
||||||
|
setting.keys.forEach(function(key){
|
||||||
|
let row = document.createElement("tr");
|
||||||
|
|
||||||
|
let nameCell = document.createElement("td");
|
||||||
|
nameCell.textContent = key;
|
||||||
|
row.appendChild(nameCell);
|
||||||
|
|
||||||
|
let keyType = inputTypes[typeof setting.defaultKeyValue];
|
||||||
|
let keyInput = document.createElement("input");
|
||||||
|
keyType.input(keyInput, setting.defaultKeyValue);
|
||||||
|
|
||||||
|
let inputCell = document.createElement("td");
|
||||||
|
inputCell.appendChild(keyInput);
|
||||||
|
row.appendChild(inputCell);
|
||||||
|
|
||||||
|
setting.on(function(){
|
||||||
|
var container = setting.get(url);
|
||||||
|
keyType.updateCallback(
|
||||||
|
keyInput,
|
||||||
|
container && container.hasOwnProperty(key)?
|
||||||
|
container[key]:
|
||||||
|
setting.defaultKeyValue,
|
||||||
|
url
|
||||||
|
);
|
||||||
|
});
|
||||||
|
keyInput.addEventListener("change", function(){
|
||||||
|
var value = keyType.getValue(keyInput);
|
||||||
|
var container = setting.get(url);
|
||||||
|
if (!container){
|
||||||
|
container = setting.defaultValue;
|
||||||
|
}
|
||||||
|
container[key] = value;
|
||||||
|
setting.set(container, url);
|
||||||
|
logging.message("changed setting", setting.name, "(", key, "):", value);
|
||||||
|
});
|
||||||
|
input.appendChild(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (setting.urlSpecific && url === ""){
|
if (setting.urlSpecific && url === ""){
|
||||||
let container = document.createElement("div");
|
let container = document.createElement("div");
|
||||||
container.className = "urlValues collapsed";
|
container.className = "urlValues collapsed";
|
||||||
|
@ -182,6 +182,20 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "apiWhiteList",
|
||||||
|
"displayDependencies": [
|
||||||
|
{
|
||||||
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
|
"displayAdvancedSettings": [true]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"blockMode": ["askReadout", "ask"],
|
||||||
|
"askDenyMode": ["fake"],
|
||||||
|
"displayAdvancedSettings": [true]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"notifications",
|
"notifications",
|
||||||
{
|
{
|
||||||
"name": "showNotifications",
|
"name": "showNotifications",
|
||||||
|
@ -3,7 +3,7 @@ Version 0.4.6:
|
|||||||
-
|
-
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
-
|
- Added setting to whitelist parts of the canvas API
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
-
|
-
|
||||||
|
Loading…
x
Reference in New Issue
Block a user