Skip to content

Instantly share code, notes, and snippets.

@mooware
Last active October 13, 2015 14:18
Show Gist options
  • Save mooware/4208732 to your computer and use it in GitHub Desktop.
Save mooware/4208732 to your computer and use it in GitHub Desktop.
Amazon Cloud Player Download Bookmarklet
// I wrote this bookmarklet because Amazon has ended Linux support for downloading MP3s,
// and now I have to download songs separately through Amazon Cloud Player.
// This bookmarklet helps a bit with this, but it's far from perfect.
// When a list of songs is shown in Amazon Cloud Player, it clicks the song checkbox and
// the download button separately for each song, while waiting a few seconds in between songs.
// I encountered the issue that I cannot download more than a few songs simultaneously;
// the rest will just not show a download window. Not sure whether my browser or the server
// is doing this, but you might want to set the value of songdelayms high enough.
// The script is not really that useful, but it was fun to play around with this.
// bookmarklet version:
javascript:(function(){var%20button=jQuery(".actions%20.download").parent()[0];var%20songs=jQuery(".songTracks%20input.checkbox[itemtype='song']");jQuery(songs).filter(":checked").each(function(index,elem){elem.click();});var%20songidx=0;var%20clickdelayms=200;var%20songdelayms=4000;function%20download(){var%20song=songs[songidx];song.click();setTimeout(function(){button.click();setTimeout(function(){song.click();songidx++;if(songidx<songs.length)download();},songdelayms);},clickdelayms);}setTimeout(download,clickdelayms);})();
// plaintext version:
// get the download button
var button = jQuery(".actions .download").parent()[0];
// get the song checkboxes
var songs = jQuery(".songTracks input.checkbox[itemtype='song']");
// uncheck all songs
jQuery(songs).filter(":checked").each(function(index, elem) { elem.click(); });
// vars for download function
var songidx = 0;
var clickdelayms = 200;
var songdelayms = 4000;
// download a song, wait a bit, then download next song
function download() {
var song = songs[songidx];
song.click();
// wait before clicking, else it fails sometimes
setTimeout(function() {
button.click();
// next download after some ms
setTimeout(function() {
song.click();
songidx++;
if (songidx < songs.length) download();
}, songdelayms);
}, clickdelayms);
}
// start downloading
setTimeout(download, clickdelayms);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment