From e7ee0ef4af8ff9f7836a0226d82b44ae83799257 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 25 Apr 2024 20:05:51 +0100 Subject: [PATCH] fix changing pages on the script --- scoresaber-utils.user.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scoresaber-utils.user.js b/scoresaber-utils.user.js index 97bbeac..22c416c 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.2 +// @version 1.0.3 // @description Useful additions to ScoreSaber! // @author Fascinated // @match https://scoresaber.com/* @@ -112,10 +112,13 @@ async function loadPlayerData(path) { loadPlayerData(); // Watch for URL changes -document.onreadystatechange = () => { - if (document.readyState === "complete") { - window.navigation.addEventListener("navigate", (event) => { - loadPlayerData(event.destination.url); - }); +let previousUrl = ""; +const observer = new MutationObserver(function (mutations) { + if (location.href !== previousUrl) { + previousUrl = location.href; + + loadPlayerData(location.pathname); } -}; +}); +const config = { subtree: true, childList: true }; +observer.observe(document, config);