您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
// ==UserScript== // @name Medals // @namespace http://tampermonkey.net/ // @version 2025-06-18 // @description try to take over the world! // @author brandwagen // @match https://osu.ppy.sh/* // @icon https://www.google.com/s2/favicons?sz=64&domain=ppy.sh // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; const medalMax = 339; let changed = false; let osekai_api = "https://osekai.net/api/profiles/get_user.php?id="; function main() { let medalPercentage; try { const data = JSON.parse(document.querySelector(".js-react--profile-page").dataset.initialData); medalPercentage = data.user.user_achievements.length / data.achievements.length * 100; } catch (error) { console.error("Medals: Error reading medals data from profile page JSON", error); return; } const nameElement = document.querySelector(".profile-info__name > span"); if (nameElement == null) { console.error("Medals: Couldn't find medal or name element"); return; } if (!nameElement.textContent.includes("%")) { nameElement.textContent = `${nameElement.textContent} | ${medalPercentage.toFixed(2)}%`; nameElement.style.color = getColor(medalPercentage); } } function getColor(p) { if (p > 95) { return '#495afa'; } if (p > 90) { return '#60edf4'; } if (p > 80) { return '#b66aed'; } if (p > 60) { return '#dd596f'; } if (p > 40) { return '#ff8c68'; } return '#9dbece'; } const observer = new MutationObserver((records) => { for (const record of records) { for (const node of record.addedNodes) { if (!(node instanceof HTMLElement)) { continue; } if ( node.classList.contains("profile-info__name") || node.querySelector(".profile-info__name") != null ) { observer.disconnect(); main(); } } } }); function onVisit(event) { observer.disconnect(); if ( event != null ? event.detail.url.includes("//osu.ppy.sh/users/") : window.location.pathname.startsWith("/users/") ) { observer.observe(document, { childList: true, subtree: true, }); } } document.addEventListener("turbo:visit", onVisit); onVisit(); })();