From 4635a203a4c7ee198cc6ca5368a17d9c608c9ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20L=C3=B3pez?= Date: Wed, 15 Sep 2021 13:10:12 +0200 Subject: [PATCH 1/2] add settings section for clearing browser history Minimal version of the settings pane to clear browsing history. Sadly, the functionality is not there: 1. First attempt was to use `places.deleteAllHistory()` but it's not available in this scope and I can't use require/import to fetch it 2. Tried using directly postMessage as places internally does but that postMessage within places is directed to the particular worker so this didn't work either Also used inline styles which should be migrated to some stylesheet, but just wanted to put a quick PoC together to ask for pointers when it comes to actually clearing the DB of its stored URLs. --- localization/languages/en-US.json | 3 +++ pages/settings/index.html | 12 ++++++++++++ pages/settings/settings.js | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/localization/languages/en-US.json b/localization/languages/en-US.json index ac4578569..c295517ce 100644 --- a/localization/languages/en-US.json +++ b/localization/languages/en-US.json @@ -176,6 +176,9 @@ "settingsProxyRules": "Proxy rules:", "settingsProxyBypassRules": "No proxy for:", "settingsProxyConfigurationURL": "Configuration URL", + "settingsHistoryEraseNow": "Clear browsing history now", + "settingsHistoryHeading": "Privacy and history", + "settingsDeleteHistory": "Are you sure you want to delete all browsing history?", /* app menu */ "appMenuFile": "File", "appMenuNewTab": "New Tab", diff --git a/pages/settings/index.html b/pages/settings/index.html index f0d39774d..6992294a7 100644 --- a/pages/settings/index.html +++ b/pages/settings/index.html @@ -77,6 +77,18 @@

+
+

+
+ +
+ +
+

diff --git a/pages/settings/settings.js b/pages/settings/settings.js index bfd5e2ec2..3ed4734af 100644 --- a/pages/settings/settings.js +++ b/pages/settings/settings.js @@ -181,6 +181,24 @@ for (var contentType in contentTypes) { })(contentType) } +/* Privacy and history */ + +var clearHistoryButton = document.getElementById("clear-history-now") +clearHistoryButton.addEventListener("click", () => { + const confirmedDeletion = confirm(l('settingsDeleteHistory')) + if (confirmedDeletion) { + try { + // Nuke history here with places.deleteAllHistory() ?? + // postMessage({ message: { action: 'deleteAllHistory' } }) + window.alert("Your browsing history has been erased.") + } catch (e) { + window.alert("There was an error clearing your history.") + } + } else { + return + } +}) + /* dark mode setting */ var darkModeNever = document.getElementById('dark-mode-never') var darkModeNight = document.getElementById('dark-mode-night') From 0e198115b325be372b50d21407aafcff289122eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20L=C3=B3pez?= Date: Wed, 15 Sep 2021 13:20:10 +0200 Subject: [PATCH 2/2] add checkbox in settings to erase browsing history on browser exit --- localization/languages/en-US.json | 1 + pages/settings/index.html | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/localization/languages/en-US.json b/localization/languages/en-US.json index c295517ce..b10f34c9d 100644 --- a/localization/languages/en-US.json +++ b/localization/languages/en-US.json @@ -179,6 +179,7 @@ "settingsHistoryEraseNow": "Clear browsing history now", "settingsHistoryHeading": "Privacy and history", "settingsDeleteHistory": "Are you sure you want to delete all browsing history?", + "settingsDeleteHistoryOnClose": "Erase browsing history when closing the browser", /* app menu */ "appMenuFile": "File", "appMenuNewTab": "New Tab", diff --git a/pages/settings/index.html b/pages/settings/index.html index 6992294a7..a5fa04870 100644 --- a/pages/settings/index.html +++ b/pages/settings/index.html @@ -84,7 +84,14 @@

style="border-radius: 4px; padding: 8px; background: black; color: white;" data-string="settingsHistoryEraseNow" id="clear-history-now"> - + +
+
+ +