Skip to content

Instantly share code, notes, and snippets.

@jeremyworboys
Forked from pheuter/sc-dl.js
Created March 12, 2012 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyworboys/2020760 to your computer and use it in GitHub Desktop.
Save jeremyworboys/2020760 to your computer and use it in GitHub Desktop.
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl, pl, ps = d.querySelectorAll('.large.player, .medium.player');
for (var i = ps.length - 1; i >= 0; i--) {
pl = ps[i];
dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+pl.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = pl.querySelector('.info-header h1, .info-header h3').innerText+'.mp3';
pl.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = '#ff5500';
dl.style.fontWeight = 700;
}
})(document);
/** Minified **/
(function(a){var b,c,d=a.querySelectorAll(".large.player, .medium.player");for(var e=d.length-1;e>=0;e--){c=d[e];b=a.createElement("a");b.innerText="Download MP3";b.href="http://media.soundcloud.com/stream/"+c.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1];b.download=c.querySelector(".info-header h1, .info-header h3").innerText+".mp3";c.querySelector(".primary").appendChild(b);b.style.marginLeft="10px";b.style.color="#ff5500";b.style.fontWeight=700}})(document)
@jeremyworboys
Copy link
Author

  • Updated code to work on pages with multiple tracks (eg. artist profile).
  • Changed link color to match Soundcloud's orange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment