mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
aa8b202545
commit
6477572f79
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -22,6 +22,7 @@
|
|||||||
"prefs",
|
"prefs",
|
||||||
"spodermenpls",
|
"spodermenpls",
|
||||||
"webgl",
|
"webgl",
|
||||||
|
"whitelisted",
|
||||||
"yfdyh"
|
"yfdyh"
|
||||||
],
|
],
|
||||||
"cSpell.language": "en,de,en-GB"
|
"cSpell.language": "en,de,en-GB"
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"browserAction_title_notified": {
|
"browserAction_title_notified": {
|
||||||
"message": "CanvasBlocker \n\nSchutz erfolgreich für:",
|
"message": " \n\nSchutz erfolgreich für:",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"browserAction_title_whitelisted": {
|
||||||
|
"message": " (APIs erlaubt für {url})",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"browserAction_title_protectedAPIs": {
|
"browserAction_title_protectedAPIs": {
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"browserAction_title_notified": {
|
"browserAction_title_notified": {
|
||||||
"message": "CanvasBlocker \n\nprotection successful for:",
|
"message": " \n\nprotection successful for:",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"browserAction_title_whitelisted": {
|
||||||
|
"message": " (APIs whitelisted for {url})",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"browserAction_title_protectedAPIs": {
|
"browserAction_title_protectedAPIs": {
|
||||||
|
128
icons/browserAction-whitelisted.svg
Normal file
128
icons/browserAction-whitelisted.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 15 KiB |
@ -65,7 +65,7 @@
|
|||||||
notification.show(port.sender.tab.id, url, data["canvasBlocker-notify"].api);
|
notification.show(port.sender.tab.id, url, data["canvasBlocker-notify"].api);
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty("canvasBlocker-clear-page-action")){
|
if (data.hasOwnProperty("canvasBlocker-clear-page-action")){
|
||||||
notification.hide(port.sender.tab.id);
|
notification.hide(port.sender.tab.id, url);
|
||||||
}
|
}
|
||||||
verbose("got data", data, "from port", port);
|
verbose("got data", data, "from port", port);
|
||||||
});
|
});
|
||||||
|
@ -17,6 +17,27 @@
|
|||||||
const lists = require("./lists");
|
const lists = require("./lists");
|
||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
|
|
||||||
|
function isWhitelisted(url){
|
||||||
|
if (!(url instanceof URL)){
|
||||||
|
url = new URL(url);
|
||||||
|
}
|
||||||
|
return lists.get("white").match(url) ||
|
||||||
|
lists.get("sessionWhite").match(url) ||
|
||||||
|
settings.get("blockMode", url).startsWith("allow");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBrowserActionIconName(url, notified){
|
||||||
|
if (isWhitelisted(url)){
|
||||||
|
return "whitelisted";
|
||||||
|
}
|
||||||
|
else if (notified) {
|
||||||
|
return settings.highlightBrowserAction;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const paths = {
|
const paths = {
|
||||||
pageAction: {
|
pageAction: {
|
||||||
none: "icons/pageAction-printed.svg",
|
none: "icons/pageAction-printed.svg",
|
||||||
@ -26,7 +47,8 @@
|
|||||||
browserAction: {
|
browserAction: {
|
||||||
none: "icons/browserAction-notPrinted.svg",
|
none: "icons/browserAction-notPrinted.svg",
|
||||||
color: "icons/browserAction-printed.svg",
|
color: "icons/browserAction-printed.svg",
|
||||||
blink: "icons/browserAction-printedBlink.svg"
|
blink: "icons/browserAction-printedBlink.svg",
|
||||||
|
whitelisted: "icons/browserAction-whitelisted.svg"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +74,7 @@
|
|||||||
}
|
}
|
||||||
browser.browserAction.setIcon({
|
browser.browserAction.setIcon({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
path: paths.browserAction[settings.highlightBrowserAction]
|
path: paths.browserAction[getBrowserActionIconName(url, true)]
|
||||||
});
|
});
|
||||||
|
|
||||||
let apis = apiMap.get(tabId);
|
let apis = apiMap.get(tabId);
|
||||||
@ -72,13 +94,20 @@
|
|||||||
apis.forEach(function(api){
|
apis.forEach(function(api){
|
||||||
apiList += browser.i18n.getMessage("browserAction_title_protectedAPIs").replace(/{api}/g, api);
|
apiList += browser.i18n.getMessage("browserAction_title_protectedAPIs").replace(/{api}/g, api);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let browserActionTitle = browser.i18n.getMessage("browserAction_title_default");
|
||||||
|
if (isWhitelisted(url)){
|
||||||
|
browserActionTitle += browser.i18n.getMessage("browserAction_title_whitelisted").replace(/{url}/g, url);
|
||||||
|
}
|
||||||
|
browserActionTitle += browser.i18n.getMessage("browserAction_title_notified");
|
||||||
|
browserActionTitle += apiList;
|
||||||
browser.browserAction.setTitle({
|
browser.browserAction.setTitle({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
title: browser.i18n.getMessage("browserAction_title_notified") + apiList
|
title: browserActionTitle
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.hide = function hideNotification(tabId){
|
scope.hide = function hideNotification(tabId, url){
|
||||||
logging.notice("Hide page action for tab", tabId);
|
logging.notice("Hide page action for tab", tabId);
|
||||||
apiMap.delete(tabId);
|
apiMap.delete(tabId);
|
||||||
browser.pageAction.hide(tabId);
|
browser.pageAction.hide(tabId);
|
||||||
@ -88,15 +117,19 @@
|
|||||||
});
|
});
|
||||||
browser.browserAction.setIcon({
|
browser.browserAction.setIcon({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
path: paths.browserAction.none
|
path: paths.browserAction[getBrowserActionIconName(url, false)]
|
||||||
});
|
});
|
||||||
browser.browserAction.setBadgeText({
|
browser.browserAction.setBadgeText({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
text: ""
|
text: ""
|
||||||
});
|
});
|
||||||
|
let browserActionTitle = browser.i18n.getMessage("browserAction_title_default");
|
||||||
|
if (isWhitelisted(url)){
|
||||||
|
browserActionTitle += browser.i18n.getMessage("browserAction_title_whitelisted").replace(/{url}/g, url);
|
||||||
|
}
|
||||||
browser.browserAction.setTitle({
|
browser.browserAction.setTitle({
|
||||||
tabId: tabId,
|
tabId: tabId,
|
||||||
title: browser.i18n.getMessage("browserAction_title_default")
|
title: browserActionTitle
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ Version 0.5.4:
|
|||||||
|
|
||||||
new features:
|
new features:
|
||||||
- added save/load directly to/from file option
|
- added save/load directly to/from file option
|
||||||
|
- browser action icon gets grayed out if the page is whitelisted
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- window and audio API were always blocked when using any of the "block ..." modes
|
- window and audio API were always blocked when using any of the "block ..." modes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user