From 95c14c4e72bec2441d560266202011c526e30192 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 25 Apr 2024 20:17:19 +0100 Subject: [PATCH] cleanup --- scoresaber-utils.user.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/scoresaber-utils.user.js b/scoresaber-utils.user.js index ca01e50..0d38425 100644 --- a/scoresaber-utils.user.js +++ b/scoresaber-utils.user.js @@ -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);