1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Merge remote-tracking branch 'origin/master' into notificationOnFakeReadout

Conflicts:
	canvasblocker.xpi
	data/inject.js
	lib/main.js
This commit is contained in:
kkapsner 2015-04-15 12:11:51 +02:00
commit a8f636ba6f
3 changed files with 29 additions and 50 deletions

Binary file not shown.

View File

@ -253,49 +253,27 @@
// Communication with main.js
function checkAbout(){
return document.location.protocol === "about:";
}
function checkPDF(blocking){
if (document.contentType.match(/\/pdf$/i)){
self.port.emit("isPDF", blocking);
return true;
}
return false;
}
self.port.on("block", function(force){
if (force || !checkAbout() || !checkPDF("block")){
self.port.on("block", function(){
blockMode.getContext.status = "block";
blockMode.readAPI.status = "allow";
}
});
self.port.on("ask", function(force, askOnce){
if (force || !checkAbout() || !checkPDF("askVisible")){
self.port.on("ask", function(askOnce){
blockMode.getContext.status = "ask";
blockMode.getContext.askStatus.askOnce = askOnce;
blockMode.readAPI.status = "allow";
}
});
self.port.on("blockReadout", function(force){
if (force || !checkAbout() || !checkPDF("blockReadout")){
self.port.on("blockReadout", function(){
blockMode.getContext.status = "allow";
blockMode.readAPI.status = "block";
}
});
self.port.on("fakeReadout", function(force){
if (force || !checkAbout() || !checkPDF("fakeReadout")){
self.port.on("fakeReadout", function(){
blockMode.getContext.status = "allow";
blockMode.readAPI.status = "fake";
}
});
self.port.on("askReadout", function(force, askOnce){
if (force || !checkAbout() || !checkPDF("askReadout")){
self.port.on("askReadout", function(askOnce){
blockMode.getContext.status = "allow";
blockMode.readAPI.status = "ask";
blockMode.readAPI.askStatus.askOnce = askOnce;
}
});
self.port.on("unblock", function(){
blockMode.getContext.status = "allow";

View File

@ -90,7 +90,6 @@
});
function checkURL(url){
url = new URL(url);
var mode = "block";
switch (prefs.blockMode){
case "blockEverything":
@ -136,8 +135,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);
@ -161,14 +170,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";