mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-04 05:08:06 +02:00
autofill updates to support multiple forms on same page
This commit is contained in:
parent
c81968043a
commit
5d269884d4
@ -38,14 +38,13 @@ function initAutofill() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registration forms often have 2 password fields
|
for (i = 0; i < passwordFieldsForForm.length; i++) {
|
||||||
if (passwordFieldsForForm.length === 1) {
|
pf = passwordFieldsForForm[i];
|
||||||
pf = passwordFieldsForForm[0];
|
|
||||||
passwords.push(pf);
|
passwords.push(pf);
|
||||||
|
|
||||||
if (fillUsername) {
|
if (fillUsername) {
|
||||||
for (i = 0; i < pageDetails.fields.length; i++) {
|
for (var j = 0; j < pageDetails.fields.length; j++) {
|
||||||
f = pageDetails.fields[i];
|
f = pageDetails.fields[j];
|
||||||
if (f.form === pf.form && (f.type === 'text' || f.type === 'email' || f.type === 'tel')
|
if (f.form === pf.form && (f.type === 'text' || f.type === 'email' || f.type === 'tel')
|
||||||
&& f.elementNumber < pf.elementNumber) {
|
&& f.elementNumber < pf.elementNumber) {
|
||||||
username = f;
|
username = f;
|
||||||
@ -59,8 +58,8 @@ function initAutofill() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passwordFields.length === 1 && !passwords.length) {
|
if (passwordFields.length && !passwords.length) {
|
||||||
// The page does not have any forms with password fields. Use the one password field on the page and the
|
// The page does not have any forms with password fields. Use the first password field on the page and the
|
||||||
// input field just before it as the username.
|
// input field just before it as the username.
|
||||||
|
|
||||||
pf = passwordFields[0];
|
pf = passwordFields[0];
|
||||||
@ -82,10 +81,6 @@ function initAutofill() {
|
|||||||
if (username) {
|
if (username) {
|
||||||
usernames.push(username);
|
usernames.push(username);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// As a last resort use the field just before the password
|
|
||||||
usernames.push(pageDetails.fields[pf.elementNumber - 1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user