diff --git a/keepassxc-browser/_locales/en/messages.json b/keepassxc-browser/_locales/en/messages.json index a05f447..15f1ffc 100644 --- a/keepassxc-browser/_locales/en/messages.json +++ b/keepassxc-browser/_locales/en/messages.json @@ -779,6 +779,14 @@ "message": "An HTTP Basic Auth dialog looks like this:", "description": "HTTP Basic Auth image help text." }, + "optionsClearCredentialsTimeout": { + "message": "Clear credentials from non-active tabs after (seconds, 0-3600).", + "description": "Clear credentials label text." + }, + "optionsClearCredentialsTimeoutHelpText": { + "message": "Credentials are cleared from background tabs after the timeout and permissions for those pages will be asked again.", + "description": "Clear credentials timeout help text." + }, "optionsVersionInfoText": { "message": "KeePassXC-Browser needs KeePassXC to retrieve credentials.", "description": "Settings page version info text." diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js index 96338c9..126b8b4 100755 --- a/keepassxc-browser/background/page.js +++ b/keepassxc-browser/background/page.js @@ -9,6 +9,7 @@ const defaultSettings = { autoRetrieveCredentials: true, autoSubmit: false, checkUpdateKeePassXC: 3, + clearCredentialsTimeout: 10, colorTheme: 'system', credentialSorting: SORT_BY_GROUP_AND_TITLE, defaultGroup: '', @@ -27,6 +28,7 @@ const defaultSettings = { var page = {}; page.attributeMenuItemIds = []; page.blockedTabs = []; +page.clearCredentialsTimeout = null; page.currentRequest = {}; page.currentTabId = -1; page.loginId = -1; @@ -83,6 +85,10 @@ page.initSettings = async function() { page.settings.colorTheme = defaultSettings.colorTheme; } + if (!('clearCredentialsTimeout' in page.settings)) { + page.settings.clearCredentialsTimeout = defaultSettings.clearCredentialsTimeout; + } + if (!('credentialSorting' in page.settings)) { page.settings.credentialSorting = defaultSettings.credentialSorting; } @@ -177,12 +183,18 @@ page.initSitePreferences = async function() { }; page.switchTab = async function(tab) { + // Clears Fill Attribute selection from context menu browser.contextMenus.update('fill_attribute', { visible: false }); - if (page.tabs[tab.id] - && page.tabs[tab.id].credentials.length > 0 - && page.tabs[tab.id].credentials.some(e => e.stringFields && e.stringFields.length > 0)) { - await page.updateContextMenu(tab, page.tabs[tab.id].credentials); - } + + // Clears all logins from other tabs after a timeout + clearTimeout(page.clearCredentialsTimeout); + page.clearCredentialsTimeout = setTimeout(() => { + for (const pageTabId of Object.keys(page.tabs)) { + if (tab.id !== Number(pageTabId)) { + page.clearCredentials(Number(pageTabId), true); + } + } + }, page.settings.clearCredentialsTimeout * 1000); browserAction.showDefault(tab); browser.tabs.sendMessage(tab.id, { action: 'activated_tab' }).catch((e) => { diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index f0eff41..23e2f61 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -6,7 +6,6 @@ const _maximumMutations = 200; // Contains already called method names const _called = {}; _called.automaticRedetectCompleted = false; -_called.clearLogins = false; _called.retrieveCredentials = false; // Wrapper @@ -1289,9 +1288,6 @@ kpxc.initCombinations = async function(inputs = []) { // The main function for finding input fields kpxc.initCredentialFields = async function() { - await sendMessage('page_clear_logins', _called.clearLogins); - _called.clearLogins = true; - // Identify all forms in the page const formInputs = await kpxc.identifyFormInputs(); diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html index 37d812e..fa49abf 100644 --- a/keepassxc-browser/options/options.html +++ b/keepassxc-browser/options/options.html @@ -36,7 +36,7 @@ @@ -48,12 +48,15 @@

+
+ +
+
@@ -71,6 +75,7 @@
+
@@ -80,6 +85,7 @@
+
@@ -88,6 +94,7 @@
+
@@ -98,6 +105,7 @@
+
@@ -118,12 +126,15 @@
+
+ +
@@ -132,6 +143,7 @@
+
@@ -140,6 +152,7 @@
+
@@ -160,6 +173,7 @@
+
@@ -172,6 +186,7 @@
+
@@ -184,12 +199,15 @@
+
+ +
@@ -197,6 +215,7 @@
+
@@ -205,6 +224,7 @@
+
@@ -217,6 +237,7 @@
+
@@ -225,6 +246,7 @@
+
@@ -233,6 +255,7 @@
+
@@ -275,11 +298,14 @@
+
+ +
@@ -289,6 +315,7 @@
+
@@ -301,6 +328,7 @@
+
@@ -313,6 +341,7 @@
+
@@ -321,6 +350,7 @@
+
@@ -331,9 +361,20 @@
+ + +
+
+ +
+ + +
+
+
@@ -610,6 +651,7 @@ Bart Libert David Walluscheck + yuriyk
diff --git a/keepassxc-browser/options/options.js b/keepassxc-browser/options/options.js index 40c1885..33c4cc6 100644 --- a/keepassxc-browser/options/options.js +++ b/keepassxc-browser/options/options.js @@ -123,6 +123,16 @@ options.initGeneralSettings = function() { $('#tab-general-settings select#credentialSorting').val(options.settings['credentialSorting']); $('#tab-general-settings input#defaultGroup').val(options.settings['defaultGroup']); + $('#tab-general-settings input#clearCredentialTimeout').val(options.settings['clearCredentialsTimeout']); + $('#tab-general-settings input#clearCredentialTimeout').change(async function(e) { + if (e.target.valueAsNumber < 0 || e.target.valueAsNumber > 3600) { + return; + } + + options.settings['clearCredentialsTimeout'] = e.target.valueAsNumber; + await options.saveSettings(); + }); + $('#tab-general-settings input[type=radio]').each(function() { if ($(this).val() === String(options.settings[$(this).attr('name')])) { $(this).attr('checked', options.settings[$(this).attr('name')]);