mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Added setting for canvas cache.
This commit is contained in:
parent
f853071d19
commit
48dc965f7c
@ -193,6 +193,15 @@
|
||||
"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": {
|
||||
"message": "Benachrichtigungen deaktivieren",
|
||||
"description": ""
|
||||
|
@ -193,6 +193,15 @@
|
||||
"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": {
|
||||
"message": "disable notifications",
|
||||
"description": ""
|
||||
|
@ -7,7 +7,8 @@ var settings = {
|
||||
blockMode: "fakeReadout",
|
||||
minFakeSize: 1,
|
||||
maxFakeSize: 0,
|
||||
rng: "constant",
|
||||
rng: "nonPersistent",
|
||||
useCanvasCache: true,
|
||||
ignoreFrequentColors: 0,
|
||||
persistentRndStorage: "",
|
||||
storePersistentRnd: false,
|
||||
|
@ -54,8 +54,16 @@
|
||||
};
|
||||
}
|
||||
|
||||
var canvasCache = Object.create(null);
|
||||
function getFakeCanvas(window, original, prefs){
|
||||
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
|
||||
var context = getContext(window, original);
|
||||
var {imageData, source} = getImageData(window, context);
|
||||
@ -86,6 +94,9 @@
|
||||
var canvas = original.cloneNode(true);
|
||||
context = window.HTMLCanvasElement.prototype.getContext.call(canvas, "2d");
|
||||
context.putImageData(imageData, 0, 0);
|
||||
if (prefs("useCanvasCache")){
|
||||
canvasCache[originalDataURL] = canvas;
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
catch (e){
|
||||
|
@ -139,6 +139,15 @@ document.body.appendChild(table);
|
||||
"blockMode": ["fakeReadout"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "useCanvasCache",
|
||||
"title": "Use canvas cache",
|
||||
"type": "bool",
|
||||
"value": true,
|
||||
"displayDependencies": {
|
||||
"blockMode": ["fakeReadout"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "askOnlyOnce",
|
||||
"title": "Ask only once",
|
||||
|
@ -16,6 +16,7 @@ Version 0.4.0:
|
||||
* setting to enable the inspection of the content of the faked canvas
|
||||
* new random number generator "constant"
|
||||
* setting to not fake the most frequent colors in a canvas
|
||||
* setting to enable canvas cache
|
||||
|
||||
fixes:
|
||||
- ask mode did not work for input types
|
||||
|
Loading…
x
Reference in New Issue
Block a user