mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-05 03:21:52 +01:00
Changed settings
This commit is contained in:
parent
430a9226dc
commit
40d059311a
@ -1,8 +1,11 @@
|
|||||||
|
(function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var getContext = unsafeWindow.HTMLCanvasElement.prototype.getContext;
|
var getContext = unsafeWindow.HTMLCanvasElement.prototype.getContext;
|
||||||
var askFunctionName = Math.random().toString(16);
|
var askFunctionName = Math.random().toString(16);
|
||||||
|
|
||||||
function checkPDF(blocking){
|
function checkPDF(blocking){
|
||||||
if (unsafeWindow.document.contentType.match(/\/pdf$/i)){
|
if (document.contentType.match(/\/pdf$/i)){
|
||||||
self.port.emit("isPDF", blocking);
|
self.port.emit("isPDF", blocking);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -17,9 +20,8 @@ function block(force){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ask(force){
|
function askVisible(force){
|
||||||
if (force || !checkPDF("ask")){
|
if (force || !checkPDF("askVisible")){
|
||||||
// console.log("ask");
|
|
||||||
|
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
unsafeWindow.HTMLCanvasElement.prototype,
|
unsafeWindow.HTMLCanvasElement.prototype,
|
||||||
@ -58,7 +60,6 @@ function ask(force){
|
|||||||
}
|
}
|
||||||
function askInvisible(force){
|
function askInvisible(force){
|
||||||
if (force || !checkPDF("askInvisible")){
|
if (force || !checkPDF("askInvisible")){
|
||||||
// console.log("ask");
|
|
||||||
|
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
unsafeWindow.HTMLCanvasElement.prototype,
|
unsafeWindow.HTMLCanvasElement.prototype,
|
||||||
@ -108,7 +109,8 @@ self.port.on("setTranslation", function(name, translation){
|
|||||||
|
|
||||||
block();
|
block();
|
||||||
self.port.on("block", block);
|
self.port.on("block", block);
|
||||||
self.port.on("ask", ask);
|
self.port.on("askVisible", askVisible);
|
||||||
self.port.on("askInvisible", askInvisible);
|
self.port.on("askInvisible", askInvisible);
|
||||||
self.port.on("unblock", unblock);
|
self.port.on("unblock", unblock);
|
||||||
self.port.on("detach", unblock);
|
self.port.on("detach", unblock);
|
||||||
|
}());
|
111
lib/main.js
111
lib/main.js
@ -1,5 +1,8 @@
|
|||||||
|
(function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
function getDomainRegExpList(domainList){
|
function getDomainRegExpList(domainList){
|
||||||
return domainList
|
var list = domainList
|
||||||
.split(",")
|
.split(",")
|
||||||
.map(function(entry){
|
.map(function(entry){
|
||||||
return entry.replace(/^\s+|\s+$/g, "");
|
return entry.replace(/^\s+|\s+$/g, "");
|
||||||
@ -27,6 +30,14 @@ function getDomainRegExpList(domainList){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
list.match = function(url){
|
||||||
|
return this.some(function(entry){
|
||||||
|
return entry.match(url);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = require("sdk/self");
|
var self = require("sdk/self");
|
||||||
@ -58,6 +69,12 @@ preferences.on("blackList", function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
preferences.on("blockMode", function(){
|
||||||
|
workers.forEach(checkWorker);
|
||||||
|
});preferences.on("allowPDFCanvas", function(){
|
||||||
|
workers.forEach(checkWorker);
|
||||||
|
});
|
||||||
|
|
||||||
var workers = [];
|
var workers = [];
|
||||||
function detachWorker(worker, workerArray) {
|
function detachWorker(worker, workerArray) {
|
||||||
var index = workerArray.indexOf(worker);
|
var index = workerArray.indexOf(worker);
|
||||||
@ -66,67 +83,56 @@ function detachWorker(worker, workerArray) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function checkWorker(worker){
|
function checkWorker(worker){
|
||||||
if (prefs.blockAll){
|
|
||||||
worker.port.emit("block");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var url = new URL(worker.url);
|
var url = new URL(worker.url);
|
||||||
var inBlackList = blackList.some(function(entry){
|
switch (prefs.blockMode){
|
||||||
return entry.match(url);
|
case "blockEverything":
|
||||||
});
|
|
||||||
if (inBlackList){
|
|
||||||
worker.port.emit("block");
|
worker.port.emit("block");
|
||||||
}
|
break;
|
||||||
else {
|
case "allowOnlyWhiteList":
|
||||||
var inWhiteList = whiteList.some(function(entry){
|
if (whiteList.match(url)){
|
||||||
return entry.match(url);
|
|
||||||
});
|
|
||||||
if (inWhiteList){
|
|
||||||
worker.port.emit("unblock");
|
worker.port.emit("unblock");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (prefs.askPermission){
|
|
||||||
if (prefs.askInvisiblePermission){
|
|
||||||
worker.port.emit("askInvisible");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
worker.port.emit("ask");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
worker.port.emit("block");
|
worker.port.emit("block");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "askVisible":
|
||||||
|
if (whiteList.match(url)){
|
||||||
|
worker.port.emit("unblock");
|
||||||
}
|
}
|
||||||
}
|
else if (blackList.match(url)){
|
||||||
}
|
worker.port.emit("block");
|
||||||
}
|
|
||||||
|
|
||||||
preferences.on("blockAll", function(){
|
|
||||||
if (prefs.blockAll){
|
|
||||||
prefs.askPermission = false;
|
|
||||||
prefs.askInsiviblePermission = false;
|
|
||||||
}
|
|
||||||
workers.forEach(checkWorker);
|
|
||||||
});
|
|
||||||
preferences.on("askPermission", function(){
|
|
||||||
if (prefs.askPermission){
|
|
||||||
prefs.blockAll = false;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
prefs.askInvisiblePermission = false;
|
worker.port.emit("askVisible");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "askInvisible":
|
||||||
|
if (whiteList.match(url)){
|
||||||
|
worker.port.emit("unblock");
|
||||||
|
}
|
||||||
|
else if (blackList.match(url)){
|
||||||
|
worker.port.emit("block");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
worker.port.emit("askInvisible");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "blockOnlyBlackList":
|
||||||
|
if (blackList.match(url)){
|
||||||
|
worker.port.emit("block");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
worker.port.emit("unblock");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "allowEverything":
|
||||||
|
worker.port.emit("unblock");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("Unknown blocking mode.");
|
||||||
}
|
}
|
||||||
workers.forEach(checkWorker);
|
|
||||||
});
|
|
||||||
preferences.on("askInvisiblePermission", function(){
|
|
||||||
if (prefs.askInvisiblePermission){
|
|
||||||
prefs.askPermission = true;
|
|
||||||
prefs.blockAll = false;
|
|
||||||
}
|
}
|
||||||
workers.forEach(checkWorker);
|
|
||||||
});
|
|
||||||
preferences.on("allowPDFCanvas", function(){
|
|
||||||
workers.forEach(checkWorker);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
pageMod.PageMod({
|
pageMod.PageMod({
|
||||||
@ -139,9 +145,6 @@ pageMod.PageMod({
|
|||||||
worker.on("detach", function(){
|
worker.on("detach", function(){
|
||||||
detachWorker(this, workers);
|
detachWorker(this, workers);
|
||||||
});
|
});
|
||||||
worker.port.on("getTranslation", function(name){
|
|
||||||
worker.port.emit("setTranslation", name, _.apply(null, arguments));
|
|
||||||
});
|
|
||||||
worker.port.on("isPDF", function(blocking){
|
worker.port.on("isPDF", function(blocking){
|
||||||
if (prefs.allowPDFCanvas){
|
if (prefs.allowPDFCanvas){
|
||||||
worker.port.emit("unblock");
|
worker.port.emit("unblock");
|
||||||
@ -155,3 +158,5 @@ pageMod.PageMod({
|
|||||||
checkWorker(worker);
|
checkWorker(worker);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}());
|
@ -1,17 +1,18 @@
|
|||||||
whilteList_title= Whitelist
|
whilteList_title= Whitelist
|
||||||
whiteList_description= Domänen oder URLs, die die <canvas>-API verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt weren.
|
whiteList_description= Domänen oder URLs, die die <canvas>-API verwenden dürfen. Mehrere Einträge müssen durch ein Komma getrennt weren.
|
||||||
|
|
||||||
blockAll_title= Alles blockieren
|
|
||||||
blockAll_description= Ob immer alles blockiert werden soll (ignoriert die Whitelist).
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
askPermission_title= Um Erlaubnis fragen
|
blockMode_title= Blockiermodus
|
||||||
askPermission_description= Ob man gefragt werden soll, ob ein sichtbares <canvas>-Element blockiert werden soll oder nicht, wenn die Domäne oder URL weder auf der Whitelist noch auf der Blacklist steht.
|
blockMode_description=
|
||||||
|
|
||||||
askInvisiblePermission_title= Bei verstecken Elementen um Erlaubnis fragen
|
blockMode_options.block everything= alles blockieren
|
||||||
askInvisiblePermission_description= Ob man gefragt werden soll, ob ein verstecktes <canvas>-Element blockiert werden soll oder nicht, wenn die Domäne oder URL weder auf der Whitelist noch auf der Blacklist steht.
|
blockMode_options.allow only white list= nur Einträge der Whitelist erlauben
|
||||||
|
blockMode_options.ask for permission for visible <canvas>= bei sichtbaren <canvas> um Erlaubnis fragen
|
||||||
|
blockMode_options.ask for permision for invisible <canvas>= bei unsichtbaren <canvas> um Erlaubnis fragen
|
||||||
|
blockMode_options.block only black list= nur Einträge der Blacklist blockieren
|
||||||
|
blockMode_options.allow everything= alles erlauben
|
||||||
|
|
||||||
allowPDFCanvas_title= <canvas> in PDFs erlauben
|
allowPDFCanvas_title= <canvas> in PDFs erlauben
|
||||||
allowPDFCanvas_description= Die native pdf.js verwendet <canvas> um den Inhalt von PDFs anzuzeigen. Wenn dies nicht markiert ist, werden viele Nachfragedialoge erscheinen oder die PDF Ansicht nicht funktionieren.
|
allowPDFCanvas_description= Die native pdf.js verwendet <canvas> um den Inhalt von PDFs anzuzeigen. Wenn dies nicht markiert ist, werden viele Nachfragedialoge erscheinen oder die PDF Ansicht nicht funktionieren.
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
whilteList_title= White list
|
whilteList_title= White list
|
||||||
whiteList_description= Domains or URLs where the <canvas>-API should not be blocked. To add multiple entries seperate them by comma.
|
whiteList_description= Domains or URLs where the <canvas>-API should not be blocked. To add multiple entries seperate them by comma.
|
||||||
|
|
||||||
blockAll_title= Block everything
|
|
||||||
blockAll_description= If you want to block everything (ignore the white list).
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
askPermission_title= Ask for permission
|
blockMode_title= Block mode
|
||||||
askPermission_description= If you want to be asked if you want to block a visible canvas element if the domain or URL is neither in the white or black list.
|
blockMode_description=
|
||||||
|
|
||||||
askInvisiblePermission_title= Ask for permission for invisible elements
|
blockMode_options.block everything= block everything
|
||||||
askInvisiblePermission_description= If you want to be asked if you want to block an invisible canvas element if the domain or URL is neither in the white or black list.
|
blockMode_options.allow only white list= allow only white list
|
||||||
|
blockMode_options.ask for permission for visible <canvas>= ask for permission for visible <canvas>
|
||||||
|
blockMode_options.ask for permision for invisible <canvas>= ask for permision for invisible <canvas>
|
||||||
|
blockMode_options.block only black list= block only black list
|
||||||
|
blockMode_options.allow everything= allow everything
|
||||||
|
|
||||||
allowPDFCanvas_title= Allow canvas in PDFs
|
allowPDFCanvas_title= Allow canvas in PDFs
|
||||||
allowPDFCanvas_description= The native pdf.js uses <canvas> to display the PDF content. If this is unchecked there will lots of annoying ask dialogs or the PDF display will not work.
|
allowPDFCanvas_description= The native pdf.js uses <canvas> to display the PDF content. If this is unchecked there will lots of annoying ask dialogs or the PDF display will not work.
|
||||||
|
42
package.json
42
package.json
@ -10,12 +10,6 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"value": "kkapsner.de,^https?://(\\\\w+\\\\.)*google.[a-z]+/maps"
|
"value": "kkapsner.de,^https?://(\\\\w+\\\\.)*google.[a-z]+/maps"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "blockAll",
|
|
||||||
"title": "Block everything",
|
|
||||||
"type": "bool",
|
|
||||||
"value": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "blackList",
|
"name": "blackList",
|
||||||
"title": "Black list",
|
"title": "Black list",
|
||||||
@ -23,16 +17,36 @@
|
|||||||
"value": ""
|
"value": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "askPermission",
|
"name": "blockMode",
|
||||||
"title": "Ask for permission",
|
"title": "block mode",
|
||||||
"type": "bool",
|
"type": "menulist",
|
||||||
"value": true
|
"value": "askVisible",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"value": "blockEverything",
|
||||||
|
"label": "block everything"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "askInvisiblePermission",
|
"value": "allowOnlyWhiteList",
|
||||||
"title": "Ask for permission for invisible elements",
|
"label": "allow only white list"
|
||||||
"type": "bool",
|
},
|
||||||
"value": false
|
{
|
||||||
|
"value": "askVisible",
|
||||||
|
"label": "ask for permission for visible <canvas>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "askInvisible",
|
||||||
|
"label": "ask for permision for invisible <canvas>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "blockOnlyBlackList",
|
||||||
|
"label": "block only black list"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "allowEverything",
|
||||||
|
"label": "allow everything"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "allowPDFCanvas",
|
"name": "allowPDFCanvas",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user