File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,14 @@ async function autoFillSecrets(message, sender) {
7575
7676 const vault = new Vault ( vaultToken , vaultAddress ) ;
7777
78+ let loginCount = 0 ;
79+
7880 for ( let secret of secretList ) {
7981 const secretKeys = await vault . list ( `/secret/metadata/vaultPass/${ secret } ` ) ;
8082 for ( let key of secretKeys . data . keys ) {
83+ var pattern = new RegExp ( key ) ;
84+ var patternMatches = pattern . test ( hostname ) ;
85+ // If the key is an exact match to the current hostname --> autofill
8186 if ( hostname === clearHostname ( key ) ) {
8287 const credentials = await vault . get ( `/secret/data/vaultPass/${ secret } ${ key } ` ) ;
8388
@@ -86,11 +91,16 @@ async function autoFillSecrets(message, sender) {
8691 username : credentials . data . data . username ,
8792 password : credentials . data . data . password ,
8893 } ) ;
89-
90- return ;
94+ }
95+ if ( patternMatches ) {
96+ loginCount ++ ;
9197 }
9298 }
9399 }
100+ if ( loginCount == 0 ) {
101+ return ;
102+ }
103+ chrome . action . setBadgeText ( { text : `${ loginCount } ` , tabId : sender . tab . id } ) ;
94104}
95105
96106chrome . runtime . onMessage . addListener ( function ( message , sender ) {
Original file line number Diff line number Diff line change @@ -91,11 +91,9 @@ function handleFillCredits(request) {
9191}
9292
9393function fillForm ( ) {
94- if ( document . querySelectorAll ( 'input[type=\'password\']' ) . length ) {
95- chrome . runtime . sendMessage ( {
96- type : 'auto_fill_secrets' ,
97- } ) ;
98- }
94+ chrome . runtime . sendMessage ( {
95+ type : 'auto_fill_secrets' ,
96+ } ) ;
9997}
10098
10199fillForm ( ) ;
You can’t perform that action at this time.
0 commit comments