mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-08 12:44:48 +01:00
Merge from master
This commit is contained in:
commit
ab8a88ef66
Binary file not shown.
@ -2,6 +2,9 @@
|
|||||||
(function(){
|
(function(){
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var settings = {
|
||||||
|
showCallingFile: false
|
||||||
|
};
|
||||||
var blockMode = {
|
var blockMode = {
|
||||||
getContext: {
|
getContext: {
|
||||||
status: "block",
|
status: "block",
|
||||||
@ -147,12 +150,32 @@
|
|||||||
status = askStatus.answer;
|
status = askStatus.answer;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//console.log("asking");
|
||||||
var appearance = canvasAppearance(this);
|
var appearance = canvasAppearance(this);
|
||||||
// console.log("asking");
|
var msg = _(changedFunction.mode.askText[appearance.text]);
|
||||||
status = window.confirm(_(changedFunction.mode.askText[appearance.text]))? "allow": "block";
|
if (settings.showCallingFile){
|
||||||
|
var callers = new Error().stack.trim().split("\n");
|
||||||
|
//console.log(callers);
|
||||||
|
var findme = callers.shift(); // Remove us from the stack
|
||||||
|
findme = findme.replace(/(:[0-9]+){1,2}$/, ""); // rm line & column
|
||||||
|
// Eliminate squashed stack. stack may contain 2+ stacks, but why...
|
||||||
|
callers = callers.filter(function(caller){
|
||||||
|
return caller.search(findme) === -1;
|
||||||
|
});
|
||||||
|
msg += "\n\n" + _("sourceOutput") + ": ";
|
||||||
|
if (settings.showCompleteCallingStack){
|
||||||
|
msg += callers.reduce(function(stack, c){
|
||||||
|
return stack + "\n\t" + _("stackEntryOutput", parseStackEntry(c));
|
||||||
|
}, "");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
msg += _("stackEntryOutput", parseStackEntry(callers[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status = window.confirm(msg) ? "allow": "block";
|
||||||
askStatus.alreadyAsked = true;
|
askStatus.alreadyAsked = true;
|
||||||
askStatus.answer = status;
|
askStatus.answer = status;
|
||||||
|
//console.log("asking (done)");
|
||||||
appearance.reset();
|
appearance.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,9 +197,26 @@
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Stack parsing
|
||||||
|
function parseStackEntry(entry){
|
||||||
|
var m = /@(.*):(\d*):(\d*)$/.exec(entry) || ["", entry, "--", "--"];
|
||||||
|
return {
|
||||||
|
url: m[1],
|
||||||
|
line: m[2],
|
||||||
|
column: m[3],
|
||||||
|
raw: entry
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
var _ = function(name){
|
var _ = function(name, replace){
|
||||||
return _[name] || name;
|
var str = _[name] || name;
|
||||||
|
if (replace){
|
||||||
|
Object.keys(replace).forEach(function(name){
|
||||||
|
str = str.replace(new RegExp("{" + name + "}", "g"), replace[name]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return str;
|
||||||
};
|
};
|
||||||
self.port.on("setTranslation", function(name, translation){
|
self.port.on("setTranslation", function(name, translation){
|
||||||
_[name] = translation;
|
_[name] = translation;
|
||||||
@ -232,4 +272,9 @@
|
|||||||
blockMode.getContext.status = "allow";
|
blockMode.getContext.status = "allow";
|
||||||
blockMode.readAPI.status = "allow";
|
blockMode.readAPI.status = "allow";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// settings passthrough
|
||||||
|
self.port.on("set", function(name, value){
|
||||||
|
settings[name] = value;
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
16
lib/main.js
16
lib/main.js
@ -73,6 +73,16 @@
|
|||||||
updateBlackList();
|
updateBlackList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// preferences for injected file
|
||||||
|
var preferencesForInjected = ["showCallingFile", "showCompleteCallingStack"];
|
||||||
|
preferencesForInjected.forEach(function(name){
|
||||||
|
preferences.on(name, function(){
|
||||||
|
workers.forEach(function(worker){
|
||||||
|
worker.port.emit("set", name, prefs[name]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function checkURL(url){
|
function checkURL(url){
|
||||||
var url = new URL(url);
|
var url = new URL(url);
|
||||||
var mode = "block";
|
var mode = "block";
|
||||||
@ -159,6 +169,12 @@
|
|||||||
worker.port.emit("setTranslation", text, _(text));
|
worker.port.emit("setTranslation", text, _(text));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
worker.port.emit("setTranslation", "sourceOutput", _("sourceOutput"));
|
||||||
|
worker.port.emit("setTranslation", "stackEntryOutput", _("stackEntryOutput"));
|
||||||
|
|
||||||
|
preferencesForInjected.forEach(function(name){
|
||||||
|
worker.port.emit("set", name, prefs[name]);
|
||||||
|
});
|
||||||
|
|
||||||
checkWorker(worker);
|
checkWorker(worker);
|
||||||
},
|
},
|
||||||
|
@ -19,6 +19,12 @@ blockMode_options.allow everything= alles erlauben
|
|||||||
askOnlyOnce_title= Nur einmal nachfragen
|
askOnlyOnce_title= Nur einmal nachfragen
|
||||||
askOnlyOnce_description= Wenn eine Seite öfters versucht, die <canvas>-API abzurufen, erscheint jedes mal eine Nachfrage. Mit diesem Schalter wird pro Seitenbesuch nur einmal nachgefragt. Bei manchen Seiten kann es trotzdem zu mehrmaligem Nachfragen kommen.
|
askOnlyOnce_description= Wenn eine Seite öfters versucht, die <canvas>-API abzurufen, erscheint jedes mal eine Nachfrage. Mit diesem Schalter wird pro Seitenbesuch nur einmal nachgefragt. Bei manchen Seiten kann es trotzdem zu mehrmaligem Nachfragen kommen.
|
||||||
|
|
||||||
|
showCallingFile_title= Aufrufende Datei anzeigen
|
||||||
|
showCallingFile_description=
|
||||||
|
|
||||||
|
showCompleteCallingStack_title= Kompletten Aufrufestack anzeigen
|
||||||
|
showCompleteCallingStack_description=
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@ -27,4 +33,7 @@ askForVisiblePermission= Wollen Sie das rot umrandete <canvas> erlauben?
|
|||||||
askForInvisiblePermission= Wollen Sie unsichtbare <canvas> erlauben?
|
askForInvisiblePermission= Wollen Sie unsichtbare <canvas> erlauben?
|
||||||
askForReadoutPermission= Wollen Sie das Auslesen von <canvas> erlauben?
|
askForReadoutPermission= Wollen Sie das Auslesen von <canvas> erlauben?
|
||||||
askForVisibleReadoutPermission= Wollen Sie das Auslesen des rot umrandeten <canvas> erlauben?
|
askForVisibleReadoutPermission= Wollen Sie das Auslesen des rot umrandeten <canvas> erlauben?
|
||||||
askForInvisibleReadoutPermission= Wollen Sie das Auslesen von unsichtbaren <canvas> erlauben?
|
askForInvisibleReadoutPermission= Wollen Sie das Auslesen von unsichtbaren <canvas> erlauben?
|
||||||
|
|
||||||
|
sourceOutput= Aufrufende Datei
|
||||||
|
stackEntryOutput= {url} Zeile {line} Spalte {column}
|
@ -19,6 +19,12 @@ blockMode_options.allow everything= allow everything
|
|||||||
askOnlyOnce_title= Ask only once
|
askOnlyOnce_title= Ask only once
|
||||||
askOnlyOnce_description= If a page tries to access the <canvas>-API several times a confirm message will appear every time. This switch tries to make only one confirmation. Never the less on some pages there will be more.
|
askOnlyOnce_description= If a page tries to access the <canvas>-API several times a confirm message will appear every time. This switch tries to make only one confirmation. Never the less on some pages there will be more.
|
||||||
|
|
||||||
|
showCallingFile_title= Show calling file
|
||||||
|
showCallingFile_description=
|
||||||
|
|
||||||
|
showCompleteCallingStack_title= Display complete calling stack
|
||||||
|
showCompleteCallingStack_description=
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@ -27,4 +33,7 @@ askForVisiblePermission= Do you want to allow the red bordered <canvas>?
|
|||||||
askForInvisiblePermission= Do you want to allow invisible <canvas>?
|
askForInvisiblePermission= Do you want to allow invisible <canvas>?
|
||||||
askForReadoutPermission= Do you want to allow <canvas> readout?
|
askForReadoutPermission= Do you want to allow <canvas> readout?
|
||||||
askForVisibleReadoutPermission= Do you want to allow the readout of the red bordered <canvas>?
|
askForVisibleReadoutPermission= Do you want to allow the readout of the red bordered <canvas>?
|
||||||
askForInvisibleReadoutPermission= Do you want to allow invisible <canvas> readout?
|
askForInvisibleReadoutPermission= Do you want to allow invisible <canvas> readout?
|
||||||
|
|
||||||
|
sourceOutput= Calling file
|
||||||
|
stackEntryOutput= {url} line {line} column {column}
|
12
package.json
12
package.json
@ -62,6 +62,18 @@
|
|||||||
"type": "bool",
|
"type": "bool",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "showCallingFile",
|
||||||
|
"title": "Display calling file",
|
||||||
|
"type": "bool",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "showCompleteCallingStack",
|
||||||
|
"title": "Display complete calling stack",
|
||||||
|
"type": "bool",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "allowPDFCanvas",
|
"name": "allowPDFCanvas",
|
||||||
"title": "Allow canvas in PDFs",
|
"title": "Allow canvas in PDFs",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user