mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 03:56:26 +02:00
parent
3b14e56537
commit
a8611230b1
7 changed files with 99 additions and 8 deletions
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue