Created
January 29, 2025 19:21
-
-
Save Igloczek/422b0eaf301fe9358832ee67df958c9f to your computer and use it in GitHub Desktop.
Revisions
-
Igloczek created this gist
Jan 29, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ (async function collectSpotifyPlaylist() { const TRACK_SELECTOR = '._iQpvk1c9OgRAc8KRTlH'; // Find the correct scroll container let scrollContainers = document.querySelectorAll('[data-overlayscrollbars-viewport]'); let scrollContainer = scrollContainers.length > 1 ? scrollContainers[1] : scrollContainers[0]; if (!scrollContainer) { console.error("Could not find the scrollable playlist container."); return; } let results = new Set(); // To store unique tracks let lastTrackCount = 0; function extractTracks() { document.querySelectorAll(TRACK_SELECTOR).forEach(el => { results.add(el.innerText.replace('\n', ' by ')); }); } async function scrollAndCollect() { while (true) { extractTracks(); scrollContainer.scrollBy(0, scrollContainer.clientHeight); // Scroll one viewport down await new Promise(resolve => setTimeout(resolve, 1000)); // Wait longer for new content let currentTrackCount = results.size; if (currentTrackCount === lastTrackCount) { break; // Stop when no new tracks are loaded } lastTrackCount = currentTrackCount; } console.log([...results].join('\n')); // Print all collected tracks } scrollAndCollect(); })();