mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
separate persistent random numbers for incognito windows
This commit is contained in:
parent
7f1fe0ed1c
commit
9b18631768
12
lib/frame.js
12
lib/frame.js
@ -56,12 +56,14 @@
|
|||||||
notice("my tab id is", data.tabId);
|
notice("my tab id is", data.tabId);
|
||||||
tabId = data.tabId;
|
tabId = data.tabId;
|
||||||
}
|
}
|
||||||
if (data.hasOwnProperty("persistentRnd")){
|
const persistentRndName = "persistent" + (browser.extension.inIncognitoContext? "Incognito": "") + "Rnd";
|
||||||
notice("got persistent random data", data.persistentRnd);
|
if (data.hasOwnProperty(persistentRndName)){
|
||||||
|
const persistentRndValue = data[persistentRndName];
|
||||||
|
notice("got persistent random data", persistentRndValue);
|
||||||
const {persistent: persistentRnd} = require("./randomSupplies.js");
|
const {persistent: persistentRnd} = require("./randomSupplies.js");
|
||||||
Object.keys(data.persistentRnd).forEach(function(domain){
|
Object.keys(persistentRndValue).forEach(function(domain){
|
||||||
verbose("random data for", domain, data.persistentRnd[domain]);
|
verbose("random data for", domain, persistentRndValue[domain]);
|
||||||
persistentRnd.setDomainRnd(domain, data.persistentRnd[domain]);
|
persistentRnd.setDomainRnd(domain, persistentRndValue[domain]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
if (data["canvasBlocker-new-domain-rnd"]){
|
if (data["canvasBlocker-new-domain-rnd"]){
|
||||||
persistentRndStorage.setDomainData(
|
persistentRndStorage.setDomainData(
|
||||||
data["canvasBlocker-new-domain-rnd"].domain,
|
data["canvasBlocker-new-domain-rnd"].domain,
|
||||||
|
data["canvasBlocker-new-domain-rnd"].incognito,
|
||||||
data["canvasBlocker-new-domain-rnd"].rnd
|
data["canvasBlocker-new-domain-rnd"].rnd
|
||||||
);
|
);
|
||||||
if (keys.length === 1){
|
if (keys.length === 1){
|
||||||
@ -55,7 +56,8 @@
|
|||||||
verbose("send back the persistent random seeds", persistentRndStorage.persistentRnd);
|
verbose("send back the persistent random seeds", persistentRndStorage.persistentRnd);
|
||||||
port.postMessage({
|
port.postMessage({
|
||||||
tabId: port.sender.tab.id,
|
tabId: port.sender.tab.id,
|
||||||
persistentRnd: persistentRndStorage.persistentRnd
|
persistentRnd: persistentRndStorage.persistentRnd,
|
||||||
|
persistentIncognitoRnd: persistentRndStorage.persistentIncognitoRnd
|
||||||
});
|
});
|
||||||
var url = new URL(port.sender.url);
|
var url = new URL(port.sender.url);
|
||||||
port.onMessage.addListener(function(data){
|
port.onMessage.addListener(function(data){
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
|
|
||||||
scope.persistentRnd = Object.create(null);
|
scope.persistentRnd = Object.create(null);
|
||||||
|
scope.persistentIncognitoRnd = Object.create(null);
|
||||||
scope.init = function init(){
|
scope.init = function init(){
|
||||||
logging.message("initializing persistent rng storage");
|
logging.message("initializing persistent rng storage");
|
||||||
|
|
||||||
@ -75,6 +76,16 @@
|
|||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
browser.windows.onRemoved.addListener(function(){
|
||||||
|
browser.windows.getAll().then(function(windows){
|
||||||
|
if (windows.every(function(window){
|
||||||
|
return !window.incognito;
|
||||||
|
})){
|
||||||
|
clearIncognito();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
let clearTimeout;
|
let clearTimeout;
|
||||||
function registerTimeout(){
|
function registerTimeout(){
|
||||||
var interval = getInterval();
|
var interval = getInterval();
|
||||||
@ -98,19 +109,30 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function clearIncognito(){
|
||||||
|
scope.persistentIncognitoRnd = Object.create(null);
|
||||||
|
settings.persistentIncognitoRndStorage = JSON.stringify(scope.persistentIncognitoRnd);
|
||||||
|
}
|
||||||
function clear(){
|
function clear(){
|
||||||
logging.verbose("domain rnd cleared");
|
logging.verbose("domain rnd cleared");
|
||||||
scope.persistentRnd = Object.create(null);
|
scope.persistentRnd = Object.create(null);
|
||||||
settings.persistentRndStorage = JSON.stringify(scope.persistentRnd);
|
settings.persistentRndStorage = JSON.stringify(scope.persistentRnd);
|
||||||
settings.lastPersistentRndClearing = Date.now();
|
settings.lastPersistentRndClearing = Date.now();
|
||||||
|
clearIncognito();
|
||||||
registerTimeout();
|
registerTimeout();
|
||||||
broadcast({"canvasBlocker-clear-domain-rnd": true});
|
broadcast({"canvasBlocker-clear-domain-rnd": true});
|
||||||
}
|
}
|
||||||
function setDomainData(domain, rnd){
|
function setDomainData(domain, incognito, rnd){
|
||||||
logging.verbose("got new domain rnd for ", domain, ":", rnd);
|
logging.verbose("got new domain rnd for ", domain, " (incognito:", incognito, "):", rnd);
|
||||||
|
if (incognito){
|
||||||
|
scope.persistentIncognitoRnd[domain] = rnd;
|
||||||
|
settings.persistentIncognitoRndStorage = JSON.stringify(scope.persistentIncognitoRnd);
|
||||||
|
}
|
||||||
|
else {
|
||||||
scope.persistentRnd[domain] = rnd;
|
scope.persistentRnd[domain] = rnd;
|
||||||
settings.persistentRndStorage = JSON.stringify(scope.persistentRnd);
|
settings.persistentRndStorage = JSON.stringify(scope.persistentRnd);
|
||||||
broadcast({"canvasBlocker-set-domain-rnd": {domain, rnd}});
|
}
|
||||||
|
broadcast({"canvasBlocker-set-domain-rnd": {domain, incognito, rnd}});
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.clear = clear;
|
scope.clear = clear;
|
||||||
|
@ -80,7 +80,11 @@
|
|||||||
var persistentRnd = Object.create(null);
|
var persistentRnd = Object.create(null);
|
||||||
settings.onloaded(function(){
|
settings.onloaded(function(){
|
||||||
try {
|
try {
|
||||||
let storedData = JSON.parse(settings.persistentRndStorage);
|
let storedData = JSON.parse(
|
||||||
|
browser.extension.inIncognitoContext?
|
||||||
|
settings.persistentIncognitoRndStorage:
|
||||||
|
settings.persistentRndStorage
|
||||||
|
);
|
||||||
for (var domain in storedData){
|
for (var domain in storedData){
|
||||||
var value = storedData[domain];
|
var value = storedData[domain];
|
||||||
if (
|
if (
|
||||||
@ -102,9 +106,11 @@
|
|||||||
|
|
||||||
browser.runtime.onMessage.addListener(function(data){
|
browser.runtime.onMessage.addListener(function(data){
|
||||||
if (data["canvasBlocker-set-domain-rnd"]){
|
if (data["canvasBlocker-set-domain-rnd"]){
|
||||||
var {domain, rnd} = data["canvasBlocker-set-domain-rnd"];
|
var {domain, incognito, rnd} = data["canvasBlocker-set-domain-rnd"];
|
||||||
|
if (incognito === browser.extension.inIncognitoContext){
|
||||||
persistentRnd[domain] = new Uint8Array(rnd);
|
persistentRnd[domain] = new Uint8Array(rnd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (data["canvasBlocker-clear-domain-rnd"]){
|
if (data["canvasBlocker-clear-domain-rnd"]){
|
||||||
persistentRnd = Object.create(null);
|
persistentRnd = Object.create(null);
|
||||||
}
|
}
|
||||||
@ -117,7 +123,11 @@
|
|||||||
persistentRnd[domain] = new Uint8Array(128);
|
persistentRnd[domain] = new Uint8Array(128);
|
||||||
window.crypto.getRandomValues(persistentRnd[domain]);
|
window.crypto.getRandomValues(persistentRnd[domain]);
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
"canvasBlocker-new-domain-rnd": {domain, rnd: Array.from(persistentRnd[domain])}
|
"canvasBlocker-new-domain-rnd": {
|
||||||
|
domain,
|
||||||
|
incognito: browser.extension.inIncognitoContext,
|
||||||
|
rnd: Array.from(persistentRnd[domain])
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return persistentRnd[domain];
|
return persistentRnd[domain];
|
||||||
|
@ -113,6 +113,11 @@
|
|||||||
name: "persistentRndStorage",
|
name: "persistentRndStorage",
|
||||||
defaultValue: ""
|
defaultValue: ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "persistentIncognitoRndStorage",
|
||||||
|
resetOnStartup: true,
|
||||||
|
defaultValue: ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "storePersistentRnd",
|
name: "storePersistentRnd",
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
|
@ -3,11 +3,13 @@ Version 0.5.2:
|
|||||||
-
|
-
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
-
|
- separate persistent random numbers for incognito windows
|
||||||
|
(resets when closing all incognito windows - like cookies do)
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- optimized CSP
|
- optimized CSP
|
||||||
- in Firefox ESR (52) iFrames with a blob-URL cannot be protected -> they have to be blocked there as well
|
- in Firefox ESR (52) iFrames with a blob-URL cannot be protected -> they have to be blocked there as well
|
||||||
|
- broken when using with Random Agent Spoofer
|
||||||
|
|
||||||
known issues:
|
known issues:
|
||||||
- if a data URL is blocked the page action button does not appear
|
- if a data URL is blocked the page action button does not appear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user