[PATCH himitsu-firefox] content: also try [autocomplete] to find inputs
Export this patch
Some websites (such as proton mail) don't use the [name] attribute
which caused autofill to fail.
---
content/content.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/content/content.js b/content/content.js
index bbd15eb..73b657d 100644
--- a/content/content.js
+++ b/content/content.js
@@ -15,7 +15,7 @@ function handleAutofill(msg) {
if (pair.key === "proto" || pair.key === "host") {
return;
};
- const input = form.querySelector(`input[name="${pair.key}"]`);
+ const input = findInput(form, pair.key);
input.click();
input.focus();
input.value = pair.value;
@@ -40,7 +40,7 @@ function findForm(key) {
if (pair.optional) {
return;
}
- const input = form.querySelector(`input[name="${pair.key}"]`);
+ const input = findInput(form, pair.key);
if (input === null) {
valid = false;
}
@@ -51,3 +51,11 @@ function findForm(key) {
}
return null;
}
+
+function findInput(elem, key) {
+ const input = elem.querySelector(`input[name="${key}"]`);
+ if (input !== null) {
+ return input;
+ }
+ return elem.querySelector(`input[autocomplete="${key}"]`);
+}
--
2.45.2
himitsu-firefox/patches/.build.yml: FAILED in 14s
[content: also try [autocomplete] to find inputs][0] from [tiosgz][1]
[0]: https://lists.sr.ht/~sircmpwn/himitsu-devel/patches/53936
[1]: mailto:alamica@protonmail.com
✗ #1277921 FAILED himitsu-firefox/patches/.build.yml https://builds.sr.ht/~sircmpwn/job/1277921
Thanks!
To git@git.sr.ht:~sircmpwn/himitsu-firefox
dd720ad..1fb4d56 master -> master