don't load again if only page params changed
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:12:16 +01:00
parent ddaa1e7c97
commit 0b5f083366

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name ScoreSaber Utils // @name ScoreSaber Utils
// @namespace https://ssu.fascinated.cc // @namespace https://ssu.fascinated.cc
// @version 1.0.4 // @version 1.0.5
// @description Useful additions to ScoreSaber! // @description Useful additions to ScoreSaber!
// @author Fascinated // @author Fascinated
// @match https://scoresaber.com/* // @match https://scoresaber.com/*
@ -112,10 +112,11 @@ async function loadPlayerData(path) {
// Watch for URL changes // Watch for URL changes
let previousUrl = ""; let previousUrl = "";
const observer = new MutationObserver(function (mutations) { const observer = new MutationObserver(function (mutations) {
if (location.href !== previousUrl) { const currentUrl = location.pathname; // Get the current URL without parameters
previousUrl = location.href; if (currentUrl !== previousUrl) {
previousUrl = currentUrl;
loadPlayerData(location.pathname); loadPlayerData(currentUrl);
} }
}); });
const config = { subtree: true, childList: true }; const config = { subtree: true, childList: true };