diff --git a/_locales/de/messages.json b/_locales/de/messages.json index ffb9ef4..c079ec0 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -491,6 +491,14 @@ "message": "Leeren", "description": "" }, + "clearPersistentRndForContainer_label": { + "message": "Container leeren", + "description": "" + }, + "clearPersistentRndForContainer_title": { + "message": "Container auswählen", + "description": "" + }, "sharePersistentRndBetweenDomains_title": { "message": "Persistente Zufallszahlen zwischen Domains teilen", "description": "" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 6b41820..12bde38 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -515,6 +515,14 @@ "message": "Clear", "description": "" }, + "clearPersistentRndForContainer_label": { + "message": "Clear container", + "description": "" + }, + "clearPersistentRndForContainer_title": { + "message": "Select container", + "description": "" + }, "sharePersistentRndBetweenDomains_title": { "message": "Share persistent randomness between domains", diff --git a/lib/main.js b/lib/main.js index a90186a..4ed055c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,6 +41,12 @@ return; } } + if (data["canvasBlocker-clear-container-rnd"]){ + persistentRndStorage.clearContainerData(data["canvasBlocker-clear-container-rnd"]); + if (keys.length === 1){ + return; + } + } notice("pass the message to the tabs"); browser.tabs.query({}).then(function(tabs){ tabs.forEach(function(tab){ diff --git a/lib/modal.js b/lib/modal.js index 31584d7..7c5fb6c 100644 --- a/lib/modal.js +++ b/lib/modal.js @@ -118,6 +118,8 @@ window.addEventListener("scroll", positionDialog); window.addEventListener("resize", positionDialog); } + + return container; } scope.confirm = function(text, parent){ @@ -128,4 +130,22 @@ ], parent); }); }; + + scope.select = function(text, options, parent){ + return new Promise(function(resolve, reject){ + const select = document.createElement("select"); + options.forEach(function(option){ + const optionNode = document.createElement("option"); + optionNode.text = option.name; + optionNode.object = option.object; + select.appendChild(optionNode); + }); + + const container = openDialog(text, [ + {text: extension.getTranslation("cancel"), default: true, callback: ()=>reject(false)}, + {text: extension.getTranslation("OK"), focused: true, callback: ()=>resolve(select.options[select.selectedIndex].object)} + ], parent); + container.querySelector(".text").insertAdjacentElement("afterend", select); + }); + }; }()); \ No newline at end of file diff --git a/options/options.js b/options/options.js index 454d91e..bb637d0 100644 --- a/options/options.js +++ b/options/options.js @@ -34,6 +34,21 @@ logging.notice("send message to main script"); extension.message.send({"canvasBlocker-clear-domain-rnd": true}); }, + clearPersistentRndForContainer: function(){ + browser.contextualIdentities.query({}).then(function(identities){ + modal.select( + extension.getTranslation("clearPersistentRndForContainer_title"), + identities.map(function(identity){ + return { + name: `${identity.name} (${identity.cookieStoreId})`, + object: identity + }; + }) + ).then(function(identity){ + extension.message.send({"canvasBlocker-clear-container-rnd": identity.cookieStoreId}); + }, ()=>{}); + }); + }, inspectSettings: function(){ logging.verbose("open settings inspection"); window.open("export.html", "_blank"); diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 93d4b15..73bce9c 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -85,6 +85,7 @@ }, { "name": "clearPersistentRnd", + "actions": ["clearPersistentRnd", "clearPersistentRndForContainer"], "displayDependencies": [ { "blockMode": ["fake"], diff --git a/releaseNotes.txt b/releaseNotes.txt index f760273..a0fa4dc 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -6,6 +6,7 @@ Version 0.5.11: - added auto update for beta versions - options: made sections collapsible - clear persistent rng data if a container is deleted + - added tool to clear persistent rng for a specific container fixes: - improved protection of (i)frame properties