Skip to content

Instantly share code, notes, and snippets.

@jimbo8098
Last active April 29, 2020 19:42
Show Gist options
  • Save jimbo8098/f5b352fdd4031686ad1d84539c2fc113 to your computer and use it in GitHub Desktop.
Save jimbo8098/f5b352fdd4031686ad1d84539c2fc113 to your computer and use it in GitHub Desktop.
Outputs all songs currently in view on a Spotify playlist page and outputs a JSON array of those songs
// Go to https://open.spotify.com/playlist/7dhpGlWyXiRadoIgKKvubA?si=tF8elMqMSPazYUUzKivLgg&fbclid=IwAR0bNVYx-XV0ddKp9djpk5RxfpgERLqJOHk9Vjb7-amThYQwl-gl3j1gthM or something similar then run this in console
var songs = [];
var rows = document.getElementsByClassName("tracklist-row");
for(var i = 0; i < rows.length; i++)
{
var rowComps = rows[i].innerText.split("\n");
if(rowComps[1] != "E")
{
var song = {
"name": rowComps[0],
"artist": rowComps[1],
"album": rowComps[3]
}
}
else
{
var song = {
"name": rowComps[0],
"artist": rowComps[2],
"album": rowComps[4]
}
}
songs.push(song);
}
console.log(JSON.stringify(songs));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment