Merge from master

This commit is contained in:
kkapsner 2014-12-15 19:32:02 +01:00
commit ab8a88ef66
6 changed files with 98 additions and 7 deletions

Binary file not shown.

View File

@ -2,6 +2,9 @@
(function(){
"use strict";
var settings = {
showCallingFile: false
};
var blockMode = {
getContext: {
status: "block",
@ -147,12 +150,32 @@
status = askStatus.answer;
}
else {
//console.log("asking");
var appearance = canvasAppearance(this);
// console.log("asking");
status = window.confirm(_(changedFunction.mode.askText[appearance.text]))? "allow": "block";
var msg = _(changedFunction.mode.askText[appearance.text]);
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.answer = status;
//console.log("asking (done)");
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
var _ = function(name){
return _[name] || name;
var _ = function(name, replace){
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){
_[name] = translation;
@ -232,4 +272,9 @@
blockMode.getContext.status = "allow";
blockMode.readAPI.status = "allow";
});
// settings passthrough
self.port.on("set", function(name, value){
settings[name] = value;
});
}());

View File

@ -73,6 +73,16 @@
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){
var url = new URL(url);
var mode = "block";
@ -159,6 +169,12 @@
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);
},

View File

@ -19,6 +19,12 @@ blockMode_options.allow everything= alles erlauben
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.
showCallingFile_title= Aufrufende Datei anzeigen
showCallingFile_description=
showCompleteCallingStack_title= Kompletten Aufrufestack anzeigen
showCompleteCallingStack_description=
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.
@ -27,4 +33,7 @@ askForVisiblePermission= Wollen Sie das rot umrandete <canvas> erlauben?
askForInvisiblePermission= Wollen Sie unsichtbare <canvas> erlauben?
askForReadoutPermission= Wollen Sie das Auslesen von <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}

View File

@ -19,6 +19,12 @@ blockMode_options.allow everything= allow everything
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.
showCallingFile_title= Show calling file
showCallingFile_description=
showCompleteCallingStack_title= Display complete calling stack
showCompleteCallingStack_description=
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.
@ -27,4 +33,7 @@ askForVisiblePermission= Do you want to allow the red bordered <canvas>?
askForInvisiblePermission= Do you want to allow invisible <canvas>?
askForReadoutPermission= Do you want to allow <canvas> readout?
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}

View File

@ -62,6 +62,18 @@
"type": "bool",
"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",
"title": "Allow canvas in PDFs",