From f473c2b8130df147aa08c1893f86d30ad3b955aa Mon Sep 17 00:00:00 2001 From: Somedumbguy Date: Wed, 11 Dec 2024 20:15:22 -0500 Subject: [PATCH 1/3] search iframes for forms if none are found in root document --- misc/userscripts/qute-keepassxc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/misc/userscripts/qute-keepassxc b/misc/userscripts/qute-keepassxc index d5970cfed..9747c1ecb 100755 --- a/misc/userscripts/qute-keepassxc +++ b/misc/userscripts/qute-keepassxc @@ -365,18 +365,35 @@ def make_js_code(username, password): } }; - function fillFirstForm() { - var forms = document.getElementsByTagName("form"); + function checkForIframeForms(doc, recursive = true) { + doc || (doc = document); + const iframes = doc.getElementsByTagName('iframe'); + const success = []; + for (const frame of iframes) { + success.push(fillFirstForm(frame.contentDocument, false)); + } + return !!success.filter(Boolean).length; + } + + function fillFirstForm(doc, recursive = true) { + doc || (doc = document); + var forms = doc.getElementsByTagName("form"); + let success = false; for (i = 0; i < forms.length; i++) { if (hasPasswordField(forms[i])) { loadData2Form(forms[i]); - return; + return true; } } - alert("No Credentials Form found"); + if (recursive) success = checkForIframeForms(doc, false); + return success; }; - fillFirstForm() + function findAndFillFirstForm () { + if (!fillFirstForm()) { alert("No Credentials Form found"); } + }; + + findAndFillFirstForm() """.splitlines()) % (json.dumps(username), json.dumps(password)) From 68df3f88214162ce7c7ae66a0e7fa9727192693f Mon Sep 17 00:00:00 2001 From: Somedumbguy Date: Thu, 12 Dec 2024 09:04:57 -0500 Subject: [PATCH 2/3] actually stop filling forms after one is found --- misc/userscripts/qute-keepassxc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/userscripts/qute-keepassxc b/misc/userscripts/qute-keepassxc index 9747c1ecb..cba50b3ae 100755 --- a/misc/userscripts/qute-keepassxc +++ b/misc/userscripts/qute-keepassxc @@ -368,11 +368,10 @@ def make_js_code(username, password): function checkForIframeForms(doc, recursive = true) { doc || (doc = document); const iframes = doc.getElementsByTagName('iframe'); - const success = []; for (const frame of iframes) { - success.push(fillFirstForm(frame.contentDocument, false)); + if (fillFirstForm(frame.contentDocument, false)) return true; // stop filling forms } - return !!success.filter(Boolean).length; + return false; } function fillFirstForm(doc, recursive = true) { From 002e7ad85177eaa142fc263cc06f563ca0f14e32 Mon Sep 17 00:00:00 2001 From: Somedumbguy Date: Sat, 14 Dec 2024 16:23:58 -0500 Subject: [PATCH 3/3] removed comment on end of line --- misc/userscripts/qute-keepassxc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/userscripts/qute-keepassxc b/misc/userscripts/qute-keepassxc index cba50b3ae..2c14d22f6 100755 --- a/misc/userscripts/qute-keepassxc +++ b/misc/userscripts/qute-keepassxc @@ -369,7 +369,7 @@ def make_js_code(username, password): doc || (doc = document); const iframes = doc.getElementsByTagName('iframe'); for (const frame of iframes) { - if (fillFirstForm(frame.contentDocument, false)) return true; // stop filling forms + if (fillFirstForm(frame.contentDocument, false)) return true; } return false; }