1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-02-07 11:14:37 +01:00

Added "constant" rng.

This commit is contained in:
kkapsner 2017-08-07 17:43:57 +02:00
parent 4cb91462f7
commit 9da251b14d
6 changed files with 49 additions and 4 deletions

View File

@ -133,13 +133,17 @@
},
"rng_description": {
"message": "nicht persistent: die Zufallszahlen werden bei jeder Vortäuschaktion neu bestimmt.\npersistent: für jede Domain werden die Zufallszahlen nur einmal bestimmt.",
"message": "nicht persistent: die Zufallszahlen werden bei jeder Vortäuschaktion neu bestimmt.\nkonstant: innerhalb einer Webseite wird eine Farbe immer gleich verändert.\npersistent: für jede Domain werden die Zufallszahlen nur einmal bestimmt.",
"description": ""
},
"rng_options.persistent": {
"message": "persistent",
"description": ""
},
"rng_options.constant": {
"message": "konstant",
"description": ""
},
"rng_options.non persistent": {
"message": "nicht persistent",
"description": ""

View File

@ -133,13 +133,17 @@
},
"rng_description": {
"message": "non persistent: the random numbers will be determined freshly for each faking action.\npersistent: the random number will only be determined once for every domain.",
"message": "non persistent: the random numbers will be determined freshly for each faking action.\nconstant: within one web page a color will always be faked to the same color.\npersistent: the random number will only be determined once for every domain.",
"description": ""
},
"rng_options.persistent": {
"message": "persistent",
"description": ""
},
"rng_options.constant": {
"message": "constant",
"description": ""
},
"rng_options.non persistent": {
"message": "non persistent",
"description": ""

View File

@ -7,7 +7,7 @@ var settings = {
blockMode: "fakeReadout",
minFakeSize: 1,
maxFakeSize: 0,
rng: "nonPersistent",
rng: "constant",
persistentRndStorage: "",
storePersistentRnd: false,
askOnlyOnce: true,

View File

@ -25,6 +25,9 @@
case "persistent":
setRandomSupply(randomSupplies.persistent);
break;
case "constant":
setRandomSupply(randomSupplies.constant);
break;
default:
setRandomSupply(randomSupplies.nonPersistent);
}

View File

@ -75,7 +75,7 @@
var index = String.fromCharCode(r, g, b, a);
if (ignoredColors[index]){
return [r, g, b, a];
}
}
var baseIndex = i * 4;
return [
rng(r, baseIndex + 0),
@ -87,6 +87,36 @@
}
};
scope.constant = {
getRng: function(length, window){
return scope.nonPersistent.getRng(length, window);
},
getPixelRng: (function(){
var colors = Object.create(null);
return function getConstantPixelRng(length, window, ignoredColors){
var rng = scope.nonPersistent.getRng(1024, window);
return function(r, g, b, a, i){
var index = String.fromCharCode(r, g, b, a);
if (ignoredColors[index]){
return [r, g, b, a];
}
var color = colors[index];
if (!color){
color = [
rng(r, 0),
rng(g, 0),
rng(b, 0),
rng(a, 0)
];
colors[index] = color;
}
return color;
};
};
}())
};
scope.nonPersistent = {
getRng: function(length, window){
// Initialize the random number batch creation

View File

@ -97,6 +97,10 @@ document.body.appendChild(table);
"value": "nonPersistent",
"label": "non persistent"
},
{
"value": "constant",
"label": "constant"
},
{
"value": "persistent",
"label": "persistent"