add page change log

This commit is contained in:
Lee 2024-04-25 20:15:46 +01:00
parent 5ba33056b6
commit 53c751526c

@ -7,8 +7,8 @@
// @match https://scoresaber.com/* // @match https://scoresaber.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=scoresaber.com // @icon https://www.google.com/s2/favicons?sz=64&domain=scoresaber.com
// @license MIT // @license MIT
// @updateURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Backend/raw/branch/master/scoresaber-utils.user.js // @updateURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Script/raw/branch/master/scoresaber-utils.user.js
// @downloadURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Backend/raw/branch/master/scoresaber-utils.user.js // @downloadURL https://git.fascinated.cc/Fascinated/ScoreSaberUtils-Script/raw/branch/master/scoresaber-utils.user.js
// @run-at document-end // @run-at document-end
// ==/UserScript== // ==/UserScript==
@ -111,13 +111,15 @@ 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(() => {
const currentUrl = location.pathname; // Get the current URL without parameters const currentUrl = location.pathname; // Get the current URL without parameters
if (currentUrl !== previousUrl) { if (currentUrl == previousUrl) {
previousUrl = currentUrl; return;
loadPlayerData(currentUrl);
} }
console.log("Switching Page:", currentUrl);
previousUrl = currentUrl;
loadPlayerData(currentUrl);
}); });
const config = { subtree: true, childList: true }; const config = { subtree: true, childList: true };
observer.observe(document, config); observer.observe(document, config);