1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-05-29 09:28:06 +02:00

Suppressed notification if maxFakeSize triggers.

This commit is contained in:
kkapsner 2016-05-11 08:58:45 +02:00
parent b8ba76300e
commit 37fd9f7a36
4 changed files with 24 additions and 6 deletions

View File

@ -34,8 +34,20 @@
case "allow":
return original;
case "fake":
notify({url: window.location.href, errorStack: error.stack}, window);
return changedFunction.fake || changedFunction.fakeGenerator(prefs) || undef;
if (changedFunction.fake){
return changedFunction.fake;
}
else {
if (changedFunction.fakeGenerator) {
return changedFunction.fakeGenerator(prefs, function(){
notify({url: window.location.href, errorStack: error.stack}, window);
});
}
else {
return undef;
}
}
//case "block":
default:
return undef;

View File

@ -93,16 +93,21 @@
getImageData: {
type: "readout",
object: "CanvasRenderingContext2D",
fakeGenerator: function(prefs){
fakeGenerator: function(prefs, notify){
var maxSize = prefs("maxFakeSize") || Number.POSITIVE_INFINITY;
return function getImageData(sx, sy, sw, sh){
var window = getWindow(this.canvas);
var context = (sw * sh > maxSize)?
this:
window.HTMLCanvasElement.prototype.getContext.call(
var context;
if (sw * sh > maxSize){
context = this;
}
else {
notify();
context = window.HTMLCanvasElement.prototype.getContext.call(
getFakeCanvas(window, this.canvas),
"2d"
);
}
var data = window.CanvasRenderingContext2D.prototype.getImageData.apply(context, arguments).data;
var imageData = new window.wrappedJSObject.ImageData(sw, sh);

View File

@ -119,5 +119,6 @@ exports.notify = function({url, errorStack}, {lists, notificationPref, _, browse
notification.domain = domain;
notification.callingStackMsg = callingStackMsg;
}
return notification;
}
};