diff --git a/misc/userscripts/qute-keepassxc b/misc/userscripts/qute-keepassxc index d5970cfed..2c14d22f6 100755 --- a/misc/userscripts/qute-keepassxc +++ b/misc/userscripts/qute-keepassxc @@ -365,18 +365,34 @@ 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'); + for (const frame of iframes) { + if (fillFirstForm(frame.contentDocument, false)) return true; + } + return false; + } + + 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))