Skip to content

Instantly share code, notes, and snippets.

@isayme
Last active January 19, 2017 11:11
Show Gist options
  • Save isayme/d94172923e81ba1a1c42 to your computer and use it in GitHub Desktop.
Save isayme/d94172923e81ba1a1c42 to your computer and use it in GitHub Desktop.
油猴脚本 => 获取SongTaste歌曲下载链接, 点击页面中的"下载歌曲"即可直接下载.
// ==UserScript==
// @name SongTasteDownload
// @namespace http://www.onefloweroneworld.com
// @description 自动解析SongTaste歌曲URL,点击即可下载~
// @include http://www.songtaste.com/song/*
// @include http://songtaste.com/song/*
// @include http://www.songtaste.com/playmusic.php?song_id=*
// @include http://songtaste.com/playmusic.php?song_id=*
// @version 0.1
// @author iSayme
// @updateURL https://gist.github.com/isayme/d94172923e81ba1a1c42/raw/songtaste-download.user.js
// @downloadURL https://gist.github.com/isayme/d94172923e81ba1a1c42
// @grant none
// ==/UserScript==
// for `/song/*`
function getURL(sid, str, callback) {
if (!sid || !str || !callback) return;
$.get('/time.php', {sid: sid, str: str, t: 0}, callback, 'html');
}
var $song = $('a[href^=javascript:playmedia1]');
if ($song.length === 1) {
var infoArr = $song.attr('href').split('\'');
getURL(infoArr[15], infoArr[5], function(data) {
$('#custom_1').attr('href', data);
});
}
// for `/playmusic.php`
// overwrite default function setSongInfo
if (typeof setSongInfo === 'function') {
var embed = function() {
var old = setSongInfo;
setSongInfo = function(obj) {
old(obj);
var $dl = $('.p_fun > a');
$dl.each(function(item) {
var $this = $(this);
if ('red' === $this.css('color')) {
$this.attr('href', obj.url);
}
});
};
};
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.appendChild(document.createTextNode('(' + embed + ')()'));
document.getElementsByTagName('head')[0].appendChild(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment