1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01: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

@ -115,7 +115,7 @@
},
"maxFakeSize_description": {
"message": "Canvas, die eine größere Fläche als die hier angegebene Zahl haben, werden nicht vorgetäuscht. (Null eingeben, um es zu deaktivieren.) Dies ist ein Leistungsparameter, der das Einfrieren des Browsers verringern kann und der an die Rechenleistung des Gerätes angepasst sein soll. ACHTUNG: Dies verringert die Sicherheit des Addons. Deswegen wird stark empfohlen, diesen Wert nicht unter 100 000 zu setzen.",
"message": "Canvas, die eine größere Fläche als die hier angegebene Zahl haben, werden nicht vorgetäuscht. (Null eingeben, um es zu deaktivieren.) Dies ist ein Leistungsparameter, der das Einfrieren des Browsers verringern kann und der an die Rechenleistung des Gerätes angepasst sein soll.\nACHTUNG: Dies verringert die Sicherheit des Addons. Deswegen wird stark empfohlen, diesen Wert nicht unter 100 000 zu setzen.",
"description": ""
},
"maxFakeSize_title": {
@ -298,6 +298,19 @@
"description": ""
},
"inspectImage": {
"message": "Bild betrachten",
"description": ""
},
"storeImageForInspection_title": {
"message": "Bild für Betrachtung speichern",
"description": ""
},
"storeImageForInspection_description": {
"message": "Aktiviert die Speicherung des Inhaltes der vorgetäuschtend Canvas.\nACHTUNG: Dies kann zu einem hohen Speicherverbrauch führen.",
"description": ""
},
"showReleaseNotes_title": {
"message": "Versionsinformationen",
"description": ""

View File

@ -115,7 +115,7 @@
},
"maxFakeSize_description": {
"message": "Canvas with a bigger area than this number will not be faked. (Enter zero to disable.) This is a performance parameter that can prevent browser freezes and should be adjusted to the computing power of the device. CAUTION: This lowers the safety of the addon, therefore it is highly recommended not to set this value below 100 000.",
"message": "Canvas with a bigger area than this number will not be faked. (Enter zero to disable.) This is a performance parameter that can prevent browser freezes and should be adjusted to the computing power of the device.\nCAUTION: This lowers the safety of the addon, therefore it is highly recommended not to set this value below 100 000.",
"description": ""
},
"maxFakeSize_title": {
@ -302,6 +302,19 @@
"description": ""
},
"inspectImage": {
"message": "inspect image",
"description": ""
},
"storeImageForInspection_title": {
"message": "Store image for inspection",
"description": ""
},
"storeImageForInspection_description": {
"message": "Enables the storage of the content of the faked canvas.\nCAUTION: This may lead to a lot of memory consumption.",
"description": ""
},
"showReleaseNotes_title": {
"message": "Release notes",
"description": ""

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;

View File

@ -122,6 +122,12 @@ Promise.all([
button.addEventListener("click", function(){actionsCallbacks[key](data);});
actions.appendChild(button);
});
if (notification.dataURL){
var button = document.createElement("button");
button.textContent = browser.i18n.getMessage("inspectImage");
button.addEventListener("click", function(){document.body.innerHTML = "<img src=" + notification.dataURL + ">";});
actions.appendChild(button);
}
li.appendChild(actions);
ul.appendChild(li);

View File

@ -7,6 +7,7 @@ Version 0.4.0:
new features:
- information of all fake events in one tab are visible
- new setting to enable the inspection of the content of the faked canvas
fixes:
- ask mode did not work for input types