1
1
'use strict' ;
2
2
3
+ const DEFAULT_SEGMENTED_TOTP_FIELDS = 6 ;
4
+
3
5
/**
4
6
* @Object kpxcFields
5
7
* Provides methods for input field handling.
@@ -92,9 +94,12 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
92
94
if ( ! kpxc . settings . showOTPIcon ) {
93
95
return ;
94
96
}
95
- const addTotpFieldsToCombination = function ( inputFields ) {
97
+
98
+ let exceptionFound = false ;
99
+
100
+ const addTotpFieldsToCombination = function ( inputFields , ignoreLength = false ) {
96
101
const totpInputs = Array . from ( inputFields ) . filter ( e => e . nodeName === 'INPUT' && e . type !== 'password' && e . type !== 'hidden' ) ;
97
- if ( totpInputs . length === 6 ) {
102
+ if ( totpInputs . length === DEFAULT_SEGMENTED_TOTP_FIELDS || ignoreLength ) {
98
103
const combination = {
99
104
form : form ,
100
105
totpInputs : totpInputs ,
@@ -121,7 +126,7 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
121
126
}
122
127
123
128
// Accept 6 inputs directly
124
- if ( currentForm . length === 6 ) {
129
+ if ( currentForm . length === DEFAULT_SEGMENTED_TOTP_FIELDS ) {
125
130
return true ;
126
131
}
127
132
@@ -132,6 +137,12 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
132
137
return true ;
133
138
}
134
139
140
+ // Accept any other site-specific exceptions
141
+ if ( kpxcSites . segmentedTotpExceptionFound ( currentForm ) ) {
142
+ exceptionFound = true ;
143
+ return true ;
144
+ }
145
+
135
146
return false ;
136
147
} ;
137
148
@@ -141,8 +152,8 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
141
152
|| ( form . name && typeof ( form . name ) === 'string' && form . name . includes ( f ) )
142
153
|| formLengthMatches ( form ) ) ) ) {
143
154
// Use the form's elements
144
- addTotpFieldsToCombination ( form . elements ) ;
145
- } else if ( inputs . length === 6 && inputs . every ( i => ( i . inputMode === 'numeric' && i . pattern . includes ( '0-9' ) )
155
+ addTotpFieldsToCombination ( form . elements , exceptionFound ) ;
156
+ } else if ( inputs . length === DEFAULT_SEGMENTED_TOTP_FIELDS && inputs . every ( i => ( i . inputMode === 'numeric' && i . pattern . includes ( '0-9' ) )
146
157
|| ( i . type === 'text' && i . maxLength === 1 )
147
158
|| i . type === 'tel' ) ) {
148
159
// No form is found, but input fields are possibly segmented TOTP fields
0 commit comments