mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
parent
3b14e56537
commit
a8611230b1
@ -1,3 +1,21 @@
|
||||
setting[pref-name="rng"] {
|
||||
border-bottom: 0px transparent none;
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
setting[pref-name="storePersistentRnd"]{
|
||||
border-top: 0px transparent none;
|
||||
border-bottom: 0px transparent none;
|
||||
}
|
||||
setting[pref-name="persistentRndStorage"]{
|
||||
border-top: 0px transparent none;
|
||||
border-bottom: 0px transparent none;
|
||||
display: none;
|
||||
}
|
||||
setting[pref-name="clearPersistentRnd"]{
|
||||
border-top: 0px transparent none;
|
||||
border-bottom: 0px transparent none;
|
||||
}
|
||||
|
||||
setting[pref-name="showNotifications"] {
|
||||
border-bottom: 0px transparent none;
|
||||
padding-top: 0.5em;
|
||||
|
39
lib/main.js
39
lib/main.js
@ -39,18 +39,49 @@
|
||||
});
|
||||
|
||||
// persistent rng
|
||||
const persistentRnd = Object.create(null);
|
||||
var persistentRnd = Object.create(null);
|
||||
try {
|
||||
let storedData = JSON.parse(prefs.persistentRndStorage);
|
||||
for (var domain in storedData){
|
||||
var value = storedData[domain];
|
||||
if (
|
||||
Array.isArray(value) &&
|
||||
value.length === 128 &&
|
||||
value.every(function(value){return typeof value === "number" && value >= 0 && value < 256;})
|
||||
){
|
||||
persistentRnd[domain] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
|
||||
processes.port.on("canvasBlocker-new-domain-rnd", function(process, data){
|
||||
processes.port.emit("canvasBlocker-set-domain-rnd", data);
|
||||
persistentRnd[data.domain] = data.rnd;
|
||||
if (prefs.storePersistentRnd){
|
||||
prefs.persistentRndStorage = JSON.stringify(persistentRnd);
|
||||
}
|
||||
});
|
||||
processes.on("attach", function(process){
|
||||
processes.forEvery(function(process){
|
||||
if (process.isRemote){
|
||||
for (var name in persistentRnd){
|
||||
process.port.emit("canvasBlocker-set-domain-rnd", {domain: name, rnd: persistentRnd[name]});
|
||||
for (var domain in persistentRnd){
|
||||
process.port.emit("canvasBlocker-set-domain-rnd", {domain, rnd: persistentRnd[domain]});
|
||||
}
|
||||
}
|
||||
});
|
||||
preferences.on("storePersistentRnd", function(){
|
||||
if (prefs.storePersistentRnd){
|
||||
prefs.persistentRndStorage = JSON.stringify(persistentRnd);
|
||||
}
|
||||
else {
|
||||
prefs.persistentRndStorage = "";
|
||||
}
|
||||
});
|
||||
preferences.on("clearPersistentRnd", function(){
|
||||
persistentRnd = Object.create(null);
|
||||
prefs.persistentRndStorage = "";
|
||||
processes.port.emit("canvasBlocker-clear-domain-rnd");
|
||||
});
|
||||
|
||||
// show release notes
|
||||
var data = require("sdk/self").data;
|
||||
|
@ -17,19 +17,23 @@
|
||||
return window.location.host;
|
||||
}
|
||||
const getPersistentRnd = (function(){
|
||||
var persistentRnd = Object.create(null);
|
||||
|
||||
const {process} = require("sdk/remote/child");
|
||||
process.port.on("canvasBlocker-set-domain-rnd", function(process, {domain, rnd}){
|
||||
persistentRnd[domain] = new Uint8Array(rnd);
|
||||
});
|
||||
process.port.on("canvasBlocker-clear-domain-rnd", function(){
|
||||
persistentRnd = Object.create(null);
|
||||
});
|
||||
|
||||
const persistentRnd = Object.create(null);
|
||||
return function getPersistentRnd(window){
|
||||
var domain = getDomain(window);
|
||||
if (!persistentRnd[domain]){
|
||||
// create the (sub-)domains random numbers if not existing
|
||||
persistentRnd[domain] = new Uint8Array(128);
|
||||
window.crypto.getRandomValues(persistentRnd[domain]);
|
||||
process.port.emit("canvasBlocker-new-domain-rnd", {domain, rnd: persistentRnd[domain]});
|
||||
process.port.emit("canvasBlocker-new-domain-rnd", {domain, rnd: Array.from(persistentRnd[domain])});
|
||||
}
|
||||
return persistentRnd[domain];
|
||||
}
|
||||
|
@ -31,6 +31,16 @@
|
||||
"rng_options.persistent": "persistent",
|
||||
"rng_options.non persistent": "nicht persistent",
|
||||
"rng_title": "Zufallszahlengenerator",
|
||||
|
||||
"persistentRndStorage_title": "Persistenter Speicher",
|
||||
"persistentRndStorage_description": "Speichert die Informationen für den persistenten Zufallszahlengenerator über einen Neustart hinweg.",
|
||||
|
||||
"storePersistentRnd_title": "Persistente Daten speichern",
|
||||
"storePersistentRnd_description": "Ob Daten für den persistenten Zufallszahlengenerator gespeichert werden sollen.",
|
||||
|
||||
"clearPersistentRnd_title": "Persistenten Speicher leeren",
|
||||
"clearPersistentRnd_description": "Löscht alle Daten für den persistenten Zufallszahlengenerator.",
|
||||
"clearPersistentRnd_label": "Leeren",
|
||||
|
||||
"disableNotifications": "Benachrichtigungen deaktivieren",
|
||||
"displayCallingStack": "Aufrufestack anzeigen",
|
||||
|
@ -29,8 +29,18 @@
|
||||
|
||||
"rng_description": "",
|
||||
"rng_options.persistent": "persistent",
|
||||
"rng.non persistent": "non persistent",
|
||||
"rng_options.non persistent": "non persistent",
|
||||
"rng_title": "Random number generator",
|
||||
|
||||
"persistentRndStorage_title": "Persistent storage",
|
||||
"persistentRndStorage_description": "Stores the data for the persistent random number generator for usage after restart.",
|
||||
|
||||
"storePersistentRnd_title": "Store persistent data",
|
||||
"storePersistentRnd_description": "If data for the persistent random number generator should be stored.",
|
||||
|
||||
"clearPersistentRnd_title": "Clear persistent random storage",
|
||||
"clearPersistentRnd_description": "Deletes all data for the persistent random number generator.",
|
||||
"clearPersistentRnd_label": "Clear",
|
||||
|
||||
"disableNotifications": "disable notifications",
|
||||
"displayCallingStack": "display calling stack",
|
||||
|
18
package.json
18
package.json
@ -94,6 +94,24 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "persistentRndStorage",
|
||||
"title": "Persistent storage",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "storePersistentRnd",
|
||||
"title": "Store persistent data",
|
||||
"type": "bool",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "clearPersistentRnd",
|
||||
"title": "Clear persistent random storage",
|
||||
"type": "control",
|
||||
"label": "Clear"
|
||||
},
|
||||
{
|
||||
"name": "askOnlyOnce",
|
||||
"title": "Ask only once",
|
||||
|
@ -3,7 +3,7 @@ Version 0.3.7:
|
||||
-
|
||||
|
||||
new features:
|
||||
-
|
||||
- data for persistent random number generator can be stored
|
||||
|
||||
fixes:
|
||||
- fake at input was broken
|
||||
|
Loading…
x
Reference in New Issue
Block a user