diff --git a/_locales/de/messages.json b/_locales/de/messages.json index e7bef6a..1bb3553 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -672,11 +672,11 @@ "description": "" }, "whitelistOnlyAPI": { - "message": "Erlaube nur die \"{api}\" API.", + "message": "Erlaube nur die {api}", "description": "" }, "whitelistAllAPIs": { - "message": "Erlaube alle APIs.", + "message": "Erlaube alle APIs", "description": "" }, "settings": { @@ -811,6 +811,10 @@ "message": "temporär erlauben", "description": "" }, + "inspectWhitelist": { + "message": "Erlaubnisse ansehen", + "description": "" + }, "sessionWhiteList_title": { "message": "Sitzungs-Whitelist", "description": "" @@ -959,6 +963,10 @@ "message": "Maximale Länge der Browser-History, die der Webseite mitgeteilt wird.", "description": "" }, + "historyLengthThreshold_urlSpecific": { + "message": "Um diesen Wert für bestimmte Seiten zu ändern, klicken Sie auf den schwarzen Pfeil um das Menü zu öffnen, fügen Sie die gewünschte Domain oder URL mit einem Klick auf \"+\" hinzu und geben Sie dort einen anderen Wert ein.", + "description": "" + }, "protectWindow_title": { "message": "Window-API beschützen", "description": "" @@ -1003,6 +1011,10 @@ "message": "Dies ermöglicht Änderungen an der Navigator-API. Diesen Schutz zu aktivieren ändert standardmäßig noch nichts. Öffnen Sie die Navigatoreinstellungen um die gewünschten Änderungen durchzuführen.", "description": "" }, + "protectNavigator_urlSpecific": { + "message": "Um bestimmte Seiten von diesem Schutz auszuschließen, klicken Sie auf den schwarzen Pfeil um das Menü zu öffnen, fügen Sie die gewünschte Domain oder URL mit einem Klick auf \"+\" hinzu und entfernen Sie das zugehörige Häkchen.", + "description": "" + }, "openNavigatorSettings_title": { "message": "Navigatoreinstellungen", "description": "" @@ -1159,6 +1171,10 @@ "message": "Laden", "description": "" }, + "inspectWhitelist_label": { + "message": "Erlaubnisse ansehen", + "description": "" + }, "resetSettings_title": { "message": "Einstellungen zurücksetzen", "description": "" @@ -1306,5 +1322,13 @@ "sanitation_error.doNotSharePersistentRndBetweenDomains": { "message": "Teilen Sie die persistenten Zufallszahlen nicht zwischen Domains, da dies den Browser 100% eindeutig identifizierbar macht.", "description": "" + }, + "whitelist_inspection_title": { + "message": "CanvasBlocker Erlaubnisse ansehen", + "description": "" + }, + "whitelist_all_apis": { + "message": "Alle APIs", + "description": "" } } \ No newline at end of file diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a84eef4..84136aa 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -706,11 +706,11 @@ "description": "" }, "whitelistOnlyAPI": { - "message": "Whitelist only the API \"{api}\".", + "message": "Whitelist only the {api}", "description": "" }, "whitelistAllAPIs": { - "message": "Whitelist all APIs.", + "message": "Whitelist all APIs", "description": "" }, "settings": { @@ -845,6 +845,10 @@ "message": "whitelist temporarily", "description": "" }, + "inspectWhitelist": { + "message": "inspect whitelist", + "description": "" + }, "sessionWhiteList_title": { "message": "Session whitelist", @@ -999,6 +1003,10 @@ "message": "Maximal length of the history that is reported to the website.", "description": "" }, + "historyLengthThreshold_urlSpecific": { + "message": "To change this value for specific websites, click on the black arrow to open the menu, add the domain or URL by clicking on \"+\" and set a different value.", + "description": "" + }, "protectWindow_title": { "message": "Protect window API", @@ -1047,6 +1055,10 @@ "message": "This page allows for changes in the navigator API. Enabling this protection does not change anything by default. Open the navigator settings to specify the changes you want to have there.", "description": "" }, + "protectNavigator_urlSpecific": { + "message": "To exclude specific websites from this protection, click on the black arrow to open the menu, add the domain or URL by clicking on \"+\" and remove its checkmark.", + "description": "" + }, "openNavigatorSettings_title": { "message": "Navigator settings", @@ -1212,6 +1224,10 @@ "message": "Load", "description": "" }, + "inspectWhitelist_label": { + "message": "Inspect whitelist", + "description": "" + }, "resetSettings_title": { "message": "Reset settings", @@ -1362,5 +1378,14 @@ "sanitation_error.doNotSharePersistentRndBetweenDomains": { "message": "Do not share persistent randomness between domains because this makes the browser 100% trackable.", "description": "" + }, + + "whitelist_inspection_title": { + "message": "CanvasBlocker whitelist inspection", + "description": "" + }, + "whitelist_all_apis": { + "message": "All APIs", + "description": "" } } diff --git a/icons/pageAction-inspectWhitelist.svg b/icons/pageAction-inspectWhitelist.svg new file mode 100644 index 0000000..a39f293 --- /dev/null +++ b/icons/pageAction-inspectWhitelist.svg @@ -0,0 +1,78 @@ + + + + + + + + + + image/svg+xml + + + + + + + www. + + + + diff --git a/lib/settingDefinitions.js b/lib/settingDefinitions.js index 40a7587..a0c3f44 100644 --- a/lib/settingDefinitions.js +++ b/lib/settingDefinitions.js @@ -310,7 +310,8 @@ }, { name: "protectNavigator", - defaultValue: false + defaultValue: false, + urlSpecific: true }, { name: "navigatorDetails", diff --git a/options/options.js b/options/options.js index 1bfb461..70e23b5 100644 --- a/options/options.js +++ b/options/options.js @@ -56,6 +56,10 @@ link.click(); document.body.removeChild(link); }, + inspectWhitelist: function(){ + logging.verbose("open whitelist inspection"); + window.open("whitelist.html", "_blank"); + }, loadSettings: function(){ logging.verbose("load settings"); new Promise(function(resolve, reject){ diff --git a/options/settingsDisplay.js b/options/settingsDisplay.js index 3711183..93d4b15 100644 --- a/options/settingsDisplay.js +++ b/options/settingsDisplay.js @@ -538,7 +538,7 @@ }, { "name": "exportSettings", - "actions": ["inspectSettings", "saveSettings", "loadSettings"] + "actions": ["inspectSettings", "inspectWhitelist", "saveSettings", "loadSettings"] }, { "name": "resetSettings" diff --git a/options/whitelist.html b/options/whitelist.html new file mode 100644 index 0000000..4061e01 --- /dev/null +++ b/options/whitelist.html @@ -0,0 +1,18 @@ + + + + CanvasBlocker whitelist inspection + + + + + + + + + + + + + + \ No newline at end of file diff --git a/options/whitelist.js b/options/whitelist.js new file mode 100644 index 0000000..4f540d6 --- /dev/null +++ b/options/whitelist.js @@ -0,0 +1,132 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +(function(){ + "use strict"; + + const extension = require("../lib/extension"); + const settings = require("../lib/settings"); + const settingContainers = require("../lib/settingContainers"); + require("../lib/theme").init(); + const searchParameters = new URLSearchParams(window.location.search); + + + var title = document.createElement("h1"); + title.className = "title"; + title.textContent = extension.getTranslation("whitelist_inspection_title"); + document.body.appendChild(title); + + document.querySelector("head title").textContent = title.textContent; + + settings.onloaded(function(){ + const sets = settingContainers.urlContainer.get(); + + const setSelect = document.createElement("select"); + sets.forEach(function(set){ + setSelect.appendChild(new Option(set.url)); + }); + document.body.appendChild(setSelect); + + if (searchParameters.has("urls")){ + const urls = JSON.parse(searchParameters.get("urls")).map(function(url){ + return new URL(url); + }); + if ( + !sets.some(function(set, index){ + if (urls.some(function(url){ + return set.match && set.match(url); + })){ + setSelect.selectedIndex = index; + return true; + } + }) && + searchParameters.has("domain") + ){ + setSelect.appendChild(new Option(searchParameters.get("domain"))); + setSelect.selectedIndex = setSelect.options.length - 1; + } + } + + const whitelistSettings = [ + { + title: extension.getTranslation("whitelist_all_apis"), + name: "blockMode", + whitelistValue: "allow", + protectedValue: "fake" + }, + { + title: extension.getTranslation("section_canvas-api"), + name: "protectedCanvasPart", + whitelistValue: "nothing", + protectedValue: "readout" + }, + { + title: extension.getTranslation("section_audio-api"), + name: "protectAudio", + whitelistValue: false, + protectedValue: true + }, + { + title: extension.getTranslation("section_history-api"), + name: "historyLengthThreshold", + whitelistValue: 10000, + protectedValue: 2 + }, + { + title: extension.getTranslation("section_window-api"), + name: "protectWindow", + whitelistValue: false, + protectedValue: true + }, + { + title: extension.getTranslation("section_DOMRect-api"), + name: "protectDOMRect", + whitelistValue: false, + protectedValue: true + }, + { + title: extension.getTranslation("section_navigator-api"), + name: "protectNavigator", + whitelistValue: false, + protectedValue: true + }, + ]; + + const table = document.createElement("table"); + whitelistSettings.forEach(function(setting){ + const row = document.createElement("tr"); + setting.row = row; + const name = document.createElement("td"); + name.textContent = setting.title || extension.getTranslation(setting.name + "_title"); + row.appendChild(name); + setting.input = document.createElement("input"); + setting.input.type = "checkbox"; + setting.input.addEventListener("change", function(){ + settings.set( + setting.name, + this.checked? setting.protectedValue: setting.whitelistValue, + setSelect.value + ); + }); + const input = document.createElement("td"); + input.appendChild(setting.input); + row.appendChild(input); + table.appendChild(row); + }); + document.body.appendChild(table); + + function update(){ + whitelistSettings.forEach(function(setting){ + setting.row.style.display = settings.get(setting.name) === setting.whitelistValue? + "none": + ""; + + const currentValue = settings.get(setting.name, setSelect.value); + setting.input.checked = currentValue !== setting.whitelistValue; + }); + } + update(); + setSelect.addEventListener("change", update); + settings.on("any", update); + }); +}()); \ No newline at end of file diff --git a/pageAction/pageAction.js b/pageAction/pageAction.js index 3399c64..09edacf 100644 --- a/pageAction/pageAction.js +++ b/pageAction/pageAction.js @@ -128,16 +128,6 @@ extension.getTranslation("selectWhitelist"), extension.getTranslation("inputWhitelistURL") ).then(function(choice){ - const allAPIs = { - choice, - setting: "blockMode", - settingValue: "allow" - }; - const onlyAPI = { - choice, - setting: whitelistingSettings[api], - settingValue: false - }; if ( api && whitelistingSettings[api] @@ -147,7 +137,10 @@ [ { text: extension.getTranslation("whitelistOnlyAPI") - .replace(/\{api\}/g, api), + .replace( + /\{api\}/g, + extension.getTranslation("section_" + api + "-api") + ), value: api }, { @@ -194,6 +187,21 @@ } }); } + }, + { + name: "inspectWhitelist", + isIcon: true, + callback: function({domain, urls}){ + window.open( + browser.extension.getURL( + "options/whitelist.html?domain=" + + encodeURIComponent(domain) + + "&urls=" + + encodeURIComponent(JSON.stringify(Array.from(urls.values()))) + ), + "_blank" + ); + } } ].forEach(function(domainAction){ domainNotification.addAction(domainAction); diff --git a/releaseNotes.txt b/releaseNotes.txt index 7867948..3bc66c3 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -2,6 +2,7 @@ Version 0.5.9: changes: - code cleanup - made history length threshold url specific + - made navigator protection url specific - uniform themes new features: @@ -12,6 +13,8 @@ Version 0.5.9: - added option to protect no part of the canvas API - apply themes to all extension pages (options, page action, browser action, setting sanitation, setting inspection, navigator settings) - theme for automatic detection of dark mode (only works with Firefox >= 67) + - within the page action the used API can be whitelisted alone + - added overview page for whitelist fixes: - search could show hidden settings