1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-10 01:28:36 +02:00

option to only fill visible fields (for autofill on page load)

This commit is contained in:
Kyle Spearrin 2018-05-08 09:11:32 -04:00
parent fe94d0533b
commit 17b1d84519

View File

@ -158,6 +158,7 @@ export default class AutofillService implements AutofillServiceInterface {
const fillScript = this.generateFillScript(pd.details, { const fillScript = this.generateFillScript(pd.details, {
skipUsernameOnlyFill: options.skipUsernameOnlyFill || false, skipUsernameOnlyFill: options.skipUsernameOnlyFill || false,
onlyVisibleFields: options.onlyVisibleFields || false,
cipher: options.cipher, cipher: options.cipher,
}); });
@ -217,6 +218,7 @@ export default class AutofillService implements AutofillServiceInterface {
skipTotp: !fromCommand, skipTotp: !fromCommand,
skipLastUsed: true, skipLastUsed: true,
skipUsernameOnlyFill: !fromCommand, skipUsernameOnlyFill: !fromCommand,
onlyVisibleFields: !fromCommand,
}); });
} }
@ -306,7 +308,7 @@ export default class AutofillService implements AutofillServiceInterface {
} }
let passwordFields = this.loadPasswordFields(pageDetails, false); let passwordFields = this.loadPasswordFields(pageDetails, false);
if (!passwordFields.length) { if (!passwordFields.length && !options.onlyVisibleFields) {
// not able to find any viewable password fields. maybe there are some "hidden" ones? // not able to find any viewable password fields. maybe there are some "hidden" ones?
passwordFields = this.loadPasswordFields(pageDetails, true); passwordFields = this.loadPasswordFields(pageDetails, true);
} }
@ -330,7 +332,7 @@ export default class AutofillService implements AutofillServiceInterface {
if (login.username) { if (login.username) {
username = this.findUsernameField(pageDetails, pf, false, false); username = this.findUsernameField(pageDetails, pf, false, false);
if (!username) { if (!username && !options.onlyVisibleFields) {
// 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 = this.findUsernameField(pageDetails, pf, true, false); username = this.findUsernameField(pageDetails, pf, true, false);
} }
@ -352,7 +354,7 @@ export default class AutofillService implements AutofillServiceInterface {
if (login.username && pf.elementNumber > 0) { if (login.username && pf.elementNumber > 0) {
username = this.findUsernameField(pageDetails, pf, false, true); username = this.findUsernameField(pageDetails, pf, false, true);
if (!username) { if (!username && !options.onlyVisibleFields) {
// 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 = this.findUsernameField(pageDetails, pf, true, true); username = this.findUsernameField(pageDetails, pf, true, true);
} }