Skip to content

Commit 9c3ef54

Browse files
CopilotMyst1cX
andcommitted
Extract magic strings and numbers to constants for maintainability
Co-authored-by: Myst1cX <97919309+Myst1cX@users.noreply.github.com>
1 parent f7671e9 commit 9c3ef54

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

spotifuck-v6.user.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
let ffDone = false; // First fuck done (firstFuck initialization complete)
3737
let pfint = null; // Primary features interval
3838

39+
// Constants for library button states and timing
40+
const LIBRARY_BUTTON_COLLAPSED = 'Collapse Your Library';
41+
const PLAYLIST_NAVIGATION_DELAY_MS = 300; // Delay before collapsing library after playlist click
42+
3943
// Note: Class name ".fuckd" used throughout is from original APK source (r0/e.java)
4044
// It marks elements as "already processed" to prevent duplicate event handlers
4145

@@ -166,7 +170,7 @@
166170

167171
// Collapse library on startup if it's expanded
168172
// Check if button says "Collapse" (meaning library is currently expanded)
169-
if (libBtn.getAttribute('aria-label') === 'Collapse Your Library') {
173+
if (libBtn.getAttribute('aria-label') === LIBRARY_BUTTON_COLLAPSED) {
170174
console.log('Library is expanded on startup, collapsing it...');
171175
// Click the button to let Spotify update its state properly
172176
// This ensures the button will show "Open your library" after collapse
@@ -215,12 +219,12 @@
215219
setTimeout(() => {
216220
// Check if library is still expanded before collapsing
217221
// This prevents unnecessary clicks if user manually collapsed it
218-
if (window.lBtn && window.lBtn.getAttribute('aria-label') === 'Collapse Your Library') {
222+
if (window.lBtn && window.lBtn.getAttribute('aria-label') === LIBRARY_BUTTON_COLLAPSED) {
219223
// Library is still expanded, collapse it
220224
window.lBtn.click();
221225
}
222226
closeNowPlay();
223-
}, 300); // 300ms ensures playlist navigation has initiated
227+
}, PLAYLIST_NAVIGATION_DELAY_MS);
224228
}
225229
});
226230
}

0 commit comments

Comments
 (0)