Skip to content

Instantly share code, notes, and snippets.

@oumu
Forked from rsvp/soundcloud-mp3.js
Created March 31, 2012 00:49
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oumu/2258328 to your computer and use it in GitHub Desktop.
Save oumu/2258328 to your computer and use it in GitHub Desktop.
SoundCloud bookmarklet that generates link to download MP3
/**
2012-03-26 Forked from duncanbeevers' sc-dl.js : https://gist.github.com/2157987
**/
(function(document) {
var link = document.createElement("a"),
span = document.createElement("span"),
slug = document.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1],
mp3 = document.querySelector("em").innerText + ".mp3";
span.innerText = "Download";
link.appendChild(span);
link.setAttribute("class", "pl-button");
link.setAttribute("style","background-image: url(http://soundcloud.com/images/icons_mini.png?unicorn26); background-repeat: no-repeat; padding-left: 18px; background-position: -77px -236px;");
link.download = mp3;
document.querySelector(".primary").appendChild(link);
link.href = "http://media.soundcloud.com/stream/" + slug;
})(document);
/** Minified **/
(function(a){var b=a.createElement("a"),c=a.createElement("span"),d=a.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1],e=a.querySelector("em").innerText+".mp3";c.innerText="Download",b.appendChild(c),b.setAttribute("class","pl-button"),b.setAttribute("style","background-image: url(http://soundcloud.com/images/icons_mini.png?unicorn26); background-repeat: no-repeat; padding-left: 18px; background-position: -77px -236px;"),b.download=e,a.querySelector(".primary").appendChild(b),b.href="http://media.soundcloud.com/stream/"+d})(document);
/** Bookmarklet form -- insert into URL location **/
javascript:(function(a){var b=a.createElement("a"),c=a.createElement("span"),d=a.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1],e=a.querySelector("em").innerText+".mp3";c.innerText="Download",b.appendChild(c),b.setAttribute("class","pl-button"),b.setAttribute("style","background-image: url(http://soundcloud.com/images/icons_mini.png?unicorn26); background-repeat: no-repeat; padding-left: 18px; background-position: -77px -236px;"),b.download=e,a.querySelector(".primary").appendChild(b),b.href="http://media.soundcloud.com/stream/"+d})(document);
/** ================= Code below no longer works ============================== **/
/**
2012-03-08 Thu 19:03 Forked from pheuter's sc-dl.js : https://gist.github.com/1980967
Bookmarklet was featured on Lifehacker:
http://lifehacker.com/5891635/download-any-mp3-from-soundcloud-with-this-bookmarklet#
**/
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);
/** Minified **/
(function(b){var a=b.createElement("a");a.innerText="Download MP3";a.href="http://media.soundcloud.com/stream/"+b.querySelector("#main-content-inner img[class=waveform]").src.match(/\.com\/(.+)\_/)[1];a.download=b.querySelector("em").innerText+".mp3";b.querySelector(".primary").appendChild(a);a.style.marginLeft="10px";a.style.color="red";a.style.fontWeight=700})(document);
/** Bookmarklet form -- insert into URL location **/
javascript:(function(b){var%20a=b.createElement("a");a.innerText="Download%20MP3";a.href="http://media.soundcloud.com/stream/"+b.querySelector("#main-content-inner%20img[class=waveform]").src.match(/\.com\/(.+)\_/)[1];a.download=b.querySelector("em").innerText+".mp3";b.querySelector(".primary").appendChild(a);a.style.marginLeft="10px";a.style.color="red";a.style.fontWeight=700})(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment