Graphomata Leaderboard Weighted Score Display

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

目前为 2024-02-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         Graphomata Leaderboard Weighted Score Display
// @description  Display weighted score (i.e. Re+½Im) at the leaderboard.
// @namespace    http://tampermonkey.net/
// @version      2024-02-27
// @author       WYXkk
// @match        https://graphomata.com/game/leaderboards.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=graphomata.com
// @grant        none
// @license CC BY-SA 3.0
// ==/UserScript==

function fromHTML(html, trim = true) {
  html = trim ? html.trim() : html;
  if (!html) return null;

  const template = document.createElement('template');
  template.innerHTML = html;
  const result = template.content.children;

  if (result.length === 1) return result[0];
  return result;
}
// from https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro

async function untilGet(id)
{
    var u=undefined;
    while(u==undefined)
    {
        u=document.querySelectorAll(id)[0];
        await new Promise(resolve => setTimeout(resolve, 100));
    }
    return u;
}

(async function() {
    'use strict';
    var a=await untilGet('#leaderboardsTable > tbody');
    let top=a.children[0];
    top.insertBefore(fromHTML('<th>Weighted</th>'),top.children[2]);
    for(let i=1;i<a.childElementCount;i++){
        let x=a.children[i];
        let score=x.children[1].innerText;
        let parsedScore=score.replaceAll('i','').replaceAll(',','').split('+').map(t=>parseInt(t));
        let value=parsedScore[0]+(parsedScore[1]?parsedScore[1]:0)/2;
        x.insertBefore(fromHTML(`<td style="white-space: nowrap">${value.toLocaleString()}</td>`),x.children[2]);
    }
    document.body.style['maxWidth']='950px';
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址