Last active
January 15, 2022 02:37
-
-
Save MCJack123/9b449bbe814d099cfea29f46dccd5334 to your computer and use it in GitHub Desktop.
Small UserScript to add download links to ScoreSaber leaderboard pages (requires GreaseMonkey/TamperMonkey/*Monkey)
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 ScoreSaberGetMap | |
// @version 4 | |
// @grant none | |
// @match *://scoresaber.com/leaderboard/* | |
// ==/UserScript== | |
let attempts = 0; | |
function doit() { | |
let box = document.querySelector("div.content.svelte-n29l0e > strong.text-muted.svelte-n29l0e"); | |
console.log(box); | |
if (box !== null && box !== undefined) { | |
let id = box.innerText; | |
if (id !== null && id !== undefined) { | |
fetch("https://beatsaver.com/api/maps/hash/" + id) | |
.then(res => res.json()) | |
.then(data => { | |
box.innerHTML = ""; | |
let el = document.createElement("a"); | |
el.style.fontWeight = "bold"; | |
el.innerText = id; | |
el.href = "https://beatsaver.com/maps/" + data.id; | |
box.appendChild(el); | |
box.appendChild(document.createElement("br")); | |
el = document.createElement("a"); | |
el.style.fontWeight = "bold"; | |
el.innerText = "Download map from BeatSaver"; | |
el.href = data.versions[0].downloadURL; | |
box.appendChild(el); | |
box.appendChild(document.createElement("br")); | |
el = document.createElement("a"); | |
el.style.fontWeight = "bold"; | |
el.innerText = "OneClick™ Download"; | |
el.href = "beatsaver://" + data.id; | |
box.appendChild(el); | |
}) | |
.catch(console.error); | |
} | |
} else if (attempts++ < 10) setTimeout(doit, 250); | |
} | |
setTimeout(doit, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment