From 2f4fca10ab06b0ed98841d951be176c8077f7720 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Fri, 21 Sep 2018 16:42:58 +0200 Subject: [PATCH] Ask mode did not show canvas canvas any more. --- lib/intercept.js | 3 ++- lib/modifiedAPI.js | 18 +++++++++--------- lib/modifiedAPIFunctions.js | 4 ++-- releaseNotes.txt | 1 + 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/intercept.js b/lib/intercept.js index 605b220..8f5ce81 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -222,6 +222,7 @@ } var funcStatus = changedFunction.getStatus(this, siteStatus, prefs); + const This = this; function notifyCallback(messageId){ notify({ url, @@ -230,7 +231,7 @@ timestamp: new Date(), functionName: name, api: changedFunction.api, - dataURL: getDataURL(this, prefs) + dataURL: getDataURL(This, prefs) }); } const protectedAPIFeatures = prefs("protectedAPIFeatures"); diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 02d721c..d1b2c66 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -214,7 +214,7 @@ if (canvasSizeShouldBeFaked(this, prefs)){ var fakeCanvas = getFakeCanvas(window, this, prefs); if (fakeCanvas !== this){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); } return original.apply(fakeCanvas, window.Array.from(args)); } @@ -244,7 +244,7 @@ if (canvasSizeShouldBeFaked(this, prefs)){ var fakeCanvas = getFakeCanvas(window, this, prefs); if (fakeCanvas !== this){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); } return original.apply(fakeCanvas, window.Array.from(args)); } @@ -275,7 +275,7 @@ if (canvasSizeShouldBeFaked(this, prefs)){ var fakeCanvas = getFakeCanvas(window, this, prefs); if (fakeCanvas !== this){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); } return original.apply(fakeCanvas, window.Array.from(args)); } @@ -305,7 +305,7 @@ fakeCanvas = getFakeCanvas(window, this.canvas, prefs); } if (fakeCanvas && fakeCanvas !== this.canvas){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); context = window.HTMLCanvasElement.prototype.getContext.call( fakeCanvas, "2d" @@ -335,7 +335,7 @@ var rng = randomSupply.getValueRng(1, window); var originalValue = original.apply(this, window.Array.from(args)); if ((typeof originalValue) === "boolean"){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); var index = x + this.width * y; return original.call(this, rng(x, index), rng(y, index)); } @@ -361,7 +361,7 @@ var rng = randomSupply.getValueRng(1, window); var originalValue = original.apply(this, window.Array.from(args)); if ((typeof originalValue) === "boolean"){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); var index = x + this.width * y; return original.call(this, rng(x, index), rng(y, index)); } @@ -385,7 +385,7 @@ return checkerWrapper(checker, this, arguments, function(args, check){ var {prefs, notify, window, original} = check; if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){ - notify.call(this, "fakedInput"); + notify("fakedInput"); var oldImageData; try { // "this" is not trustable - it may be not a context @@ -420,7 +420,7 @@ return checkerWrapper(checker, this, arguments, function(args, check){ var {prefs, notify, window, original} = check; if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){ - notify.call(this, "fakedInput"); + notify("fakedInput"); var oldImageData; try { // "this" is not trustable - it may be not a context @@ -455,7 +455,7 @@ return checkerWrapper(checker, this, arguments, function(args, check){ var {prefs, notify, window, original} = check; if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){ - notify.call(this, "fakedReadout"); + notify("fakedReadout"); var fakeCanvas = getFakeCanvas(window, this.canvas, prefs); var {context} = copyCanvasToWebgl( window, diff --git a/lib/modifiedAPIFunctions.js b/lib/modifiedAPIFunctions.js index 3b76b8a..8ab2ebc 100644 --- a/lib/modifiedAPIFunctions.js +++ b/lib/modifiedAPIFunctions.js @@ -20,14 +20,14 @@ }; scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){ - const check = checker(); + const check = checker.call(object); if (check.allow){ if (check.allow === true){ return check.original.apply(object, check.window.Array.from(args)); } return callback.call(object, args, check); } - check.notify.call(object, "blocked"); + check.notify("blocked"); return undefined; }; }()); \ No newline at end of file diff --git a/releaseNotes.txt b/releaseNotes.txt index 69e9c61..e2037f6 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -18,6 +18,7 @@ Version 0.5.4: - window and audio API were always blocked when using any of the "block ..." modes - canvas content was not stored to be displayed when wanted - hovering over toolbar icon created error in the browser console + - canvas content was not shown in ask mode any more known issues: - if a data URL is blocked the page action button does not appear