Skip to content

Instantly share code, notes, and snippets.

@youpy
Created July 2, 2010 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youpy/461827 to your computer and use it in GitHub Desktop.
Save youpy/461827 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name mixcloud.com: extract mp3 URL
// @namespace http://d.hatena.ne.jp/youpy/
// @include http://www.mixcloud.com/*
// ==/UserScript==
var $ = unsafeWindow.$;
function jsonUrl(path) {
return 'http://www.mixcloud.com/api/1/cloudcast'
+ path.replace(/\/$/, '')
+ '.json?embed_type=player';
}
if(document.querySelector('.newstyle-play-btn')) {
$.getJSON(jsonUrl(location.pathname), function(data) {
var div = $('.cloudcast-titles');
var links = data.audio_formats.mp3;
links.forEach(function(url) {
var linkText = 'mp3';
div.append($(linkText.link(url)).css({ 'margin-right': '5px' }));
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment