diff --git a/lib/persistentRndStorage.js b/lib/persistentRndStorage.js index 515edb7..9aa1a79 100644 --- a/lib/persistentRndStorage.js +++ b/lib/persistentRndStorage.js @@ -58,6 +58,12 @@ settings.on("storePersistentRnd", function({newValue}){ settings.persistentRndStorage = newValue? JSON.stringify(scope.persistentRnd): ""; }); + + logging.message("register contextual identities removal"); + browser.contextualIdentities.onRemoved.addListener(function(details){ + logging.message("Contextual identity", details.contextualIdentity.cookieStoreId, "removed."); + clearContainerData(details.contextualIdentity.cookieStoreId); + }); }; const getInterval = function(){ @@ -133,7 +139,33 @@ } broadcast({"canvasBlocker-set-domain-rnd": {domain, incognito, rnd}}); } - + function clearDomainData(domain){ + logging.verbose("clear domain rnd for ", domain); + delete scope.persistentIncognitoRnd[domain]; + settings.persistentIncognitoRndStorage = JSON.stringify(scope.persistentIncognitoRnd); + delete scope.persistentRnd[domain]; + settings.persistentRndStorage = JSON.stringify(scope.persistentRnd); + } + + function clearContainerData(cookieStoreId){ + logging.verbose("clear container rnd for ", cookieStoreId); + Object.keys(scope.persistentRnd).forEach(function(domain){ + if (domain.startsWith(cookieStoreId + "@")){ + delete scope.persistentRnd[domain]; + } + }); + settings.persistentRndStorage = JSON.stringify(scope.persistentRnd); + + Object.keys(scope.persistentIncognitoRnd).forEach(function(domain){ + if (domain.startsWith(cookieStoreId + "@")){ + delete scope.persistentIncognitoRnd[domain]; + } + }); + settings.persistentIncognitoRndStorage = JSON.stringify(scope.persistentIncognitoRnd); + } + scope.clear = clear; scope.setDomainData = setDomainData; + scope.clearDomainData = clearDomainData; + scope.clearContainerData = clearContainerData; }()); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 13c8d2d..c5d71d4 100644 --- a/manifest.json +++ b/manifest.json @@ -88,6 +88,7 @@ "activeTab", "webRequest", "webRequestBlocking", + "contextualIdentities", "cookies" ], diff --git a/releaseNotes.txt b/releaseNotes.txt index 7cf1dc4..f760273 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -5,6 +5,7 @@ Version 0.5.11: new features: - added auto update for beta versions - options: made sections collapsible + - clear persistent rng data if a container is deleted fixes: - improved protection of (i)frame properties