JQuery Snippet to Pull Tracklist from Amazon Page

I wrote a quick snippet to run in the chrome console to pull a tracklist from Amazon. I thought I’d share it here. I apologize if this is not the correct place to do so:

// Run this in your browser's JavaScript console, then jQuery should be available...
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();

// run this to pull tracklists from amazon page
var trackList;
$('#dmusic_tracklist_content tr').each(function() {
  var currenTD = 0;
  var trackInfo = '';
  $(this).find('td').each(function() {
    currenTD++;
    // trackno
    if(currenTD == 1) trackInfo += $(this).find('div.TrackNumber-Default-Color').html().trim();
    // title
    if(currenTD == 2) trackInfo += " - "+$(this).find('a.TitleLink').html().trim();
    // length
    if(currenTD == 3) trackInfo += " - "+$(this).find('span').html().trim();
  });
  trackList += trackInfo+"\n";
});
console.log(trackList);

You will want to run the first chunk first to load JQuery, then the second chunk after to output the tracklists. Feel free to modify!

Example

Produced:

1 - Retreat! - 3:31
2 - Stranger to My Happiness - 3:31
3 - We Get Along - 3:03
4 - You'll Be Lonely - 3:45
5 - Now I See - 3:10
6 - Making Up and Breaking Up (And Making Up and Breaking Up Over Again) - 2:23
7 - Get Up and Get Out - 3:27
8 - Long Time, Wrong Time - 3:21
9 - People Don't Get What They Deserve - 3:25
10 - Slow Down, Love - 4:02

The code is based on the current Amazon layout for music page, so it could stop working at any moment, but it was still very useful for me when adding a few releases today!

5 Likes