mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 12:06:31 +02:00
Reduced direct dependency on browser.xxx APIs
This commit is contained in:
parent
a9edf45aa8
commit
137c1688ba
7 changed files with 53 additions and 14 deletions
|
@ -63,6 +63,7 @@
|
|||
};
|
||||
|
||||
const settings = require("./settings");
|
||||
const extension = require("./extension");
|
||||
|
||||
function getDomain(window){
|
||||
if (settings.sharePersistentRndBetweenDomains){
|
||||
|
@ -83,7 +84,7 @@
|
|||
settings.onloaded(function(){
|
||||
try {
|
||||
let storedData = JSON.parse(
|
||||
browser.extension.inIncognitoContext?
|
||||
extension.inIncognitoContext?
|
||||
settings.persistentIncognitoRndStorage:
|
||||
settings.persistentRndStorage
|
||||
);
|
||||
|
@ -106,10 +107,10 @@
|
|||
});
|
||||
const getPersistentRnd = (function(){
|
||||
|
||||
browser.runtime.onMessage.addListener(function(data){
|
||||
extension.message.on(function(data){
|
||||
if (data["canvasBlocker-set-domain-rnd"]){
|
||||
var {domain, incognito, rnd} = data["canvasBlocker-set-domain-rnd"];
|
||||
if (incognito === browser.extension.inIncognitoContext){
|
||||
if (incognito === extension.inIncognitoContext){
|
||||
persistentRnd[domain] = new Uint8Array(rnd);
|
||||
}
|
||||
}
|
||||
|
@ -124,10 +125,10 @@
|
|||
// create the (sub-)domains random numbers if not existing
|
||||
persistentRnd[domain] = new Uint8Array(128);
|
||||
window.crypto.getRandomValues(persistentRnd[domain]);
|
||||
browser.runtime.sendMessage({
|
||||
extension.message.send({
|
||||
"canvasBlocker-new-domain-rnd": {
|
||||
domain,
|
||||
incognito: browser.extension.inIncognitoContext,
|
||||
incognito: extension.inIncognitoContext,
|
||||
rnd: Array.from(persistentRnd[domain])
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue