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

Added highlighting options for notification icons

Fixes #225.
This commit is contained in:
kkapsner 2018-08-20 21:48:05 +02:00
parent 15feed6445
commit c25e95f845
11 changed files with 550 additions and 34 deletions

View file

@ -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;