From 29991bf8ea72f60a81aca5bddbbeb9b84cb1319c Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 16 Sep 2023 10:51:56 +0300 Subject: [PATCH 1/2] Use active element on fillFromCombination() --- keepassxc-browser/content/fill.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/keepassxc-browser/content/fill.js b/keepassxc-browser/content/fill.js index f9e3ac9..b6ca1e7 100644 --- a/keepassxc-browser/content/fill.js +++ b/keepassxc-browser/content/fill.js @@ -30,26 +30,26 @@ kpxcFill.fillInFromActiveElement = async function(passOnly = false) { return; } + const elem = document.activeElement; if (kpxc.combinations.length > 0) { - if (await kpxcFill.fillFromCombination(passOnly)) { + if (await kpxcFill.fillFromCombination(elem, passOnly)) { // Combination found and filled return; } } // No previous combinations detected. Create a new one from active element - const el = document.activeElement; - const combination = await kpxc.createCombination(el, passOnly); + const combination = await kpxc.createCombination(elem, passOnly); await sendMessage('page_set_login_id', kpxc.credentials[0].uuid); kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly); }; // Fill from combination, if found -kpxcFill.fillFromCombination = async function(passOnly) { +kpxcFill.fillFromCombination = async function(elem, passOnly) { const combination = passOnly - ? kpxc.combinations.find(c => c.password) - : kpxc.combinations.find(c => c.username); + ? kpxc.combinations.find(c => c.password === elem) + : kpxc.combinations.find(c => c.username === elem); if (!combination) { logDebug('Error: No combination found.'); return false; From b836cf6223595585483cdf4a0b7f44a73d9069fa Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 16 Sep 2023 17:24:13 +0300 Subject: [PATCH 2/2] Modify error message --- keepassxc-browser/content/fill.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keepassxc-browser/content/fill.js b/keepassxc-browser/content/fill.js index b6ca1e7..cb3f3e6 100644 --- a/keepassxc-browser/content/fill.js +++ b/keepassxc-browser/content/fill.js @@ -51,7 +51,7 @@ kpxcFill.fillFromCombination = async function(elem, passOnly) { ? kpxc.combinations.find(c => c.password === elem) : kpxc.combinations.find(c => c.username === elem); if (!combination) { - logDebug('Error: No combination found.'); + logDebug('Error: No username/password field combination found.'); return false; }