cleanup autofill service a bit

This commit is contained in:
Kyle Spearrin 2017-10-25 21:55:52 -04:00
parent 0bcc764274
commit 1c3143867b
1 changed files with 23 additions and 27 deletions

View File

@ -78,16 +78,8 @@ function initAutofill() {
}; };
var isoProvinces = { var isoProvinces = {
alberta: 'AB', alberta: 'AB', 'british columbia': 'BC', manitoba: 'MB', 'new brunswick': 'NB', 'newfoundland and labrador': 'NL',
'british columbia': 'BC', 'nova scotia': 'NS', ontario: 'ON', 'prince edward island': 'PE', quebec: 'QC', saskatchewan: 'SK'
manitoba: 'MB',
'new brunswick': 'NB',
'newfoundland and labrador': 'NL',
'nova scotia': 'NS',
ontario: 'ON',
'prince edward island': 'PE',
quebec: 'QC',
saskatchewan: 'SK'
}; };
AutofillService.prototype.getFormsWithPasswordFields = function (pageDetails) { AutofillService.prototype.getFormsWithPasswordFields = function (pageDetails) {
@ -95,11 +87,17 @@ function initAutofill() {
formData = []; formData = [];
passwordFields = loadPasswordFields(pageDetails, true); passwordFields = loadPasswordFields(pageDetails, true);
if (passwordFields.length) { if (!passwordFields.length) {
return formData;
}
for (var formKey in pageDetails.forms) { for (var formKey in pageDetails.forms) {
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) {
continue;
}
var uf = findUsernameField(pageDetails, pf, false, 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?
@ -114,8 +112,6 @@ function initAutofill() {
break; break;
} }
} }
}
}
return formData; return formData;
}; };