1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added method to display faked canvas content.

This commit is contained in:
kkapsner 2017-07-08 22:40:38 +02:00
parent 8cec88f5f7
commit 3cefcfe702
7 changed files with 64 additions and 11 deletions

View file

@ -1,4 +1,5 @@
"use strict";
var settings = { whiteList: "", blackList: "", blockMode: "fakeReadout", maxFakeSize: 0, rng: "nonPersistent", persistentRndStorage: "", storePersistentRnd: false, askOnlyOnce: true, showNotifications: true, notificationDisplayTime: 30, ignoreList: "", showCallingFile: false, showCompleteCallingStack: false, enableStackList: false, stackList: ""
var settings = { whiteList: "", blackList: "", blockMode: "fakeReadout", maxFakeSize: 0, rng: "nonPersistent", persistentRndStorage: "", storePersistentRnd: false, askOnlyOnce: true, showNotifications: true,
storeImageForInspection: false, notificationDisplayTime: 30, ignoreList: "", showCallingFile: false, showCompleteCallingStack: false, enableStackList: false, stackList: ""
};

View file

@ -81,7 +81,26 @@
case "fake":
setRandomSupplyByType(prefs("rng"));
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
notify({url, errorStack: error.stack, messageId, timestamp: new Date(), functionName: name});
notify({
url,
errorStack: error.stack,
messageId, timestamp: new Date(),
functionName: name,
dataURL:
prefs("storeImageForInspection") &&
prefs("showNotifications")
?
(
this instanceof HTMLCanvasElement?
this.toDataURL():
(
this.canvas instanceof HTMLCanvasElement?
this.canvas.toDataURL():
false
)
):
false
});
}, window, original);
switch (fake){
case true:

View file

@ -149,7 +149,7 @@
object: "HTMLCanvasElement",
fakeGenerator: function(prefs, notify, window, original){
return function toDataURL(){
notify("fakedReadout");
notify.call(this, "fakedReadout");
return original.apply(getFakeCanvas(window, this), window.Array.from(arguments));
};
}
@ -170,7 +170,7 @@
object: "HTMLCanvasElement",
fakeGenerator: function(prefs, notify, window, original){
return function toBlob(callback){
notify("fakedReadout");
notify.call(this, "fakedReadout");
return original.apply(getFakeCanvas(window, this), window.Array.from(arguments));
};
},
@ -192,7 +192,7 @@
object: "HTMLCanvasElement",
fakeGenerator: function(prefs, notify, window, original){
return function mozGetAsFile(callback){
notify("fakedReadout");
notify.call(this, "fakedReadout");
return original.apply(getFakeCanvas(window, this), window.Array.from(arguments));
};
}
@ -218,7 +218,7 @@
return original.apply(this, window.Array.from(arguments));
}
else {
notify("fakedReadout");
notify.call(this, "fakedReadout");
var fakeCanvas;
var context = this;
if (this && this.canvas) {
@ -245,7 +245,7 @@
object: "CanvasRenderingContext2D",
fakeGenerator: function(prefs, notify, window, original){
return function fillText(str, x, y){
notify("fakedInput");
notify.call(this, "fakedInput");
var oldImageData;
try {
// "this" is not trustable - it may be not a context
@ -270,7 +270,7 @@
object: "CanvasRenderingContext2D",
fakeGenerator: function(prefs, notify, window, original){
return function strokeText(str, x, y){
notify("fakedInput");
notify.call(this, "fakedInput");
var oldImageData;
try {
// "this" is not trustable - it may be not a context
@ -296,7 +296,7 @@
fakeGenerator: function(prefs, notify, window, original){
return function readPixels(x, y, width, height, format, type, pixels){
// not able to use the getFakeCanvas function because the context type is wrong...
notify("fakedReadout");
notify.call(this, "fakedReadout");
var xPixels = pixels;
var ret = original.apply(this, window.Array.from(arguments));
var l = xPixels.length;