From 1872e4bd3418d178ed5c29400df697f7d959217b Mon Sep 17 00:00:00 2001 From: varjolintu Date: Mon, 26 Oct 2020 19:51:42 +0200 Subject: [PATCH] Add input with submit type --- keepassxc-browser/content/keepassxc-browser.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index 211aa39..75529e8 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -134,7 +134,7 @@ kpxcIcons.switchIcons = function() { * Identifies form submits and password changes. */ const kpxcForm = {}; -kpxcForm.formButtonQuery = 'button[type=\'button\'], button[type=\'submit\'], input[type=\'button\'], button:not([type]), div[role=\'button\']'; +kpxcForm.formButtonQuery = 'button[type=\'button\'], button[type=\'submit\'], input[type=\'button\'], input[type=\'submit\'], button:not([type]), div[role=\'button\']'; kpxcForm.savedForms = []; // Returns true if form has been already saved @@ -176,16 +176,17 @@ kpxcForm.getFormSubmitButton = function(form) { } } - // Try to find another button. Select the first one. + // Try to find another button. Select the last one. + // TODO: Possibly change this behavior to select the last one for only certain sites. const buttons = Array.from(form.querySelectorAll(kpxcForm.formButtonQuery)); if (buttons.length > 0) { - return buttons[0]; + return buttons[buttons.length - 1]; } // Try to find similar buttons outside the form which are added via 'form' property for (const e of form.elements) { if ((e.nodeName === 'BUTTON' && (e.type === 'button' || e.type === 'submit' || e.type === '')) - || (e.nodeName === 'INPUT' && e.type === 'button')) { + || (e.nodeName === 'INPUT' && (e.type === 'button' || e.type === 'submit'))) { return e; } }