// ==UserScript== // @name Medals // @namespace http://tampermonkey.net/ // @version 2025-01-22 // @description osu medals // @author brandwagen // @match https://osu.ppy.sh/* // @icon https://www.google.com/s2/favicons?sz=64&domain=ppy.sh // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const medalMax = 339; let changed = false; function main() { console.log("trying to change element"); const medalElement = document.querySelectorAll('.value-display__value')[2]; const medalCount = medalElement.textContent; const medalPercentage = (medalCount / medalMax * 100).toFixed(2); medalElement.textContent = `${medalPercentage}% (${medalCount})`; changed = true; } function waitForElement() { console.log("checking element"); const element = document.querySelectorAll('.value-display__value')[2]; if (element) { console.log("element found"); main(); } else { console.log("element not found"); setTimeout(waitForElement, 100); } } var oldURL = ""; var newURL = window.location.pathname; window.setInterval(function(){ console.log(oldURL, newURL); if(oldURL != newURL){ oldURL = newURL; changed = false; setTimeout(waitForElement, 1000); } newURL = window.location.pathname; }, 250); })();