From 855ac20ed564716aafbd5c326c94dc8494d90e80 Mon Sep 17 00:00:00 2001 From: Aleksandr Kolbasov Date: Sat, 22 Nov 2025 19:19:56 +0300 Subject: [PATCH] "Reopen database" shortcut --- dist/manifest_chromium.json | 3 +++ dist/manifest_firefox.json | 3 +++ keepassxc-browser/background/init.js | 3 ++- keepassxc-browser/content/keepassxc-browser.js | 7 ++++++- keepassxc-browser/manifest.json | 3 +++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dist/manifest_chromium.json b/dist/manifest_chromium.json index 93a1d4e..e0448be 100755 --- a/dist/manifest_chromium.json +++ b/dist/manifest_chromium.json @@ -124,6 +124,9 @@ "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 1a4d993..d4f8d4a 100644 --- a/dist/manifest_firefox.json +++ b/dist/manifest_firefox.json @@ -137,6 +137,9 @@ "request_autotype": { "description": "__MSG_contextMenuRequestGlobalAutoType__" }, + "reopen_database": { + "description": "__MSG_popupReopenButton__" + }, "reload_extension": { "description": "__MSG_popupReloadButton__" } diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js index e584956..050bfe7 100644 --- a/keepassxc-browser/background/init.js +++ b/keepassxc-browser/background/init.js @@ -110,6 +110,7 @@ const initListeners = async function() { || command === 'redetect_fields' || command === 'choose_credential_fields' || command === 'retrive_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 5a16bc2..f7ea8be 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' ) { @@ -955,6 +955,11 @@ 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') { diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json index 93a1d4e..e0448be 100755 --- a/keepassxc-browser/manifest.json +++ b/keepassxc-browser/manifest.json @@ -124,6 +124,9 @@ "request_autotype": { "description": "__MSG_contextMenuRequestGlobalAutoType__" }, + "reopen_database": { + "description": "__MSG_popupReopenButton__" + }, "reload_extension": { "description": "__MSG_popupReloadButton__" }