mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-05-19 19:02:21 +02:00
Added "constant" rng.
This commit is contained in:
parent
4cb91462f7
commit
9da251b14d
@ -133,13 +133,17 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"rng_description": {
|
"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": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"rng_options.persistent": {
|
"rng_options.persistent": {
|
||||||
"message": "persistent",
|
"message": "persistent",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
"rng_options.constant": {
|
||||||
|
"message": "konstant",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"rng_options.non persistent": {
|
"rng_options.non persistent": {
|
||||||
"message": "nicht persistent",
|
"message": "nicht persistent",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -133,13 +133,17 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"rng_description": {
|
"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": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"rng_options.persistent": {
|
"rng_options.persistent": {
|
||||||
"message": "persistent",
|
"message": "persistent",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
"rng_options.constant": {
|
||||||
|
"message": "constant",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"rng_options.non persistent": {
|
"rng_options.non persistent": {
|
||||||
"message": "non persistent",
|
"message": "non persistent",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -7,7 +7,7 @@ var settings = {
|
|||||||
blockMode: "fakeReadout",
|
blockMode: "fakeReadout",
|
||||||
minFakeSize: 1,
|
minFakeSize: 1,
|
||||||
maxFakeSize: 0,
|
maxFakeSize: 0,
|
||||||
rng: "nonPersistent",
|
rng: "constant",
|
||||||
persistentRndStorage: "",
|
persistentRndStorage: "",
|
||||||
storePersistentRnd: false,
|
storePersistentRnd: false,
|
||||||
askOnlyOnce: true,
|
askOnlyOnce: true,
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
case "persistent":
|
case "persistent":
|
||||||
setRandomSupply(randomSupplies.persistent);
|
setRandomSupply(randomSupplies.persistent);
|
||||||
break;
|
break;
|
||||||
|
case "constant":
|
||||||
|
setRandomSupply(randomSupplies.constant);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
setRandomSupply(randomSupplies.nonPersistent);
|
setRandomSupply(randomSupplies.nonPersistent);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
var index = String.fromCharCode(r, g, b, a);
|
var index = String.fromCharCode(r, g, b, a);
|
||||||
if (ignoredColors[index]){
|
if (ignoredColors[index]){
|
||||||
return [r, g, b, a];
|
return [r, g, b, a];
|
||||||
}
|
}
|
||||||
var baseIndex = i * 4;
|
var baseIndex = i * 4;
|
||||||
return [
|
return [
|
||||||
rng(r, baseIndex + 0),
|
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 = {
|
scope.nonPersistent = {
|
||||||
getRng: function(length, window){
|
getRng: function(length, window){
|
||||||
// Initialize the random number batch creation
|
// Initialize the random number batch creation
|
||||||
|
@ -97,6 +97,10 @@ document.body.appendChild(table);
|
|||||||
"value": "nonPersistent",
|
"value": "nonPersistent",
|
||||||
"label": "non persistent"
|
"label": "non persistent"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"value": "constant",
|
||||||
|
"label": "constant"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"value": "persistent",
|
"value": "persistent",
|
||||||
"label": "persistent"
|
"label": "persistent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user