1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 20:16:33 +02:00

Simplified PDF checking

This commit is contained in:
kkapsner 2015-04-15 11:39:35 +02:00
parent ba524a896e
commit e639b863dd
3 changed files with 29 additions and 50 deletions

View file

@ -87,7 +87,6 @@
});
function checkURL(url){
url = new URL(url);
var mode = "block";
switch (prefs.blockMode){
case "blockEverything":
@ -133,8 +132,18 @@
}
function checkWorker(worker){
try {
var mode = checkURL(worker.url);
worker.port.emit(mode, false, prefs.askOnlyOnce);
var mode;
var url = new URL(worker.url)
if (
(url.protocol === "about:") ||
(prefs.allowPDFCanvas && worker.tab.contentType.match(/\/pdf$/i))
){
mode = "unblock";
}
else {
var mode = checkURL(url);
}
worker.port.emit(mode, prefs.askOnlyOnce);
}
catch (e){
console.log("Error updating " + worker.url + ": " + e.message);
@ -158,14 +167,6 @@
worker.on("detach", function(){
array.remove(workers, this);
});
worker.port.on("isPDF", function(blocking){
if (prefs.allowPDFCanvas){
this.emit("unblock");
}
else {
this.emit(blocking, true, prefs.askOnlyOnce);
}
});
["", "Readout"].forEach(function(type){
["", "Visible", "Invisible"].forEach(function(visibility){
var text = "askFor" + visibility + type + "Permission";