@@ -358,9 +358,9 @@ kpxcFields.getAllPageInputs = async function(previousInputs = []) {
358
358
if ( ! kpxc . singleInputEnabledForPage
359
359
&& ( ( fields . length === 1 && fields [ 0 ] . getLowerCaseAttribute ( 'type' ) !== 'password' )
360
360
|| ( previousInputs . length === 1 && previousInputs [ 0 ] . getLowerCaseAttribute ( 'type' ) !== 'password' ) ) ) {
361
- sendMessage ( 'username_field_detected' , true ) ;
361
+ sendMessage ( 'username_field_detected' , true ) ;
362
362
} else {
363
- sendMessage ( 'username_field_detected' , false ) ;
363
+ sendMessage ( 'username_field_detected' , false ) ;
364
364
}
365
365
366
366
await kpxc . initCombinations ( inputs ) ;
@@ -390,11 +390,11 @@ kpxcFields.getCombination = async function(field, givenType) {
390
390
// Gets of generates an unique ID for the element
391
391
kpxcFields . getId = function ( target ) {
392
392
if ( target . classList . length > 0 ) {
393
- return `${ target . nodeName } ${ target . type } ${ target . classList . value } ` ;
393
+ return `${ target . nodeName } ${ target . type } ${ target . classList . value } ${ target . name } ${ target . placeholder } ` ;
394
394
}
395
395
396
396
if ( target . id && target . id !== '' ) {
397
- return `${ target . nodeName } ${ target . type } ${ kpxcFields . prepareId ( target . id ) } ` ;
397
+ return `${ target . nodeName } ${ target . type } ${ kpxcFields . prepareId ( target . id ) } ${ target . name } ${ target . placeholder } ` ;
398
398
}
399
399
400
400
return `kpxc ${ target . type } ${ target . clientTop } ${ target . clientLeft } ${ target . clientWidth } ${ target . clientHeight } ${ target . offsetTop } ${ target . offsetLeft } ` ;
@@ -530,7 +530,7 @@ kpxcFields.useCustomLoginFields = async function() {
530
530
}
531
531
} ) ;
532
532
533
- [ creds . username , creds . password , creds . totp ] = await Promise . all ( [
533
+ const [ username , password , totp ] = await Promise . all ( [
534
534
await findInputField ( inputFields , creds . username ) ,
535
535
await findInputField ( inputFields , creds . password ) ,
536
536
await findInputField ( inputFields , creds . totp )
@@ -546,17 +546,17 @@ kpxcFields.useCustomLoginFields = async function() {
546
546
}
547
547
548
548
// Handle custom TOTP field
549
- if ( creds . totp ) {
550
- creds . totp . setAttribute ( 'kpxc-defined' , 'totp' ) ;
551
- kpxcTOTPIcons . newIcon ( creds . totp , kpxc . databaseState , true ) ;
549
+ if ( totp ) {
550
+ totp . setAttribute ( 'kpxc-defined' , 'totp' ) ;
551
+ kpxcTOTPIcons . newIcon ( totp , kpxc . databaseState , true ) ;
552
552
}
553
553
554
554
const combinations = [ ] ;
555
555
combinations . push ( {
556
- username : creds . username ,
557
- password : creds . password ,
558
- passwordInputs : [ creds . password ] ,
559
- totp : creds . totp ,
556
+ username : username ,
557
+ password : password ,
558
+ passwordInputs : [ password ] ,
559
+ totp : totp ,
560
560
fields : stringFields
561
561
} ) ;
562
562
@@ -696,7 +696,7 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
696
696
const el = document . activeElement ;
697
697
if ( el . nodeName !== 'INPUT' || kpxc . credentials . length === 0 ) {
698
698
return ;
699
- } else if ( kpxc . credentials . length > 1 && kpxc . combinations . length > 0 ) {
699
+ } else if ( kpxc . credentials . length > 1 && kpxc . combinations . length > 0 && kpxc . settings . autoCompleteUsernames ) {
700
700
kpxcAutocomplete . showList ( el ) ;
701
701
return ;
702
702
}
@@ -723,15 +723,16 @@ kpxc.fillInFromActiveElement = async function(passOnly = false) {
723
723
724
724
// Fill requested by Auto-Fill
725
725
kpxc . fillFromAutofill = async function ( ) {
726
- if ( kpxc . credentials . length !== 1 || kpxc . combinations . length !== 1 ) {
726
+ if ( kpxc . credentials . length !== 1 || kpxc . combinations . length === 0 ) {
727
727
return ;
728
728
}
729
729
730
+ const index = kpxc . combinations . length - 1 ;
730
731
await sendMessage ( 'page_set_login_id' , 0 ) ;
731
- kpxc . fillInCredentials ( kpxc . combinations [ 0 ] , kpxc . credentials [ 0 ] . login , kpxc . credentials [ 0 ] . uuid ) ;
732
+ kpxc . fillInCredentials ( kpxc . combinations [ index ] , kpxc . credentials [ 0 ] . login , kpxc . credentials [ 0 ] . uuid ) ;
732
733
733
734
// Generate popup-list of usernames + descriptions
734
- sendMessage ( 'popup_login' , [ `${ kpxc . credentials [ 0 ] . login } (${ kpxc . credentials [ 0 ] . name } )` ] ) ;
735
+ sendMessage ( 'popup_login' , [ { text : `${ kpxc . credentials [ 0 ] . login } (${ kpxc . credentials [ 0 ] . name } )` , uuid : kpxc . credentials [ 0 ] . uuid } ] ) ;
735
736
} ;
736
737
737
738
// Fill requested by selecting credentials from the popup
@@ -783,7 +784,7 @@ kpxc.fillFromUsernameIcon = async function(combination) {
783
784
await kpxc . receiveCredentialsIfNecessary ( ) ;
784
785
if ( kpxc . credentials . length === 0 ) {
785
786
return ;
786
- } else if ( kpxc . credentials . length > 1 ) {
787
+ } else if ( kpxc . credentials . length > 1 && kpxc . settings . autoCompleteUsernames ) {
787
788
kpxcAutocomplete . showList ( combination . username || combination . password ) ;
788
789
return ;
789
790
}
@@ -854,7 +855,7 @@ kpxc.fillInCredentials = async function(combination, predefinedUsername, uuid, p
854
855
855
856
// Auto-submit
856
857
if ( kpxc . settings . autoSubmit && ! skipAutoSubmit ) {
857
- const submitButton = kpxc . getFormSubmitButton ( combination . form ) ;
858
+ const submitButton = kpxcForm . getFormSubmitButton ( combination . form ) ;
858
859
if ( submitButton !== undefined ) {
859
860
submitButton . click ( ) ;
860
861
} else {
@@ -1035,7 +1036,7 @@ kpxc.initCombinations = async function(inputs = []) {
1035
1036
1036
1037
// The main function for finding input fields
1037
1038
kpxc . initCredentialFields = async function ( ) {
1038
- await sendMessage ( 'page_clear_logins' , _called . clearLogins ) ;
1039
+ await sendMessage ( 'page_clear_logins' , _called . clearLogins ) ;
1039
1040
_called . clearLogins = true ;
1040
1041
1041
1042
// Identify all forms in the page
@@ -1060,7 +1061,7 @@ kpxc.initCredentialFields = async function() {
1060
1061
}
1061
1062
1062
1063
// Combine inputs
1063
- kpxc . inputs = [ ...formInputs , ...pageInputs ] ;
1064
+ kpxc . inputs = [ ...formInputs , ...pageInputs ] ;
1064
1065
1065
1066
// Combinations are already saved when identifying fields
1066
1067
if ( kpxc . combinations . length === 0 ) {
@@ -1471,7 +1472,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
1471
1472
target . shadowSelectorAll ( 'input' ) . forEach ( e => {
1472
1473
if ( e . type !== 'hidden' && ! e . disabled && ! kpxcObserverHelper . alreadyIdentified ( e ) ) {
1473
1474
inputFields . push ( e ) ;
1474
- } ;
1475
+ }
1475
1476
} ) ;
1476
1477
}
1477
1478
@@ -1525,8 +1526,13 @@ kpxcObserverHelper.handleObserverAdd = async function(target) {
1525
1526
await kpxc . initCombinations ( inputs ) ;
1526
1527
await kpxcIcons . initIcons ( kpxc . combinations ) ;
1527
1528
1528
- if ( kpxc . databaseState === DatabaseState . UNLOCKED && _called . retrieveCredentials === false ) {
1529
- await kpxc . retrieveCredentials ( ) ;
1529
+ if ( kpxc . databaseState === DatabaseState . UNLOCKED ) {
1530
+ if ( _called . retrieveCredentials === false ) {
1531
+ await kpxc . retrieveCredentials ( ) ;
1532
+ return ;
1533
+ }
1534
+
1535
+ kpxc . prepareCredentials ( ) ;
1530
1536
}
1531
1537
} ;
1532
1538
@@ -1574,8 +1580,8 @@ kpxcObserverHelper.ignoredNode = function(target) {
1574
1580
|| kpxcObserverHelper . ignoredNodeNames . some ( e => e === target . nodeName )
1575
1581
|| target . nodeName . startsWith ( 'YTMUSIC' )
1576
1582
|| target . nodeName . startsWith ( 'YT-' ) ) {
1577
- return true ;
1578
- }
1583
+ return true ;
1584
+ }
1579
1585
1580
1586
return false ;
1581
1587
} ;
@@ -1592,7 +1598,7 @@ kpxcObserverHelper.initObserver = async function() {
1592
1598
mutations = mutations . slice ( 0 , _maximumMutations ) ;
1593
1599
}
1594
1600
1595
- let styleMutations = [ ] ;
1601
+ const styleMutations = [ ] ;
1596
1602
for ( const mut of mutations ) {
1597
1603
if ( kpxcObserverHelper . ignoredNode ( mut . target ) ) {
1598
1604
continue ;
@@ -1614,10 +1620,6 @@ kpxcObserverHelper.initObserver = async function() {
1614
1620
continue ;
1615
1621
}
1616
1622
1617
- // Listen for possible CSS animations
1618
- mut . target . removeEventListener ( 'transitionend' , kpxcObserverHelper . handleTransitionEnd ) ;
1619
- mut . target . addEventListener ( 'transitionend' , kpxcObserverHelper . handleTransitionEnd ) ;
1620
-
1621
1623
// There's an issue here. We cannot know for sure if the class attribute if added or removed.
1622
1624
kpxcObserverHelper . handleObserverAdd ( mut . target ) ;
1623
1625
}
@@ -1658,7 +1660,7 @@ const initContentScript = async function() {
1658
1660
}
1659
1661
1660
1662
// Retrieve submitted credentials if available.
1661
- const [ creds , redirectCount ] = await Promise . all ( [
1663
+ const [ creds , redirectCount ] = await Promise . all ( [
1662
1664
await sendMessage ( 'page_get_submitted' ) ,
1663
1665
await sendMessage ( 'page_get_redirect_count' )
1664
1666
] ) ;
0 commit comments