From 871199cbc35b017f32124290c5ba2a880e171083 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Mon, 11 Dec 2017 12:48:08 +0100 Subject: [PATCH] do not show notifications when canvas faking was aborted --- lib/modifiedAPI.js | 23 ++++++++++++++++------- releaseNotes.txt | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 7e23c12..169ed75 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -206,8 +206,11 @@ fakeGenerator: function(prefs, notify, window, original){ return function toDataURL(){ if (canvasSizeShouldBeFaked(this, prefs)){ - notify.call(this, "fakedReadout"); - return original.apply(getFakeCanvas(window, this, prefs), window.Array.from(arguments)); + var fakeCanvas = getFakeCanvas(window, this, prefs); + if (fakeCanvas !== this){ + notify.call(this, "fakedReadout"); + } + return original.apply(fakeCanvas, window.Array.from(arguments)); } else { return original.apply(this, window.Array.from(arguments)); @@ -230,8 +233,11 @@ fakeGenerator: function(prefs, notify, window, original){ return function toBlob(callback){ if (canvasSizeShouldBeFaked(this, prefs)){ - notify.call(this, "fakedReadout"); - return original.apply(getFakeCanvas(window, this, prefs), window.Array.from(arguments)); + var fakeCanvas = getFakeCanvas(window, this, prefs); + if (fakeCanvas !== this){ + notify.call(this, "fakedReadout"); + } + return original.apply(fakeCanvas, window.Array.from(arguments)); } else { return original.apply(this, window.Array.from(arguments)); @@ -255,8 +261,11 @@ fakeGenerator: function(prefs, notify, window, original){ return function mozGetAsFile(callback){ if (canvasSizeShouldBeFaked(this, prefs)){ - notify.call(this, "fakedReadout"); - return original.apply(getFakeCanvas(window, this, prefs), window.Array.from(arguments)); + var fakeCanvas = getFakeCanvas(window, this, prefs); + if (fakeCanvas !== this){ + notify.call(this, "fakedReadout"); + } + return original.apply(fakeCanvas, window.Array.from(arguments)); } else { return original.apply(this, window.Array.from(arguments)); @@ -275,13 +284,13 @@ fakeGenerator: function(prefs, notify, window, original){ return function getImageData(sx, sy, sw, sh){ if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){ - notify.call(this, "fakedReadout"); var fakeCanvas; var context = this; if (this && this.canvas) { fakeCanvas = getFakeCanvas(window, this.canvas, prefs); } if (fakeCanvas && fakeCanvas !== this.canvas){ + notify.call(this, "fakedReadout"); context = window.HTMLCanvasElement.prototype.getContext.call( fakeCanvas, "2d" diff --git a/releaseNotes.txt b/releaseNotes.txt index 8f90ab5..0027373 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -14,6 +14,7 @@ Version 0.4.3: fixes: - page action was not always showing - waiting for settings created error messages in browser console + - do not show notifications when canvas faking was aborted Version 0.4.2 new features: