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