From 79ff6f3469f50f44c22b0b83134908838ba5d6a1 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Wed, 8 May 2019 13:02:37 +0300 Subject: [PATCH] Fix auto-submit --- .../content/keepassxc-browser.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 3e1e2a6..1d7de91 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -1328,12 +1328,26 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) { } } + // Get the form submit button instead if action URL is same as the page itself + function getSubmitButton(form) { + if (kpxc.submitUrl === document.location.origin + document.location.pathname) { + for (const i of form.elements) { + if (i.type === 'submit') { + return i; + } + } + } + return undefined; + } + // Auto-submit if (kpxc.settings.autoSubmit) { - if (kpxc.u.form) { - kpxc.u.form.submit(); - } else if (kpxc.p.form) { - kpxc.u.form.submit(); + const form = kpxc.u.form || kpxc.p.form; + const submitButton = getSubmitButton(form); + if (submitButton !== undefined) { + submitButton.click(); + } else { + form.submit(); } } };