1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-06-25 04:52:45 +02:00

Made checkStack available during interception.

This commit is contained in:
kkapsner 2016-11-13 14:51:58 +01:00
parent d122f90655
commit e4c65d415e
3 changed files with 27 additions and 11 deletions

View File

@ -26,6 +26,18 @@
return {type: [], mode: "allow"};
}
}
function checkStack(stack){
if (enabled){
var status = sendSyncMessage(
"canvasBlocker-checkStack",
stack
);
return status[0];
}
else {
return true;
}
}
function askWrapper(data){
return ask(data, {
_: function(token){
@ -56,7 +68,7 @@
var window = ev.target.defaultView;
intercept(
{subject: window},
{check, ask: askWrapper, notify, prefs}
{check, checkStack, ask: askWrapper, notify, prefs}
);
}
}

View File

@ -13,8 +13,7 @@
const {URL} = require("sdk/url");
exports.check = function check({url, errorStack}){
var callingStack = parseErrorStack(errorStack);
var match = checkBoth(callingStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input)$/);
var match = checkBoth(errorStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input|Internal)$/);
if (match){
return {
type: (match[2] === "Everything" || match[2] === "")?
@ -32,8 +31,8 @@
};
function checkBoth(stack, url, blockMode){
if (prefs.enableStackList && checkStack(stack)){
function checkBoth(errorStack, url, blockMode){
if (prefs.enableStackList && errorStack && checkStack(errorStack)){
return "allow";
}
else {
@ -42,15 +41,15 @@
}
function checkURL(url, blockMode){
url = new URL(url);
url = new URL(url || "about:blank");
switch (url.protocol){
case "about:":
if (url.href === "about:blank"){
break;
}
return "allow";
return "allowInternal";
case "chrome:":
return "allow";
return "allowInternal";
}
var mode = "block";
@ -93,7 +92,9 @@
return mode;
}
function checkStack(stack){
return lists.get("stack").match(stack);
function checkStack(errorStack){
var callingStack = parseErrorStack(errorStack);
return lists.get("stack").match(callingStack);
}
exports.checkStack = checkStack;
}());

View File

@ -8,7 +8,7 @@
const {when: unload} = require("sdk/system/unload");
const {check} = require("./check.js");
const {check, checkStack} = require("./check.js");
const {notify} = require("./notifications");
const _ = require("sdk/l10n").get;
@ -53,6 +53,9 @@
var status = check(ev.data);
return status;
});
addMessageListener("canvasBlocker-checkStack", function(ev){
return checkStack(ev.data);
});
addMessageListener("canvasBlocker-notify", function(ev){
var browser = ev.target;