Skip to content

Instantly share code, notes, and snippets.

@thehowl
Last active May 16, 2016 13:40
Show Gist options
  • Save thehowl/e4ea9a1dc944b440e1feb482318c9f35 to your computer and use it in GitHub Desktop.
Save thehowl/e4ea9a1dc944b440e1feb482318c9f35 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name m.zxq.co beatmap mirror
// @namespace https://m.zxq.co/
// @version 0.1
// @description faster osu! beatmaps downloads, yay!
// @author Howl
// @match http*://osu.ppy.sh/s/*
// @match http*://osu.ppy.sh/b/*
// @grant GM_xmlhttpRequest
// @connect m.zxq.co
// @updateURL https://gist.github.com/thehowl/e4ea9a1dc944b440e1feb482318c9f35/raw/osumirror.user.js
// ==/UserScript==
(function() {
'use strict';
var locs = $("img[src='//s.ppy.sh/images/osu-download-beatmap.png']").parent().attr("href").split("/");
if (locs.length < 3)
return;
var match = /^(\d+)/.exec(locs[2]);
GM_xmlhttpRequest ( {
method: "GET",
url: "https://m.zxq.co/s/" + match[1] + ".json",
onload: function (response) {
if (response.status == 200) {
var data = JSON.parse(response.responseText);
$("img[src='//s.ppy.sh/images/osu-download-beatmap.png']").parent().attr("href", "https://m.zxq.co/" + match[1] + ".osz");
if (typeof data.HasVideo != 'undefined' && data.HasVideo)
$("img[src='//s.ppy.sh/images/osu-download-beatmap-novid.png']").parent().attr("href", "https://m.zxq.co/" + match[1] + "n.osz");
}
}
} );
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment