This commit is contained in:
Lee 2024-04-25 20:17:19 +01:00
parent 53c751526c
commit 95c14c4e72

@ -1,7 +1,7 @@
// ==UserScript==
// @name ScoreSaber Utils
// @namespace https://ssu.fascinated.cc
// @version 1.0.5
// @version 1.0.6
// @description Useful additions to ScoreSaber!
// @author Fascinated
// @match https://scoresaber.com/*
@ -61,18 +61,6 @@ function sleep(ms) {
* Loads ScoreSaber Utils data on player pages.
*/
async function loadPlayerData(path) {
if (!path) {
path = window.location.pathname;
}
path = path.replace("https://scoresaber.com", "");
const isPlayerPage = path.startsWith("/u/");
if (!isPlayerPage) {
// Only run on player pages
return;
}
// Wait for the stats container to load
while (!document.querySelector(".stats-container")) {
await sleep(250);
@ -116,10 +104,13 @@ const observer = new MutationObserver(() => {
if (currentUrl == previousUrl) {
return;
}
console.log("Switching Page:", currentUrl);
previousUrl = currentUrl;
loadPlayerData(currentUrl);
console.log("Switching Page:", currentUrl);
// Load player data on player pages
if (currentUrl.startsWith("/u/")) {
loadPlayerData(currentUrl);
}
});
const config = { subtree: true, childList: true };
observer.observe(document, config);