Some login forms require selecting a domain in addition to providing
username and password. An example would be the OpenStack login form.
---
content/content.js | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/content/content.js b/content/content.js
index b26609f..dbb847d 100644
--- a/content/content.js
+++ b/content/content.js
@@ -5,6 +5,11 @@ browser.runtime.onMessage.addListener(msg => {
};
});
+function findElement(form, name) {
+ const selector = `input[name="${name}"],select[name="${name}"]`;
+ return form.querySelector(selector);
+}
+
function handleAutofill(msg) {
const form = findForm(msg.key);
if (form === null) {
@@ -15,7 +20,7 @@ function handleAutofill(msg) {
if (pair.key === "proto" || pair.key === "host") {
return;
};
- const input = form.querySelector(`input[name="${pair.key}"]`);
+ const input = findElement(form, pair.key);
input.value = pair.value;
});
}
@@ -32,7 +37,7 @@ function findForm(key) {
if (pair.optional) {
return;
}
- const input = form.querySelector(`input[name="${pair.key}"]`);
+ const input = findElement(form, pair.key);
if (input === null) {
valid = false;
}
--
2.36.2