diff --git a/_locales/de/messages.json b/_locales/de/messages.json
index c533006..da18b33 100644
--- a/_locales/de/messages.json
+++ b/_locales/de/messages.json
@@ -556,6 +556,46 @@
"message": "Benachrichtigungen anzeigen",
"description": ""
},
+ "highlightPageAction_description": {
+ "message": "Page-Action Icon für eine erhöhte Sichtbarkeit hervorheben.",
+ "description": ""
+ },
+ "highlightPageAction_title": {
+ "message": "Page-Action Icon hervorheben",
+ "description": ""
+ },
+ "highlightBrowserAction_description": {
+ "message": "",
+ "description": ""
+ },
+ "highlightPageAction_options.none": {
+ "message": "nicht hervorheben",
+ "description": ""
+ },
+ "highlightPageAction_options.color": {
+ "message": "Farbe",
+ "description": ""
+ },
+ "highlightPageAction_options.blink": {
+ "message": "blinken",
+ "description": ""
+ },
+ "highlightBrowserAction_title": {
+ "message": "Toolbar Icon bei Benachrichtigung ändern",
+ "description": ""
+ },
+ "highlightBrowserAction_options.none": {
+ "message": "nichts ändern",
+ "description": ""
+ },
+ "highlightBrowserAction_options.color": {
+ "message": "Farbe ändern",
+ "description": ""
+ },
+ "highlightBrowserAction_options.blink": {
+ "message": "blinken",
+ "description": ""
+ },
"notificationDisplayTime_description": {
"message": "Anzahl der Sekunden, die die Benachrichtigungen angezeigt werden sollen. (Null eingeben, um die Benachrichtigungen nicht automatisch zu schließen.)",
"description": ""
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 7786382..4b7aa3b 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -556,6 +556,46 @@
"message": "Show notifications",
"description": ""
},
+ "highlightPageAction_description": {
+ "message": "Highlight the page action icon for better visibility.",
+ "description": ""
+ },
+ "highlightPageAction_title": {
+ "message": "Highlight page action icon",
+ "description": ""
+ },
+ "highlightPageAction_options.none": {
+ "message": "no highlight",
+ "description": ""
+ },
+ "highlightPageAction_options.color": {
+ "message": "color",
+ "description": ""
+ },
+ "highlightPageAction_options.blink": {
+ "message": "blink",
+ "description": ""
+ },
+ "highlightBrowserAction_description": {
+ "message": "",
+ "description": ""
+ },
+ "highlightBrowserAction_title": {
+ "message": "Change toolbar icon on notification",
+ "description": ""
+ },
+ "highlightBrowserAction_options.none": {
+ "message": "change nothing",
+ "description": ""
+ },
+ "highlightBrowserAction_options.color": {
+ "message": "change color",
+ "description": ""
+ },
+ "highlightBrowserAction_options.blink": {
+ "message": "blink",
+ "description": ""
+ },
"notificationDisplayTime_description": {
"message": "Number of seconds the notifications are shown. (Enter zero to disable automatic closing.)",
"description": ""
diff --git a/icons/browserAction-printedBlink.svg b/icons/browserAction-printedBlink.svg
new file mode 100644
index 0000000..42ff7a1
--- /dev/null
+++ b/icons/browserAction-printedBlink.svg
@@ -0,0 +1,135 @@
+
+
+
+
diff --git a/icons/pageAction-printedBlink.svg b/icons/pageAction-printedBlink.svg
new file mode 100644
index 0000000..820dcbb
--- /dev/null
+++ b/icons/pageAction-printedBlink.svg
@@ -0,0 +1,116 @@
+
+
+
+
diff --git a/icons/pageAction-printedHighlight.svg b/icons/pageAction-printedHighlight.svg
new file mode 100644
index 0000000..dfaa9b9
--- /dev/null
+++ b/icons/pageAction-printedHighlight.svg
@@ -0,0 +1,116 @@
+
+
+
+
diff --git a/lib/main.js b/lib/main.js
index efb3968..72af238 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -7,9 +7,9 @@
const settings = require("./settings");
const logging = require("./logging");
const {error, warning, message, notice, verbose, } = logging;
- const lists = require("./lists");
logging.setPrefix("main script");
const persistentRndStorage = require("./persistentRndStorage");
+ const notification = require("./notification");
message("start of background script");
message("waiting for settings to be loaded");
@@ -62,30 +62,10 @@
var url = new URL(port.sender.url);
port.onMessage.addListener(function(data){
if (data.hasOwnProperty("canvasBlocker-notify")){
- if (
- settings.get("showNotifications", url) &&
- !lists.get("ignore").match(url)
- ){
- browser.pageAction.show(port.sender.tab.id);
- browser.browserAction.setIcon({
- tabId: port.sender.tab.id,
- path: {
- "19": "icons/browserAction-printed.svg",
- "38": "icons/browserAction-printed.svg"
- }
- });
- }
+ notification.show(port.sender.tab.id, url);
}
if (data.hasOwnProperty("canvasBlocker-clear-page-action")){
- notice("Hide page action for tab", port.sender.tab.id);
- browser.pageAction.hide(port.sender.tab.id);
- browser.browserAction.setIcon({
- tabId: port.sender.tab.id,
- path: {
- "19": "icons/browserAction-notPrinted.svg",
- "38": "icons/browserAction-notPrinted.svg"
- }
- });
+ notification.hide(port.sender.tab.id);
}
verbose("got data", data, "from port", port);
});
@@ -93,17 +73,6 @@
message("register storage change event listener");
- settings.on("showNotifications", function({newValue}){
- if (!newValue){
- message("notifications were disabled -> hide all page actions");
- browser.tabs.query({}).then(function(tabs){
- tabs.forEach(function(tab){
- browser.pageAction.hide(tab.id);
- });
- });
- }
- });
-
if (browser.contentScripts){
let unregister = function(){};
let lastRegistering;
diff --git a/lib/notification.js b/lib/notification.js
new file mode 100644
index 0000000..7cfe2c4
--- /dev/null
+++ b/lib/notification.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+(function(){
+ "use strict";
+
+ var scope;
+ if ((typeof exports) !== "undefined"){
+ scope = exports;
+ }
+ else {
+ scope = {};
+ window.scope.notification = scope;
+ }
+
+ const settings = require("./settings");
+ const lists = require("./lists");
+ const logging = require("./logging");
+
+ const paths = {
+ pageAction: {
+ none: "icons/pageAction-printed.svg",
+ color: "icons/pageAction-printedHighlight.svg",
+ blink: "icons/pageAction-printedBlink.svg"
+ },
+ browserAction: {
+ none: "icons/browserAction-notPrinted.svg",
+ color: "icons/browserAction-printed.svg",
+ blink: "icons/browserAction-printedBlink.svg"
+ }
+ };
+
+ scope.show = function showNotification(tabId, url){
+ logging.notice("Show notification for tab", tabId);
+ if (
+ settings.get("showNotifications", url) &&
+ !lists.get("ignore").match(url)
+ ){
+ browser.pageAction.show(tabId);
+ browser.pageAction.setIcon({
+ tabId: tabId,
+ path: paths.pageAction[settings.highlightPageAction]
+ });
+ }
+ browser.browserAction.setIcon({
+ tabId: tabId,
+ path: paths.browserAction[settings.highlightBrowserAction]
+ });
+ };
+
+ scope.hide = function hideNotification(tabId){
+ logging.notice("Hide page action for tab", tabId);
+ browser.pageAction.hide(tabId);
+ browser.pageAction.setIcon({
+ tabId: tabId,
+ path: paths.pageAction.none
+ });
+ browser.browserAction.setIcon({
+ tabId: tabId,
+ path: paths.browserAction.none
+ });
+ };
+
+ settings.on("showNotifications", function({newValue}){
+ if (!newValue){
+ logging.message("notifications were disabled -> hide all page actions");
+ browser.tabs.query({}).then(function(tabs){
+ tabs.forEach(function(tab){
+ browser.pageAction.hide(tab.id);
+ });
+ });
+ }
+ });
+}());
\ No newline at end of file
diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js
index 9266f11..229f752 100644
--- a/lib/settingDefinitions.js
+++ b/lib/settingDefinitions.js
@@ -154,6 +154,18 @@
defaultValue: true,
urlSpecific: true
},
+ {
+ name: "highlightPageAction",
+ defaultValue: "none",
+ options: ["none", "color", "blink"],
+ urlSpecific: true
+ },
+ {
+ name: "highlightBrowserAction",
+ defaultValue: "color",
+ options: ["none", "color", "blink"],
+ urlSpecific: true
+ },
{
name: "storeImageForInspection",
defaultValue: false
diff --git a/manifest.json b/manifest.json
index 8096310..7452b3e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -16,6 +16,7 @@
"lib/lists.js",
"lib/persistentRndStorage.js",
"lib/dataUrls.js",
+ "lib/notification.js",
"lib/main.js"
]
},
diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js
index 4aed8bd..ec1f1be 100644
--- a/options/settingsDisplay.js
+++ b/options/settingsDisplay.js
@@ -194,6 +194,17 @@
{
"name": "showNotifications"
},
+ {
+ "name": "highlightPageAction",
+ "displayDependencies": [
+ {
+ "showNotifications": [true]
+ }
+ ]
+ },
+ {
+ "name": "highlightBrowserAction"
+ },
{
"name": "storeImageForInspection",
"displayDependencies": [
diff --git a/releaseNotes.txt b/releaseNotes.txt
index 86ff52e..b709268 100644
--- a/releaseNotes.txt
+++ b/releaseNotes.txt
@@ -6,6 +6,8 @@ Version 0.5.3:
- display version in options page
- added link to open options page in separate tab
- added option "Don't show again on update." for options page
+ - added option to highlight page action icon
+ - added option to control browser action icon on notifications
fixes:
- CSP did not work properly for worker-src