Medals

try to take over the world!

当前为 2025-02-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Medals
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-02-13
  5. // @description try to take over the world!
  6. // @author brandwagen
  7. // @match https://osu.ppy.sh/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=ppy.sh
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const medalMax = 339;
  17. let changed = false;
  18.  
  19. function main(medalElement) {
  20. const medalCount = medalElement.textContent;
  21. if (!medalCount.includes("%")) {
  22. const medalPercentage = (medalCount / medalMax * 100).toFixed(2);
  23. medalElement.textContent = `${medalPercentage}% (${medalCount})`;
  24. medalElement.style.color = getColor(medalPercentage);
  25. changed = true;
  26. }
  27. }
  28.  
  29. function getColor(p) {
  30. if (p > 95) { return '#495afa'; }
  31. else if (p > 90) { return '#60edf4'; }
  32. else if (p > 80) { return '#b66aed'; }
  33. else if (p > 60) { return '#dd596f'; }
  34. else if (p > 40) { return '#ff8c68'; }
  35. return '#9dbece';
  36. }
  37.  
  38. function waitForElement() {
  39. const element = document.querySelectorAll('.value-display__value')[2];
  40.  
  41. if (element) {
  42. main(element);
  43. } else {
  44. setTimeout(waitForElement, 100);
  45. }
  46. }
  47.  
  48. var oldURL = "";
  49. var newURL = window.location.pathname;
  50.  
  51. window.setInterval(function(){
  52. if(oldURL != newURL){
  53. oldURL = newURL;
  54. changed = false;
  55. setTimeout(waitForElement, 1000);
  56. }
  57.  
  58. newURL = window.location.pathname;
  59. }, 250);
  60.  
  61.  
  62. })();