Skip to content

Instantly share code, notes, and snippets.

@C0D3-M4513R
Last active July 13, 2021 22:59
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 C0D3-M4513R/0888c7d578b4c5c213e502e4bb38071a to your computer and use it in GitHub Desktop.
Save C0D3-M4513R/0888c7d578b4c5c213e502e4bb38071a to your computer and use it in GitHub Desktop.
Osu Played Maps Downloader

How this works

This will download all played maps of a user. Make sure, that you are on a user-page, as this script will not work elsewhere.

This Script works, by opening the beatmaps (either with osu direct, or via download) in a new browser window. The Browser will detect this, and "Block Pop-ups". Please make sure to disable the Popup Blocker.

If you are unsure, if the Popup-blocker is active, or not, execute this script. If the Popup-blocker is active, this should spawn one, or no new tabs. If the Popup-blocker is not active, it spawns three tabs.

window.open("https://google.com")
window.open("https://google.com")
window.open("https://google.com")

I have chosen this way, because then I do now need to worry about loading times, and if the code will continue to execute, after the first redirect.

Breakability

I can't say, whether this will work in the future, because this script is dependent on the osu-userpage layout (,and osu-direct functionality). If any of those change, this script will require a rework.

Code

Below is the code, that you need to paste in the Browser Console.

//Do you own supporter? And should osu-direct be used for downloading?
//If this is false, this script will download the map, via the browsers downlading mechanism.
var hasOsuSupporter=false
//Timeout between loading more beatmaps of that user. This is largely dependent on the osu server speed.
var moreTimeout = 500;
//How many times moreTimeout may fail, until it is concluded, that all beatmaps have been loaded.
var buttonInvalidLimit=5;
//Timeout of opening maps in the browser.
//This can be low, but something too low, will cause you to get your ip temporarily bloked, because of ddos protection.
//I advise to not go below 500.
var openNewTimeout = 10000;
function dl(){
//Open Played maps full
//get all maps to arr
var hash = new Map();
for (const i of $(".page-extra").children(4)
.filter(".beatmap-playcount")
.map((o,i)=>i.firstChild))
{
var setidstr = i.attributes[2].nodeValue.substr(54);
var setid = setidstr.substr(0,setidstr.indexOf('/'));
var diffidstr=i.href.substr(28);
var diffid=diffidstr.substr(0,diffidstr.indexOf("?"))
hash.set(setid,diffid)
}
//about to log stuff!
console.clear();
//download all maps
var i=0;
hash.forEach((v,k)=>{
setTimeout((v,k)=>{
console.log("downloading beatmapset"+k+" id:"+v);
if (hasOsuSupporter) {
setTimeout((w)=>w.close(),openNewTimeout,window.open("osu://b/"+v));
} else {
setTimeout((w)=>w.close(),openNewTimeout,window.open("https://osu.ppy.sh/beatmapsets/"+k+"/download"));
}
},openNewTimeout*i,v,k);
i++;
})
}
var lastbutton=0;
var time = setInterval(()=>{
try{
$('button.show-more-link')[1].click()
lastbutton=0
}catch{
console.log("Please increase moreTimeout, and try again")
console.log("Ignore that though, if this the Most Played Baetmaps are completely loaded(no 'Show more' button visible)")
if (lastbutton>buttonInvalidLimit){
clearInterval(time)
dl();
}
lastbutton+=1
}
},moreTimeout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment