Graphomata Weighted Score Display

Display weighted score (i.e. Re+½Im) on the leaderboard.

  1. // ==UserScript==
  2. // @name Graphomata Weighted Score Display
  3. // @namespace http://tampermonkey.net/
  4. // @description Display weighted score (i.e. Re+½Im) on the leaderboard.
  5. // @version 2024-12-11
  6. // @author WYXkk
  7. // @match https://graphomata.com/game/leaderboards.html
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=graphomata.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. async function untilGet(id)
  13. {
  14. var u=undefined;
  15. while(u==undefined)
  16. {
  17. u=document.querySelectorAll(id)[0];
  18. await new Promise(resolve => setTimeout(resolve, 100));
  19. }
  20. return u;
  21. }
  22.  
  23. (async function() {
  24. 'use strict';
  25. var a=await untilGet('#leaderboardsTable > tbody');
  26. let s=a.innerHTML;
  27. let x=[...s.matchAll(/(\d{1,2}),(\d{3})(\+(\d,)?(\d{1,3})<i>i<\/i>)?/g)];
  28. let last=0;let ss='';
  29. for(let i in x){
  30. ss+=s.slice(last,x[i].index);
  31. let value=(parseInt(x[i][1]||'0')*1000+parseInt(x[i][2]||'0'))+(parseInt(x[i][4]||'0')*1000+parseInt(x[i][5]||'0'))/2;
  32. ss+=x[i][0]+`</td><td style="white-space: nowrap">${value.toLocaleString()}`;
  33. last=x[i].index+x[i][0].length;
  34. }
  35. ss+=s.slice(last);
  36. a.innerHTML=ss.replace('<th>Score</th>','<th>Score</th>\n<th>Weighted</th>');
  37. document.body.style['maxWidth']='950px';
  38. })();