Created
January 18, 2014 02:06
-
-
Save joest67/8485217 to your computer and use it in GitHub Desktop.
Download free music from xiami.
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
// ==UserScript== | |
// | |
// @name xiami_music_download | |
// @description download free music from xiami | |
// @namespace http://www.xiami.com/ | |
// @author joest(chaojiong.zheng@gmail.com) | |
// @license GNU GPL v3 (http://www.gnu.org/copyleft/gpl.html) | |
// @version 1.0 | |
// @include http://www.xiami.com/search* | |
// | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js | |
// | |
// | |
// ==/UserScript== | |
var pre='http://www.xiami.com/song/'; | |
var tail='?comefrom=sogou'; | |
function changeLink(){ | |
var elements = document.getElementsByClassName('song_download'); | |
var musicId = ''; | |
var link = ''; | |
for (var i=0;i<elements.length;i++) | |
{ | |
ele = elements[i]; | |
musicId = ele.getAttribute("onclick"); // xm_download('1770201852'); | |
var start = musicId.indexOf("'"); | |
var end = musicId.lastIndexOf("'"); | |
musicId = musicId.substring(start+1, end); | |
link = pre + musicId + tail; | |
ele.href = link; | |
ele.removeAttribute('onclick'); | |
ele.removeAttribute('data-spm-anchor-id'); | |
var att = document.createAttribute("target"); | |
att.value='_blank'; | |
ele.setAttributeNode(att); | |
} | |
} | |
$(document).ready(function(){ | |
changeLink(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment