mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-18 09:28:52 +01:00
Added setting for canvas cache.
This commit is contained in:
parent
f853071d19
commit
48dc965f7c
@ -193,6 +193,15 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"useCanvasCache_title": {
|
||||||
|
"message": "Zwischenspeicher für Canvas verwenden",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"useCanvasCache_description": {
|
||||||
|
"message": "Aktiviert den Canvas-Zwischenspeicher. Dies kann die Detektion des Addons verhindern und kann die Geschwindigkeit des Addons erhöhen, wenn kleine Canvas oft ausgelesen werden. Für große Canvas wird die Geschwindigkeit leider reduziert.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"disableNotifications": {
|
"disableNotifications": {
|
||||||
"message": "Benachrichtigungen deaktivieren",
|
"message": "Benachrichtigungen deaktivieren",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -193,6 +193,15 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"useCanvasCache_title": {
|
||||||
|
"message": "Use canvas cache",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"useCanvasCache_description": {
|
||||||
|
"message": "Enables the canvas cache. This can prevent detection and increases the performance when small canvas are read several times but decreases it for big canvas.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"disableNotifications": {
|
"disableNotifications": {
|
||||||
"message": "disable notifications",
|
"message": "disable notifications",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -7,7 +7,8 @@ var settings = {
|
|||||||
blockMode: "fakeReadout",
|
blockMode: "fakeReadout",
|
||||||
minFakeSize: 1,
|
minFakeSize: 1,
|
||||||
maxFakeSize: 0,
|
maxFakeSize: 0,
|
||||||
rng: "constant",
|
rng: "nonPersistent",
|
||||||
|
useCanvasCache: true,
|
||||||
ignoreFrequentColors: 0,
|
ignoreFrequentColors: 0,
|
||||||
persistentRndStorage: "",
|
persistentRndStorage: "",
|
||||||
storePersistentRnd: false,
|
storePersistentRnd: false,
|
||||||
|
@ -54,8 +54,16 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var canvasCache = Object.create(null);
|
||||||
function getFakeCanvas(window, original, prefs){
|
function getFakeCanvas(window, original, prefs){
|
||||||
try {
|
try {
|
||||||
|
if (prefs("useCanvasCache")){
|
||||||
|
var originalDataURL = original.toDataURL();
|
||||||
|
var cached = canvasCache[originalDataURL];
|
||||||
|
if (cached){
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
}
|
||||||
// original may not be a canvas -> we must not leak an error
|
// original may not be a canvas -> we must not leak an error
|
||||||
var context = getContext(window, original);
|
var context = getContext(window, original);
|
||||||
var {imageData, source} = getImageData(window, context);
|
var {imageData, source} = getImageData(window, context);
|
||||||
@ -86,6 +94,9 @@
|
|||||||
var canvas = original.cloneNode(true);
|
var canvas = original.cloneNode(true);
|
||||||
context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
|
context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
|
||||||
context.putImageData(imageData, 0, 0);
|
context.putImageData(imageData, 0, 0);
|
||||||
|
if (prefs("useCanvasCache")){
|
||||||
|
canvasCache[originalDataURL] = canvas;
|
||||||
|
}
|
||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
catch (e){
|
catch (e){
|
||||||
|
@ -139,6 +139,15 @@ document.body.appendChild(table);
|
|||||||
"blockMode": ["fakeReadout"]
|
"blockMode": ["fakeReadout"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "useCanvasCache",
|
||||||
|
"title": "Use canvas cache",
|
||||||
|
"type": "bool",
|
||||||
|
"value": true,
|
||||||
|
"displayDependencies": {
|
||||||
|
"blockMode": ["fakeReadout"]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "askOnlyOnce",
|
"name": "askOnlyOnce",
|
||||||
"title": "Ask only once",
|
"title": "Ask only once",
|
||||||
|
@ -16,6 +16,7 @@ Version 0.4.0:
|
|||||||
* setting to enable the inspection of the content of the faked canvas
|
* setting to enable the inspection of the content of the faked canvas
|
||||||
* new random number generator "constant"
|
* new random number generator "constant"
|
||||||
* setting to not fake the most frequent colors in a canvas
|
* setting to not fake the most frequent colors in a canvas
|
||||||
|
* setting to enable canvas cache
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- ask mode did not work for input types
|
- ask mode did not work for input types
|
||||||
|
Loading…
x
Reference in New Issue
Block a user