fix changing pages on the script
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Has been cancelled

This commit is contained in:
Lee 2024-04-25 20:05:51 +01:00
parent 80331ba972
commit e7ee0ef4af

View File

@ -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);