cleanup
This commit is contained in:
parent
53c751526c
commit
95c14c4e72
@ -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.5
|
// @version 1.0.6
|
||||||
// @description Useful additions to ScoreSaber!
|
// @description Useful additions to ScoreSaber!
|
||||||
// @author Fascinated
|
// @author Fascinated
|
||||||
// @match https://scoresaber.com/*
|
// @match https://scoresaber.com/*
|
||||||
@ -61,18 +61,6 @@ function sleep(ms) {
|
|||||||
* Loads ScoreSaber Utils data on player pages.
|
* Loads ScoreSaber Utils data on player pages.
|
||||||
*/
|
*/
|
||||||
async function loadPlayerData(path) {
|
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
|
// Wait for the stats container to load
|
||||||
while (!document.querySelector(".stats-container")) {
|
while (!document.querySelector(".stats-container")) {
|
||||||
await sleep(250);
|
await sleep(250);
|
||||||
@ -116,10 +104,13 @@ const observer = new MutationObserver(() => {
|
|||||||
if (currentUrl == previousUrl) {
|
if (currentUrl == previousUrl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Switching Page:", currentUrl);
|
|
||||||
previousUrl = 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 };
|
const config = { subtree: true, childList: true };
|
||||||
observer.observe(document, config);
|
observer.observe(document, config);
|
||||||
|
Loading…
Reference in New Issue
Block a user