mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +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
|
||||
|
||||
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")){
|
||||
blockMode.getContext.status = "block";
|
||||
blockMode.readAPI.status = "allow";
|
||||
}
|
||||
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")){
|
||||
blockMode.getContext.status = "ask";
|
||||
blockMode.getContext.askStatus.askOnce = askOnce;
|
||||
blockMode.readAPI.status = "allow";
|
||||
}
|
||||
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")){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "block";
|
||||
}
|
||||
self.port.on("blockReadout", function(){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "block";
|
||||
});
|
||||
self.port.on("fakeReadout", function(force){
|
||||
if (force || !checkAbout() || !checkPDF("fakeReadout")){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "fake";
|
||||
}
|
||||
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")){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "ask";
|
||||
blockMode.readAPI.askStatus.askOnce = askOnce;
|
||||
}
|
||||
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";
|
||||
|
23
lib/main.js
23
lib/main.js
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user