mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 12:06:31 +02:00
First working webExtesion.
This commit is contained in:
parent
4ea073132d
commit
cba5680406
9 changed files with 266 additions and 310 deletions
|
@ -5,6 +5,15 @@
|
|||
(function(){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
else {
|
||||
window.scope.randomSupplies = {};
|
||||
scope = window.scope.randomSupplies;
|
||||
}
|
||||
|
||||
function getDomain(window){
|
||||
if (!window.location.href || window.location.href === "about:blank"){
|
||||
if (window !== window.parent){
|
||||
|
@ -19,12 +28,14 @@
|
|||
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);
|
||||
browser.runtime.onMessage.addListener(function(data){
|
||||
if (data["canvasBlocker-set-domain-rnd"]){
|
||||
var {domain, rnd} = data["canvasBlocker-set-domain-rnd"];
|
||||
persistentRnd[domain] = new Uint8Array(rnd);
|
||||
}
|
||||
if (data["canvasBlocker-clear-domain-rnd"]){
|
||||
persistentRnd = Object.create(null);
|
||||
}
|
||||
});
|
||||
|
||||
return function getPersistentRnd(window){
|
||||
|
@ -33,12 +44,12 @@
|
|||
// 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: Array.from(persistentRnd[domain])});
|
||||
browser.runtime.sendMessage({"canvasBlocker-new-domain-rnd": {domain, rnd: Array.from(persistentRnd[domain])}});
|
||||
}
|
||||
return persistentRnd[domain];
|
||||
}
|
||||
}());
|
||||
exports.persistent = {
|
||||
scope.persistent = {
|
||||
getRng: function(length, window){
|
||||
var bitSet = getPersistentRnd(window);
|
||||
|
||||
|
@ -60,7 +71,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
exports.nonPersistent = {
|
||||
scope.nonPersistent = {
|
||||
getRng: function(length, window){
|
||||
// Initialize the random number batch creation
|
||||
var randomI = 65536;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue