Greasy Fork

osu! Download from mirror

Download beatbaps from mirror site

当前为 2014-11-11 提交的版本,查看 最新版本

// ==UserScript==
// @name        osu! Download from mirror
// @namespace   http://www.icycat.com
// @description Download beatbaps from mirror site
// @author      冻猫
// @include     *osu.ppy.sh/b*
// @include     *osu.ppy.sh/s*
// @version     1.5
// @grant       GM_xmlhttpRequest
// ==/UserScript==

(function($) {

	var mirrorDown = '<div id="mirroDown" style="float:right;width:100px;"><button id="mirrorLoli" style="background-color:#78AB23;border:1px solid;border-radius:5px;color:#FFFFFF;cursor:pointer;font-size:1.5em;font-weight:bold;height:64px;margin:2px 1px 0 5px;width:100px;">Download from loli.al</button><button id="mirrorBloodcat" style="background-color:#78AB23;border:1px solid;border-radius:5px;color:#FFFFFF;cursor:pointer;font-size:1.5em;font-weight:bold;height:64px;margin:4px 1px 0 5px;width:100px;">Download from bloodcat</button></div>';

	$('.beatmapDownloadButton:first').before(mirrorDown);

	document.getElementById('mirrorLoli').onclick = function() {
		var osuId = location.pathname.match(/\d+/)[0];
		var loliId;
		GM_xmlhttpRequest({
			method: 'GET',
			url: 'http://loli.al/osu.osp?action=check&id=' + osuId,
			headers: {
				'User-Agent': navigator.userAgent,
				'Cookie': document.cookies,
			},
			onload: function(responseDetails) {
				if (responseDetails.status == 200) {
					loliId = responseDetails.responseText;
					console.log('loliId:' + loliId);
					location.href = 'http://loli.al/d/' + loliId;
				} else {
					console.log('遇到网络问题了!');
				}
			}
		});

	}

	document.getElementById('mirrorBloodcat').onclick = function() {
		location.href = 'https://bloodcat.com/osu' + $('.beatmapDownloadButton:last a').attr('href').replace('d', 'm');
	}

})(unsafeWindow.$);