mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 12:36:37 +02:00
Added fake for readPixels and removed new tab bug
Bug description: if a new tab is opened the wrong blockmode could be used.
This commit is contained in:
parent
a8f636ba6f
commit
30407e71a0
4 changed files with 169 additions and 113 deletions
|
@ -171,7 +171,15 @@
|
|||
},
|
||||
readPixels: {
|
||||
mode: blockMode.readAPI,
|
||||
object: unsafeWindow.WebGLRenderingContext
|
||||
object: unsafeWindow.WebGLRenderingContext,
|
||||
fake: function(x, y, width, height, format, type, pixels){
|
||||
// fake not working due to XRay copy restrictions...
|
||||
// for (var i = 0; i < pixels.length; i += 1){
|
||||
// pixels[i] = Math.floor(
|
||||
// Math.random() * 256
|
||||
// );
|
||||
// }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -253,37 +261,56 @@
|
|||
|
||||
// Communication with main.js
|
||||
|
||||
self.port.on("block", function(){
|
||||
blockMode.getContext.status = "block";
|
||||
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(){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "block";
|
||||
});
|
||||
self.port.on("fakeReadout", function(){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "fake";
|
||||
});
|
||||
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";
|
||||
blockMode.readAPI.status = "allow";
|
||||
});
|
||||
self.port.on("detach", function(){
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "allow";
|
||||
function setStatus(mode, askOnce){
|
||||
switch (mode){
|
||||
case "block":
|
||||
blockMode.getContext.status = "block";
|
||||
blockMode.readAPI.status = "allow";
|
||||
break;
|
||||
case "ask":
|
||||
blockMode.getContext.status = "ask";
|
||||
blockMode.getContext.askStatus.askOnce = askOnce;
|
||||
blockMode.readAPI.status = "allow";
|
||||
break;
|
||||
case "blockReadout":
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "block";
|
||||
break;
|
||||
case "fakeReadout":
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "fake";
|
||||
break;
|
||||
case "askReadout":
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "ask";
|
||||
blockMode.readAPI.askStatus.askOnce = askOnce;
|
||||
break;
|
||||
case "unblock":
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "allow";
|
||||
break;
|
||||
case "detach":
|
||||
blockMode.getContext.status = "allow";
|
||||
blockMode.readAPI.status = "allow";
|
||||
break;
|
||||
}
|
||||
}
|
||||
["block", "ask", "blockReadout", "fakeReadout", "askReadout", "unblock", "detach"].forEach(function(mode){
|
||||
self.port.on(mode, function(askOnce){
|
||||
setStatus(mode, askOnce);
|
||||
});
|
||||
});
|
||||
|
||||
setStatus(
|
||||
checkURL(
|
||||
location,
|
||||
self.options.blockMode,
|
||||
getDomainRegExpList(self.options.whiteList),
|
||||
getDomainRegExpList(self.options.blackList)
|
||||
),
|
||||
self.options.askOnce
|
||||
);
|
||||
|
||||
// settings passthrough
|
||||
self.port.on("set", function(name, value){
|
||||
settings[name] = value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue