1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added whitelist scope question

This commit is contained in:
kkapsner 2019-04-30 23:42:21 +02:00
parent cd8c7bd71c
commit 51445b36e0
5 changed files with 89 additions and 10 deletions

View file

@ -120,15 +120,60 @@
{
name: "whitelist",
isIcon: true,
callback: function({domain, urls}){
callback: function({domain, urls, api}){
const whitelistingSettings = {
all: {name: "blockMode", value: "allow"},
canvas: {name: "protectedCanvasPart", value: "nothing"},
audio: {name: "protectAudio", value: false},
domRect: {name: "protectDOMRect", value: false},
history: {name: "historyLengthThreshold", value: 10000},
navigator: {name: "protectNavigator", value: false},
windows: {name: "protectWindow", value: false}
};
domainOrUrlPicker(
domain,
urls,
extension.getTranslation("selectWhitelist"),
extension.getTranslation("inputWhitelistURL")
).then(function(choice){
const allAPIs = {
choice,
setting: "blockMode",
settingValue: "allow"
};
const onlyAPI = {
choice,
setting: whitelistingSettings[api],
settingValue: false
};
if (
api &&
whitelistingSettings[api]
){
return modalChoice(
extension.getTranslation("selectWhitelistScope"),
[
{
text: extension.getTranslation("whitelistOnlyAPI")
.replace(/\{api\}/g, api),
value: api
},
{
text: extension.getTranslation("whitelistAllAPIs"),
value: "all"
}
]
).then(function(selection){
return {choice, setting: whitelistingSettings[selection]};
});
}
else {
return {choice, setting: whitelistingSettings.all};
}
}).then(function({choice, setting}){
if (choice){
settings.set("blockMode", "allow", choice).then(function(){
settings.set(setting.name, setting.value, choice).then(function(){
window.close();
});
}
@ -184,14 +229,15 @@
});
var tab = tabs[0];
browser.runtime.onMessage.addListener(function(data){
extension.message.on(function(data){
if (data["canvasBlocker-notificationCounter"]){
const url = new URL(data.url);
Object.keys(data["canvasBlocker-notificationCounter"]).forEach(function(key){
const notification = domainNotification(
url,
key,
data["canvasBlocker-notificationCounter"][key]
data["canvasBlocker-notificationCounter"][key].count,
data["canvasBlocker-notificationCounter"][key].api
);
});
}
@ -218,7 +264,9 @@
notification.url = new URL(notification.url);
domainNotification(
notification.url,
notification.messageId
notification.messageId,
0,
notification.api
).addNotification(new Notification(notification));
}
i += delta;