Add TOTP possibility to Predefined Sites

This commit is contained in:
varjolintu 2020-12-12 10:03:09 +02:00
parent 9ea7a26677
commit b68453fa89
2 changed files with 12 additions and 3 deletions

View file

@ -66,3 +66,12 @@ kpxcSites.exceptionFound = function(classList) {
return false;
};
kpxcSites.expectedTOTPMaxLength = function() {
if (document.location.origin.startsWith('https://www.amazon')
&& document.location.href.includes('/ap/mfa')) {
return 20;
}
return MAX_TOTP_INPUT_LENGTH;
};

View file

@ -2,8 +2,8 @@
const ignoreRegex = /(bank|coupon|postal|user|zip).*code|comment|author/i;
const ignoredTypes = [ 'email', 'password', 'username' ];
const MIN_INPUT_LENGTH = 6;
const MAX_INPUT_LENGTH = 10;
const MIN_TOTP_INPUT_LENGTH = 6;
const MAX_TOTP_INPUT_LENGTH = 10;
const acceptedOTPFields = [
'2fa',
@ -57,7 +57,7 @@ kpxcTOTPIcons.isValid = function(field, forced) {
if (ignoredTypes.some(t => t === field.type)
|| field.offsetWidth < MINIMUM_INPUT_FIELD_WIDTH
|| field.size < 2
|| (field.maxLength > 0 && (field.maxLength < MIN_INPUT_LENGTH || field.maxLength > MAX_INPUT_LENGTH))
|| (field.maxLength > 0 && (field.maxLength < MIN_TOTP_INPUT_LENGTH || field.maxLength > kpxcSites.expectedTOTPMaxLength()))
|| ignoredTypes.some(t => t === field.autocomplete)
|| field.id.match(ignoreRegex)
|| field.name.match(ignoreRegex)