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": ""
|
||||
},
|
||||
|
||||
"apiWhiteList_title": {
|
||||
"message": "API Whitelist",
|
||||
"description": ""
|
||||
},
|
||||
"apiWhiteList_description": {
|
||||
"message": "Erlaubt ausgewählte Teile der Canvas-API.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"disableNotifications": {
|
||||
"message": "Benachrichtigungen deaktivieren",
|
||||
"description": ""
|
||||
|
@ -394,6 +394,15 @@
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"apiWhiteList_title": {
|
||||
"message": "API whitelist",
|
||||
"description": ""
|
||||
},
|
||||
"apiWhiteList_description": {
|
||||
"message": "Allows certain parts of the canvas API.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"disableNotifications": {
|
||||
"message": "disable notifications",
|
||||
"description": ""
|
||||
|
@ -227,7 +227,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (funcStatus.active){
|
||||
if (funcStatus.active && !prefs("apiWhiteList")[name]){
|
||||
if (funcStatus.mode === "ask"){
|
||||
funcStatus.mode = ask({
|
||||
window: window,
|
||||
|
@ -59,6 +59,18 @@
|
||||
defaultValue: "nonPersistent",
|
||||
options: ["white", "nonPersistent", "constant", "persistent"]
|
||||
},
|
||||
{
|
||||
name: "apiWhiteList",
|
||||
defaultValue: {},
|
||||
keys: [
|
||||
"getContext",
|
||||
"toDataURL", "toBlob", "mozGetAsFile", "getImageData",
|
||||
"isPointInPath", "isPointInStroke",
|
||||
"fillText", "strokeText",
|
||||
"readPixels"
|
||||
],
|
||||
defaultKeyValue: false
|
||||
},
|
||||
{
|
||||
name: "useCanvasCache",
|
||||
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 === ""){
|
||||
let container = document.createElement("div");
|
||||
container.className = "urlValues collapsed";
|
||||
|
@ -182,6 +182,20 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "apiWhiteList",
|
||||
"displayDependencies": [
|
||||
{
|
||||
"blockMode": ["fakeReadout", "fakeInput"],
|
||||
"displayAdvancedSettings": [true]
|
||||
},
|
||||
{
|
||||
"blockMode": ["askReadout", "ask"],
|
||||
"askDenyMode": ["fake"],
|
||||
"displayAdvancedSettings": [true]
|
||||
}
|
||||
]
|
||||
},
|
||||
"notifications",
|
||||
{
|
||||
"name": "showNotifications",
|
||||
|
@ -3,7 +3,7 @@ Version 0.4.6:
|
||||
-
|
||||
|
||||
new features:
|
||||
-
|
||||
- Added setting to whitelist parts of the canvas API
|
||||
|
||||
fixes:
|
||||
-
|
||||
|
Loading…
x
Reference in New Issue
Block a user