1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-01-05 11:32:20 +01:00

Added ignore list.

This commit is contained in:
kkapsner 2015-04-23 10:04:20 +02:00
parent af47ee8d87
commit 475c28483f
4 changed files with 90 additions and 52 deletions

View File

@ -41,6 +41,15 @@
updateBlackList(); updateBlackList();
}); });
var ignoreList;
function updateIgnoreList(){
ignoreList = getDomainRegExpList(prefs.ignoreList);
}
updateIgnoreList();
preferences.on("ignoreList", function(){
updateIgnoreList();
});
// preferences for injected file // preferences for injected file
var preferencesForInjected = ["showCallingFile", "showCompleteCallingStack"]; var preferencesForInjected = ["showCallingFile", "showCompleteCallingStack"];
preferencesForInjected.forEach(function(name){ preferencesForInjected.forEach(function(name){
@ -130,58 +139,69 @@
case "fake": case "fake":
var contentURL = new URL(worker.contentURL); var contentURL = new URL(worker.contentURL);
var url = contentURL.href; if (!ignoreList.match(contentURL)){
var domain = contentURL.hostname; var url = contentURL.href;
var message = _("fakedReadout").replace(/\{url\}/g, url); var domain = contentURL.hostname;
var message = _("fakedReadout").replace(/\{url\}/g, url);
var tab = tabUtils.getTabForId(worker.tab.id); var tab = tabUtils.getTabForId(worker.tab.id);
var tabBrowser = tabUtils.getTabBrowserForTab(tab); var tabBrowser = tabUtils.getTabBrowserForTab(tab);
var browser = tabUtils.getBrowserForTab(tab); var browser = tabUtils.getBrowserForTab(tab);
var notifyBox = tabBrowser.getNotificationBox(browser); var notifyBox = tabBrowser.getNotificationBox(browser);
var notification = notifyBox.getNotificationWithValue("fake-readout"); var notification = notifyBox.getNotificationWithValue("fake-readout");
if (notification){ if (notification){
notification.label = message; notification.label = message;
}
else {
var buttons = [
{
label: _("displayCallingStack"),
accessKey: "",
callback: function(){
browser.contentWindow.alert(callingStackMsg);
}
},
{
label: _("ignorelistDomain"),
accessKey: "",
callback: function(){
prefs.ignoreList += "," + domain;
prefService.set("extensions.CanvasBlocker@kkapsner.de.ignoreList", prefs.ignoreList);
updateIgnoreList();
}
},
{
label: _("whitelistURL"),
accessKey: "",
callback: function(){
prefs.whiteList += "," + url;
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
updateWhiteList();
workers.forEach(checkWorker);
}
},
{
label: _("whitelistDomain"),
accessKey: "",
callback: function(){
prefs.whiteList += "," + domain;
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
updateWhiteList();
workers.forEach(checkWorker);
}
}
];
var priority = notifyBox.PRIORITY_WARNING_MEDIUM;
notifyBox.appendNotification(
message,
"fake-readout",
"chrome://browser/skin/Info.png",
priority,
buttons
);
} }
else {
var buttons = [
{
label: _("displayCallingStack"),
accessKey: "",
callback: function(){
browser.contentWindow.alert(callingStackMsg);
}
},
{
label: _("whitelistURL"),
accessKey: "",
callback: function(){
prefs.whiteList += "," + url;
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
updateWhiteList();
workers.forEach(checkWorker);
}
},
{
label: _("whitelistDomain"),
accessKey: "",
callback: function(){
prefs.whiteList += "," + domain;
prefService.set("extensions.CanvasBlocker@kkapsner.de.whiteList", prefs.whiteList);
updateWhiteList();
workers.forEach(checkWorker);
}
}
];
var priority = notifyBox.PRIORITY_WARNING_MEDIUM;
notifyBox.appendNotification(
message,
"fake-readout",
"chrome://browser/skin/Info.png",
priority,
buttons
);
} }
break; break;
} }

View File

@ -4,6 +4,9 @@ whiteList_description= Domänen oder URLs, die die <canvas>-API verwenden dürfe
blackList_title= Blacklist blackList_title= Blacklist
blackList_description= Domänen oder URLs, die die <canvas>-API niemals verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt weren. blackList_description= Domänen oder URLs, die die <canvas>-API niemals verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt weren.
ignoreList_title= Ignorierliste
ignoreList_description= Domänen oder URLs, bei denen keine Benachrichtgung angezeigt werden. Mehrere Einträge müssen durch ein Komma getrennt weren.
blockMode_title= Blockiermodus blockMode_title= Blockiermodus
blockMode_description= blockMode_description=
@ -43,3 +46,6 @@ settings = Einstellungen
displayCallingStack = Aufrufestack anzeigen displayCallingStack = Aufrufestack anzeigen
whitelistURL = erlaube URL whitelistURL = erlaube URL
whitelistDomain = erlaube Domain whitelistDomain = erlaube Domain
ignorelistURL = ignoriere URL
ignorelistDomain = ignoriere Domain

View File

@ -4,6 +4,9 @@ whiteList_description= Domains or URLs where the <canvas>-API should not be bloc
blackList_title= Black list blackList_title= Black list
blackList_description= Domains or URLs where the <canvas>-API should always be blocked. To add multiple entries seperate them by comma. blackList_description= Domains or URLs where the <canvas>-API should always be blocked. To add multiple entries seperate them by comma.
ignoreList_title= Ignore list
ignoreList_description= Domains or URLs where no notifications will be shown. To add multiple entries seperate them by comma.
blockMode_title= Block mode blockMode_title= Block mode
blockMode_description= blockMode_description=
@ -44,3 +47,6 @@ displayCallingStack = display calling stack
whitelist = whitelist whitelist = whitelist
whitelistURL = whitelist URL whitelistURL = whitelist URL
whitelistDomain = whitelist domain whitelistDomain = whitelist domain
whitelistURL = ignore URL
whitelistDomain = ignore domain

View File

@ -16,6 +16,12 @@
"type": "string", "type": "string",
"value": "" "value": ""
}, },
{
"name": "ignoreList",
"title": "Ignore list",
"type": "string",
"value": ""
},
{ {
"name": "blockMode", "name": "blockMode",
"title": "block mode", "title": "block mode",