From da14aaff5152c33bed4305ab9a1e96735a5038df Mon Sep 17 00:00:00 2001 From: kkapsner Date: Fri, 24 Aug 2018 16:47:27 +0200 Subject: [PATCH] Added option to ignore APIs As mentioned in #233 --- _locales/de/messages.json | 10 ++++++++++ _locales/en/messages.json | 9 +++++++++ lib/notification.js | 3 +++ lib/settingDefinitions.js | 9 +++++++++ options/settingsDisplay.js | 17 +++++++++++++++++ pageAction/pageAction.js | 3 +++ releaseNotes.txt | 1 + 7 files changed, 52 insertions(+) diff --git a/_locales/de/messages.json b/_locales/de/messages.json index e54d3c5..b027b8a 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -513,6 +513,16 @@ "message": "Ignorierliste", "description": "" }, + + "ignoredAPIs_title": { + "message": "Ignorierte APIs", + "description": "" + }, + "ignoredAPIs_description": { + "message": "Für die ausgewählten APIs werden keinerlei Benachrichtigungen angezeigt.", + "description": "" + }, + "ignorelistDomain": { "message": "verschweige Domain", "description": "" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index aceece8..e44d20d 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -513,6 +513,15 @@ "message": "Ignore list", "description": "" }, + + "ignoredAPIs_title": { + "message": "Ignored APIs", + "description": "" + }, + "ignoredAPIs_description": { + "message": "No notifications will be displayed for the selected APIs.", + "description": "" + }, "ignorelistDomain": { "message": "silence domain", "description": "" diff --git a/lib/notification.js b/lib/notification.js index 0be74ae..0878cab 100644 --- a/lib/notification.js +++ b/lib/notification.js @@ -36,6 +36,9 @@ const apiMap = new Map(); scope.show = function showNotification(tabId, url, api){ + if (settings.ignoredAPIs[api]){ + return; + } logging.notice("Show notification for tab", tabId); if ( settings.get("showNotifications", url) && diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js index 30a0353..b59ca2b 100644 --- a/lib/settingDefinitions.js +++ b/lib/settingDefinitions.js @@ -182,6 +182,15 @@ name: "ignoreList", defaultValue: "" }, + { + name: "ignoredAPIs", + defaultValue: {}, + keys: [ + "canvas", + "audio", + ], + defaultKeyValue: false + }, { name: "showCallingFile", defaultValue: false diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 29403c7..9572f4b 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -235,6 +235,23 @@ } ] }, + { + "name": "ignoredAPIs", + "displayDependencies": [ + { + "showNotifications": [true], + "displayAdvancedSettings": [true] + }, + { + "displayBadge": [true], + "displayAdvancedSettings": [true] + }, + { + "highlightBrowserAction": ["color", "blink"], + "displayAdvancedSettings": [true] + } + ] + }, { "name": "showCallingFile", "displayDependencies": { diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index 32956a7..4db6562 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -195,6 +195,9 @@ else { for (var delta = 0; delta < 20 && i + delta < length; delta += 1){ let notification = notifications[i + delta]; + if (settings.ignoredAPIs[notification.api]){ + continue; + } verbose(notification); notification.url = new URL(notification.url); domainNotification( diff --git a/releaseNotes.txt b/releaseNotes.txt index 0ee0e89..f4c693d 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -10,6 +10,7 @@ Version 0.5.3: - added option to control browser action icon on notifications - added theme for browser action popup - added badge + - added option to ignore APIs fixes: - CSP did not work properly for worker-src