1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-03-13 11:44:12 +01:00

Monitoring only the necessary functions -> changes of the mode or the white/black lists only affects new loaded pages.

Fixes #84.
This commit is contained in:
kkapsner 2016-11-13 15:09:03 +01:00
parent b2823cbd8d
commit 82bb25d0f2
2 changed files with 51 additions and 46 deletions

View File

@ -21,11 +21,13 @@
}
}
exports.setRandomSupplyByType = setRandomSupplyByType;
exports.intercept = function intercept({subject: window}, {check, ask, notify, prefs}){
exports.intercept = function intercept({subject: window}, {check, checkStack, ask, notify, prefs}){
var siteStatus = check({url: window.location.href});
apiNames.forEach(function(name){
var changedFunction = changedFunctions[name];
var original = window.wrappedJSObject[changedFunction.object].prototype[name];
if (changedFunction.getStatus(undefined, siteStatus).active){
Object.defineProperty(
window.wrappedJSObject[changedFunction.object].prototype,
name,
@ -37,8 +39,10 @@
return undef;
}
var error = new Error();
var status = check({url: window.location.href, errorStack: error.stack});
var funcStatus = changedFunction.getStatus(this, status);
if (checkStack(error.stack)){
return original;
}
var funcStatus = changedFunction.getStatus(this, siteStatus);
if (funcStatus.active){
if (funcStatus.mode === "ask"){
@ -71,6 +75,7 @@
}
}
);
}
});
};
}());

View File

@ -111,7 +111,7 @@
getStatus: function(obj, status){
if (hasType(status, "input")){
var contextType = canvasContextType.get(obj);
status.active = contextType && contextType !== "2d";
status.active = contextType !== "2d";
}
else {
status.active = hasType(status, "readout");
@ -131,7 +131,7 @@
getStatus: function(obj, status){
if (hasType(status, "input")){
var contextType = canvasContextType.get(obj);
status.active = contextType && contextType !== "2d";
status.active = contextType !== "2d";
}
else {
status.active = hasType(status, "readout");
@ -152,7 +152,7 @@
getStatus: function(obj, status){
if (hasType(status, "input")){
var contextType = canvasContextType.get(obj);
status.active = contextType && contextType !== "2d";
status.active = contextType !== "2d";
}
else {
status.active = hasType(status, "readout");
@ -172,7 +172,7 @@
getStatus: function(obj, status){
if (hasType(status, "input")){
var contextType = canvasContextType.get(obj);
status.active = contextType && contextType !== "2d";
status.active = contextType !== "2d";
}
else {
status.active = hasType(status, "readout");