1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Fixed bug with "block" mode

window and audio API were always blocked when using any of the "block
..." modes

Fixes #243
This commit is contained in:
kkapsner 2018-09-06 17:24:05 +02:00
parent e0729480fb
commit aa8b202545
5 changed files with 12 additions and 10 deletions

View file

@ -25,6 +25,7 @@
); );
if (match){ if (match){
return { return {
url: url,
type: (match[2] === "Everything" || match[2] === "")? type: (match[2] === "Everything" || match[2] === "")?
["context", "readout", "input"]: ["context", "readout", "input"]:
[match[2].toLowerCase()], [match[2].toLowerCase()],
@ -33,6 +34,7 @@
} }
else { else {
return { return {
url: url,
type: ["context", "readout", "input"], type: ["context", "readout", "input"],
mode: "block" mode: "block"
}; };

View file

@ -211,7 +211,7 @@
if (checkStack(error.stack)){ if (checkStack(error.stack)){
return {allow: true, original, window}; return {allow: true, original, window};
} }
var funcStatus = changedFunction.getStatus(this, siteStatus); var funcStatus = changedFunction.getStatus(this, siteStatus, prefs);
function notifyCallback(messageId){ function notifyCallback(messageId){
notify({ notify({
@ -273,7 +273,7 @@
if (siteStatus.mode !== "allow"){ if (siteStatus.mode !== "allow"){
apiNames.forEach(function(name){ apiNames.forEach(function(name){
var changedFunction = changedFunctions[name]; var changedFunction = changedFunctions[name];
var functionStatus = changedFunction.getStatus(undefined, siteStatus); var functionStatus = changedFunction.getStatus(undefined, siteStatus, prefs);
logging.verbose("status for", name, ":", functionStatus); logging.verbose("status for", name, ":", functionStatus);
if (functionStatus.active){ if (functionStatus.active){
( (
@ -312,7 +312,7 @@
}); });
changedGetters.forEach(function(changedGetter){ changedGetters.forEach(function(changedGetter){
const name = changedGetter.name; const name = changedGetter.name;
var functionStatus = changedGetter.getStatus(undefined, siteStatus); var functionStatus = changedGetter.getStatus(undefined, siteStatus, prefs);
logging.verbose("status for", changedGetter, ":", functionStatus); logging.verbose("status for", changedGetter, ":", functionStatus);
if (functionStatus.active){ if (functionStatus.active){
changedGetter.objectGetters.forEach(function(objectGetter){ changedGetter.objectGetters.forEach(function(objectGetter){

View file

@ -90,7 +90,7 @@
const intCache = Object.create(null); const intCache = Object.create(null);
function fakeFloat32Array(array, window, prefs){ function fakeFloat32Array(array, window, prefs){
if (prefs("protectAudio")){ if (prefs("protectAudio", window.location)){
let cached = false; let cached = false;
let hash; let hash;
if (prefs("useAudioCache")){ if (prefs("useAudioCache")){
@ -121,7 +121,7 @@
} }
} }
function fakeUint8Array(array, window, prefs){ function fakeUint8Array(array, window, prefs){
if (prefs("protectAudio")){ if (prefs("protectAudio", window.location)){
let cached = false; let cached = false;
let hash; let hash;
if (prefs("useAudioCache")){ if (prefs("useAudioCache")){
@ -148,9 +148,9 @@
randomSupply = supply; randomSupply = supply;
}; };
function getStatus(obj, status){ function getStatus(obj, status, prefs){
status = Object.create(status); status = Object.create(status);
status.active = hasType(status, "readout"); status.active = prefs("protectAudio", status.url) && hasType(status, "readout");
return status; return status;
} }

View file

@ -73,9 +73,9 @@
} }
]; ];
function getStatus(obj, status){ function getStatus(obj, status, prefs){
status = Object.create(status); status = Object.create(status);
status.active = hasType(status, "readout"); status.active = prefs("protectWindow", status.url) && hasType(status, "readout");
return status; return status;
} }

View file

@ -6,7 +6,7 @@ Version 0.5.4:
- added save/load directly to/from file option - added save/load directly to/from file option
fixes: fixes:
- - window and audio API were always blocked when using any of the "block ..." modes
known issues: known issues:
- if a data URL is blocked the page action button does not appear - if a data URL is blocked the page action button does not appear