From 1dc3dcd38c99aab98703f48915a68a1f94d25f03 Mon Sep 17 00:00:00 2001 From: Aleksandr Kolbasov Date: Sun, 4 Jan 2026 10:26:53 +0300 Subject: [PATCH] "Reopen database" shortcut (#2767) "Reopen database" shortcut --- dist/manifest_chromium.json | 7 +++++-- dist/manifest_firefox.json | 7 +++++-- keepassxc-browser/_locales/en/messages.json | 4 ++++ keepassxc-browser/background/init.js | 5 +++-- keepassxc-browser/content/keepassxc-browser.js | 9 +++++++-- keepassxc-browser/manifest.json | 7 +++++-- keepassxc-browser/popups/popup.js | 2 +- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dist/manifest_chromium.json b/dist/manifest_chromium.json index 23e7f88..aa49167 100755 --- a/dist/manifest_chromium.json +++ b/dist/manifest_chromium.json @@ -119,12 +119,15 @@ "choose_credential_fields": { "description": "__MSG_popupChooseCredentialsText__" }, - "retrive_credentials_forced": { - "description": "__MSG_popupReopenButton__" + "retrieve_credentials_forced": { + "description": "__MSG_credentialsRetrieveButton__" }, "request_autotype": { "description": "__MSG_contextMenuRequestGlobalAutoType__" }, + "reopen_database": { + "description": "__MSG_popupReopenButton__" + }, "reload_extension": { "description": "__MSG_popupReloadButton__" } diff --git a/dist/manifest_firefox.json b/dist/manifest_firefox.json index 31ffefb..2153e08 100644 --- a/dist/manifest_firefox.json +++ b/dist/manifest_firefox.json @@ -132,12 +132,15 @@ "choose_credential_fields": { "description": "__MSG_popupChooseCredentialsText__" }, - "retrive_credentials_forced": { - "description": "__MSG_popupReopenButton__" + "retrieve_credentials_forced": { + "description": "__MSG_credentialsRetrieveButton__" }, "request_autotype": { "description": "__MSG_contextMenuRequestGlobalAutoType__" }, + "reopen_database": { + "description": "__MSG_popupReopenButton__" + }, "reload_extension": { "description": "__MSG_popupReloadButton__" } diff --git a/keepassxc-browser/_locales/en/messages.json b/keepassxc-browser/_locales/en/messages.json index 41a9d52..e9763ed 100644 --- a/keepassxc-browser/_locales/en/messages.json +++ b/keepassxc-browser/_locales/en/messages.json @@ -406,6 +406,10 @@ "message": "Expired", "description": "If a credential is expired, this is appended to the title label." }, + "credentialsRetrieveButton": { + "message": "Retrieve credentials", + "description": "Manual retrieve credentials button text." + }, "fieldsFill": { "message": "Error: Cannot find fields to fill in.", "description": "Alert message when no fields are found to fill in." diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js index e584956..bafb6e4 100644 --- a/keepassxc-browser/background/init.js +++ b/keepassxc-browser/background/init.js @@ -109,7 +109,8 @@ const initListeners = async function() { if (contextMenuItems.some(e => e.action === command) || command === 'redetect_fields' || command === 'choose_credential_fields' - || command === 'retrive_credentials_forced' + || command === 'retrieve_credentials_forced' + || command === 'reopen_database' || command === 'reload_extension') { const tab = await getCurrentTab(); if (tab?.id) { @@ -172,7 +173,7 @@ const initContextMenuItems = async function() { }); } catch (e) { logError(e); - } + } } }; diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 031cf18..e935887 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -837,7 +837,7 @@ kpxc.usePredefinedSites = function(currentLocation) { * Content script initialization. */ const initContentScript = async function() { - try { + try { if (document?.documentElement?.ownerDocument?.contentType !== 'text/html' && document?.documentElement?.ownerDocument?.contentType !== 'application/xhtml+xml' ) { @@ -960,9 +960,14 @@ browser.runtime.onMessage.addListener(async function(req, sender) { kpxc.initCredentialFields(); } else if (req.action === 'reload_extension') { sendMessage('reconnect'); + } else if (req.action === 'reopen_database') { + sendMessage( + 'get_status', + [ false, true ] // Set forcePopup to true + ); } else if (req.action === 'save_credentials') { kpxc.rememberCredentialsFromContextMenu(); - } else if (req.action === 'retrive_credentials_forced') { + } else if (req.action === 'retrieve_credentials_forced') { await kpxc.retrieveCredentials(true); } else if (req.action === 'show_password_generator') { kpxcPasswordGenerator.showPasswordGenerator(); diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json index 23e7f88..aa49167 100755 --- a/keepassxc-browser/manifest.json +++ b/keepassxc-browser/manifest.json @@ -119,12 +119,15 @@ "choose_credential_fields": { "description": "__MSG_popupChooseCredentialsText__" }, - "retrive_credentials_forced": { - "description": "__MSG_popupReopenButton__" + "retrieve_credentials_forced": { + "description": "__MSG_credentialsRetrieveButton__" }, "request_autotype": { "description": "__MSG_contextMenuRequestGlobalAutoType__" }, + "reopen_database": { + "description": "__MSG_popupReopenButton__" + }, "reload_extension": { "description": "__MSG_popupReloadButton__" } diff --git a/keepassxc-browser/popups/popup.js b/keepassxc-browser/popups/popup.js index 2823284..7bd02f2 100644 --- a/keepassxc-browser/popups/popup.js +++ b/keepassxc-browser/popups/popup.js @@ -87,7 +87,7 @@ const sendMessageToTab = async function(message) { }); // This does not work with Firefox because of https://bugzilla.mozilla.org/show_bug.cgi?id=1665380 - await sendMessageToTab('retrive_credentials_forced'); + await sendMessageToTab('retrieve_credentials_forced'); close(); });