Medals

osu medals

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

  1. // ==UserScript==
  2. // @name Medals
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-02-04
  5. // @description osu medals
  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() {
  20. const medalElement = document.querySelectorAll('.value-display__value')[2];
  21. const medalCount = medalElement.textContent;
  22. const medalPercentage = (medalCount / medalMax * 100).toFixed(2);
  23. medalElement.textContent = `${medalPercentage}% (${medalCount})`;
  24. changed = true;
  25. }
  26.  
  27. function waitForElement() {
  28. const element = document.querySelectorAll('.value-display__value')[2];
  29.  
  30. if (element) {
  31. main();
  32. } else {
  33. setTimeout(waitForElement, 100);
  34. }
  35. }
  36.  
  37. var oldURL = "";
  38. var newURL = window.location.pathname;
  39.  
  40. window.setInterval(function(){
  41. if(oldURL != newURL){
  42. oldURL = newURL;
  43. changed = false;
  44. setTimeout(waitForElement, 1000);
  45. }
  46.  
  47. newURL = window.location.pathname;
  48. }, 250);
  49.  
  50.  
  51. })();