mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Made checkStack available during interception.
This commit is contained in:
parent
d122f90655
commit
e4c65d415e
@ -26,6 +26,18 @@
|
|||||||
return {type: [], mode: "allow"};
|
return {type: [], mode: "allow"};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function checkStack(stack){
|
||||||
|
if (enabled){
|
||||||
|
var status = sendSyncMessage(
|
||||||
|
"canvasBlocker-checkStack",
|
||||||
|
stack
|
||||||
|
);
|
||||||
|
return status[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
function askWrapper(data){
|
function askWrapper(data){
|
||||||
return ask(data, {
|
return ask(data, {
|
||||||
_: function(token){
|
_: function(token){
|
||||||
@ -56,7 +68,7 @@
|
|||||||
var window = ev.target.defaultView;
|
var window = ev.target.defaultView;
|
||||||
intercept(
|
intercept(
|
||||||
{subject: window},
|
{subject: window},
|
||||||
{check, ask: askWrapper, notify, prefs}
|
{check, checkStack, ask: askWrapper, notify, prefs}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
lib/check.js
19
lib/check.js
@ -13,8 +13,7 @@
|
|||||||
const {URL} = require("sdk/url");
|
const {URL} = require("sdk/url");
|
||||||
|
|
||||||
exports.check = function check({url, errorStack}){
|
exports.check = function check({url, errorStack}){
|
||||||
var callingStack = parseErrorStack(errorStack);
|
var match = checkBoth(errorStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input|Internal)$/);
|
||||||
var match = checkBoth(callingStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input)$/);
|
|
||||||
if (match){
|
if (match){
|
||||||
return {
|
return {
|
||||||
type: (match[2] === "Everything" || match[2] === "")?
|
type: (match[2] === "Everything" || match[2] === "")?
|
||||||
@ -32,8 +31,8 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkBoth(stack, url, blockMode){
|
function checkBoth(errorStack, url, blockMode){
|
||||||
if (prefs.enableStackList && checkStack(stack)){
|
if (prefs.enableStackList && errorStack && checkStack(errorStack)){
|
||||||
return "allow";
|
return "allow";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -42,15 +41,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkURL(url, blockMode){
|
function checkURL(url, blockMode){
|
||||||
url = new URL(url);
|
url = new URL(url || "about:blank");
|
||||||
switch (url.protocol){
|
switch (url.protocol){
|
||||||
case "about:":
|
case "about:":
|
||||||
if (url.href === "about:blank"){
|
if (url.href === "about:blank"){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "allow";
|
return "allowInternal";
|
||||||
case "chrome:":
|
case "chrome:":
|
||||||
return "allow";
|
return "allowInternal";
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode = "block";
|
var mode = "block";
|
||||||
@ -93,7 +92,9 @@
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkStack(stack){
|
function checkStack(errorStack){
|
||||||
return lists.get("stack").match(stack);
|
var callingStack = parseErrorStack(errorStack);
|
||||||
|
return lists.get("stack").match(callingStack);
|
||||||
}
|
}
|
||||||
|
exports.checkStack = checkStack;
|
||||||
}());
|
}());
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
const {when: unload} = require("sdk/system/unload");
|
const {when: unload} = require("sdk/system/unload");
|
||||||
const {check} = require("./check.js");
|
const {check, checkStack} = require("./check.js");
|
||||||
const {notify} = require("./notifications");
|
const {notify} = require("./notifications");
|
||||||
|
|
||||||
const _ = require("sdk/l10n").get;
|
const _ = require("sdk/l10n").get;
|
||||||
@ -53,6 +53,9 @@
|
|||||||
var status = check(ev.data);
|
var status = check(ev.data);
|
||||||
return status;
|
return status;
|
||||||
});
|
});
|
||||||
|
addMessageListener("canvasBlocker-checkStack", function(ev){
|
||||||
|
return checkStack(ev.data);
|
||||||
|
});
|
||||||
|
|
||||||
addMessageListener("canvasBlocker-notify", function(ev){
|
addMessageListener("canvasBlocker-notify", function(ev){
|
||||||
var browser = ev.target;
|
var browser = ev.target;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user