File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 159159 libBtn . addEventListener ( 'click' , function ( ) {
160160 setTimeout ( ( ) => switchLs ( ) , 0 ) ;
161161 } ) ;
162- // Collapse library on startup
163- switchLs ( true ) ;
164- console . log ( 'Library collapsed on startup' ) ;
162+
163+ // Collapse library on startup if it's expanded
164+ // Check if button says "Collapse" (meaning library is currently expanded)
165+ if ( libBtn . getAttribute ( 'aria-label' ) === 'Collapse Your Library' ) {
166+ console . log ( 'Library is expanded on startup, collapsing it...' ) ;
167+ // Click the button to let Spotify update its state properly
168+ // This ensures the button will show "Open your library" after collapse
169+ libBtn . click ( ) ;
170+ }
165171 }
166172 } ;
167173
200206 // Only auto-close library if it's NOT a folder
201207 if ( ! isFolder ) {
202208 console . log ( 'AutoCloseLib (playlist/item clicked)' ) ;
203- // Force collapse using switchLs to avoid code duplication
204- switchLs ( true ) ;
209+ // Click the library button to let Spotify update its state properly
210+ // This ensures the button shows "Open your library" after collapse
211+ if ( window . lBtn ) {
212+ window . lBtn . click ( ) ;
213+ }
205214 closeNowPlay ( ) ;
206215 }
207216 } ) ;
You can’t perform that action at this time.
0 commit comments