Skip to content

Instantly share code, notes, and snippets.

@michel-zimmer
Created November 16, 2016 09:27
Show Gist options
  • Save michel-zimmer/b615adc03a40bbed3ad888c42b3807dd to your computer and use it in GitHub Desktop.
Save michel-zimmer/b615adc03a40bbed3ad888c42b3807dd to your computer and use it in GitHub Desktop.
if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://code.jquery.com/jquery-latest.js';(d.head||d.documentElement).appendChild(s)})(document);
function song_row_as_json(el) {
return {
title: jQuery(jQuery("td[data-col='title'] span", el).contents()[1]).text(),
duration: jQuery("td[data-col='duration'] span", el).text(),
artist: jQuery("td[data-col='artist'] span a", el).text(),
album: jQuery("td[data-col='album'] span a", el).text()
};
}
function playlist_as_json() {
var song_rows_selector = '#music-content > div.playlist-view.material-detail-view.g-content.view-transition > div.material-playlist-container.material-container.material-shadow-z1.has-hero-image > table > tbody > tr.song-row';
var data = [];
jQuery(song_rows_selector).each(function(i, el) {
data.push(song_row_as_json(el));
});
return JSON.stringify(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment