diff --git a/_locales/de/messages.json b/_locales/de/messages.json index 2bfcb64..86d7204 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -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": "" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index c0f41d1..040160f 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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": "" diff --git a/lib/defaultSettings.js b/lib/defaultSettings.js index adbdaa4..2950937 100644 --- a/lib/defaultSettings.js +++ b/lib/defaultSettings.js @@ -7,7 +7,7 @@ var settings = { blockMode: "fakeReadout", minFakeSize: 1, maxFakeSize: 0, - rng: "nonPersistent", + rng: "constant", persistentRndStorage: "", storePersistentRnd: false, askOnlyOnce: true, diff --git a/lib/intercept.js b/lib/intercept.js index 30433c6..256b714 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -25,6 +25,9 @@ case "persistent": setRandomSupply(randomSupplies.persistent); break; + case "constant": + setRandomSupply(randomSupplies.constant); + break; default: setRandomSupply(randomSupplies.nonPersistent); } diff --git a/lib/randomSupplies.js b/lib/randomSupplies.js index eabef49..26587c6 100644 --- a/lib/randomSupplies.js +++ b/lib/randomSupplies.js @@ -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 diff --git a/options/buildPrefInputs.js b/options/buildPrefInputs.js index 3ac783c..58d989a 100644 --- a/options/buildPrefInputs.js +++ b/options/buildPrefInputs.js @@ -97,6 +97,10 @@ document.body.appendChild(table); "value": "nonPersistent", "label": "non persistent" }, + { + "value": "constant", + "label": "constant" + }, { "value": "persistent", "label": "persistent"