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:
commit
a8f636ba6f
Binary file not shown.
@ -253,49 +253,27 @@
|
|||||||
|
|
||||||
// Communication with main.js
|
// Communication with main.js
|
||||||
|
|
||||||
function checkAbout(){
|
self.port.on("block", function(){
|
||||||
return document.location.protocol === "about:";
|
blockMode.getContext.status = "block";
|
||||||
}
|
blockMode.readAPI.status = "allow";
|
||||||
|
|
||||||
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")){
|
|
||||||
blockMode.getContext.status = "block";
|
|
||||||
blockMode.readAPI.status = "allow";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.port.on("ask", function(force, askOnce){
|
self.port.on("ask", function(askOnce){
|
||||||
if (force || !checkAbout() || !checkPDF("askVisible")){
|
blockMode.getContext.status = "ask";
|
||||||
blockMode.getContext.status = "ask";
|
blockMode.getContext.askStatus.askOnce = askOnce;
|
||||||
blockMode.getContext.askStatus.askOnce = askOnce;
|
blockMode.readAPI.status = "allow";
|
||||||
blockMode.readAPI.status = "allow";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.port.on("blockReadout", function(force){
|
self.port.on("blockReadout", function(){
|
||||||
if (force || !checkAbout() || !checkPDF("blockReadout")){
|
blockMode.getContext.status = "allow";
|
||||||
blockMode.getContext.status = "allow";
|
blockMode.readAPI.status = "block";
|
||||||
blockMode.readAPI.status = "block";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.port.on("fakeReadout", function(force){
|
self.port.on("fakeReadout", function(){
|
||||||
if (force || !checkAbout() || !checkPDF("fakeReadout")){
|
blockMode.getContext.status = "allow";
|
||||||
blockMode.getContext.status = "allow";
|
blockMode.readAPI.status = "fake";
|
||||||
blockMode.readAPI.status = "fake";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.port.on("askReadout", function(force, askOnce){
|
self.port.on("askReadout", function(askOnce){
|
||||||
if (force || !checkAbout() || !checkPDF("askReadout")){
|
blockMode.getContext.status = "allow";
|
||||||
blockMode.getContext.status = "allow";
|
blockMode.readAPI.status = "ask";
|
||||||
blockMode.readAPI.status = "ask";
|
blockMode.readAPI.askStatus.askOnce = askOnce;
|
||||||
blockMode.readAPI.askStatus.askOnce = askOnce;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.port.on("unblock", function(){
|
self.port.on("unblock", function(){
|
||||||
blockMode.getContext.status = "allow";
|
blockMode.getContext.status = "allow";
|
||||||
|
23
lib/main.js
23
lib/main.js
@ -90,7 +90,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function checkURL(url){
|
function checkURL(url){
|
||||||
url = new URL(url);
|
|
||||||
var mode = "block";
|
var mode = "block";
|
||||||
switch (prefs.blockMode){
|
switch (prefs.blockMode){
|
||||||
case "blockEverything":
|
case "blockEverything":
|
||||||
@ -136,8 +135,18 @@
|
|||||||
}
|
}
|
||||||
function checkWorker(worker){
|
function checkWorker(worker){
|
||||||
try {
|
try {
|
||||||
var mode = checkURL(worker.url);
|
var mode;
|
||||||
worker.port.emit(mode, false, prefs.askOnlyOnce);
|
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){
|
catch (e){
|
||||||
console.log("Error updating " + worker.url + ": " + e.message);
|
console.log("Error updating " + worker.url + ": " + e.message);
|
||||||
@ -161,14 +170,6 @@
|
|||||||
worker.on("detach", function(){
|
worker.on("detach", function(){
|
||||||
array.remove(workers, this);
|
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){
|
["", "Readout"].forEach(function(type){
|
||||||
["", "Visible", "Invisible"].forEach(function(visibility){
|
["", "Visible", "Invisible"].forEach(function(visibility){
|
||||||
var text = "askFor" + visibility + type + "Permission";
|
var text = "askFor" + visibility + type + "Permission";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user