-
-
Save oumu/2258328 to your computer and use it in GitHub Desktop.
SoundCloud bookmarklet that generates link to download MP3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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