mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-25 16:59:17 +01:00
autofill fixes
This commit is contained in:
parent
1fa96620a7
commit
8dbb2ece42
@ -345,9 +345,9 @@
|
|||||||
el.dispatchEvent(doEventOnElement(el, 'keyup'));
|
el.dispatchEvent(doEventOnElement(el, 'keyup'));
|
||||||
event2.initEvent('input', true, true);
|
event2.initEvent('input', true, true);
|
||||||
el.dispatchEvent(event2);
|
el.dispatchEvent(event2);
|
||||||
event.initEvent('change', true, true);
|
event1.initEvent('change', true, true);
|
||||||
|
el.dispatchEvent(event1);
|
||||||
|
|
||||||
el.dispatchEvent(event);
|
|
||||||
el.blur();
|
el.blur();
|
||||||
el.value !== elValue && (el.value = elValue);
|
el.value !== elValue && (el.value = elValue);
|
||||||
});
|
});
|
||||||
|
@ -42,11 +42,11 @@ function initAutofill() {
|
|||||||
passwords.push(pf);
|
passwords.push(pf);
|
||||||
|
|
||||||
if (fillUsername) {
|
if (fillUsername) {
|
||||||
username = findUsernameField(pageDetails, pf, false);
|
username = findUsernameField(pageDetails, pf, false, false);
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||||
username = findUsernameField(pageDetails, pf, true);
|
username = findUsernameField(pageDetails, pf, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (username) {
|
if (username) {
|
||||||
@ -64,11 +64,11 @@ function initAutofill() {
|
|||||||
passwords.push(pf);
|
passwords.push(pf);
|
||||||
|
|
||||||
if (fillUsername && pf.elementNumber > 0) {
|
if (fillUsername && pf.elementNumber > 0) {
|
||||||
username = findUsernameFieldWithoutForm(pageDetails, pf, false);
|
username = findUsernameField(pageDetails, pf, false, true);
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||||
username = findUsernameFieldWithoutForm(pageDetails, pf, true);
|
username = findUsernameField(pageDetails, pf, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (username) {
|
if (username) {
|
||||||
@ -109,10 +109,10 @@ function initAutofill() {
|
|||||||
for (var i = 0; i < passwordFields.length; i++) {
|
for (var i = 0; i < passwordFields.length; i++) {
|
||||||
var pf = passwordFields[i];
|
var pf = passwordFields[i];
|
||||||
if (formKey === pf.form) {
|
if (formKey === pf.form) {
|
||||||
var uf = findUsernameField(pageDetails, pf, false);
|
var uf = findUsernameField(pageDetails, pf, false, false);
|
||||||
if (!uf) {
|
if (!uf) {
|
||||||
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
// not able to find any viewable username fields. maybe there are some "hidden" ones?
|
||||||
uf = findUsernameField(pageDetails, pf, true);
|
uf = findUsernameField(pageDetails, pf, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
formData.push({
|
formData.push({
|
||||||
@ -140,28 +140,16 @@ function initAutofill() {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findUsernameField(pageDetails, passwordField, canBeHidden) {
|
function findUsernameField(pageDetails, passwordField, canBeHidden, withoutForm) {
|
||||||
for (var i = 0; i < pageDetails.fields.length; i++) {
|
|
||||||
var f = pageDetails.fields[i];
|
|
||||||
if (f.form === passwordField.form && (canBeHidden || f.viewable)
|
|
||||||
&& (f.type === 'text' || f.type === 'email' || f.type === 'tel')
|
|
||||||
&& f.elementNumber < passwordField.elementNumber) {
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function findUsernameFieldWithoutForm(pageDetails, passwordField, canBeHidden) {
|
|
||||||
var usernameField = null;
|
var usernameField = null;
|
||||||
for (var i = 0; i < pageDetails.fields.length; i++) {
|
for (var i = 0; i < pageDetails.fields.length; i++) {
|
||||||
var f = pageDetails.fields[i];
|
var f = pageDetails.fields[i];
|
||||||
if (f.elementNumber > passwordField.elementNumber) {
|
if (f.elementNumber >= passwordField.elementNumber) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((canBeHidden || f.viewable) && (f.type === 'text' || f.type === 'email' || f.type === 'tel')) {
|
if ((withoutForm || f.form === passwordField.form) && (canBeHidden || f.viewable) &&
|
||||||
|
(f.type === 'text' || f.type === 'email' || f.type === 'tel')) {
|
||||||
usernameField = f;
|
usernameField = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user