Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active January 22, 2022 14:47
Show Gist options
  • Select an option

  • Save gmolveau/a4b96ef8ab232a9c025eebb2dbff4d6d to your computer and use it in GitHub Desktop.

Select an option

Save gmolveau/a4b96ef8ab232a9c025eebb2dbff4d6d to your computer and use it in GitHub Desktop.
spotify your top songs extract

if you want to backup your top songs of {current_year}, here's a simple way of doing it :

  • open your browser
  • go to your top songs spotify playlist
  • open the console
  • copy the following code, paste it into the console and hit Enter
var songs = [];
document.querySelectorAll('div.tracklist-name').forEach((song) => {
    songs.push(song.innerText);
});
var artists = [];
document.querySelectorAll('span.TrackListRow__artists.ellipsis-one-line').forEach((artist) => {
	artists.push(artist.innerText);
});
var result = [];
for (var i = 0; i < artists.length; i++) {
    result[i] = artists[i] + " - " + songs[i];
}
console.log(result.join('\n'));
  • enjoy :)

js with map because y not

var songs = [...document.querySelectorAll('div.tracklist-name')].map(elem => elem.innerText);
var artists = [...document.querySelectorAll('span.TrackListRow__artists.ellipsis-one-line')].map(elem => elem.innerText);
var result = artists.map( function (artist, index) {
    return artist + " - " + songs[index]
});
console.log(result.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment