mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Suppressed notification if maxFakeSize triggers.
This commit is contained in:
parent
b8ba76300e
commit
37fd9f7a36
Binary file not shown.
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -119,5 +119,6 @@ exports.notify = function({url, errorStack}, {lists, notificationPref, _, browse
|
||||
notification.domain = domain;
|
||||
notification.callingStackMsg = callingStackMsg;
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user