Graphomata Weighted Score Display

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

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 s=a.innerHTML;
    let x=[...s.matchAll(/(\d{1,2}),(\d{3})(\+(\d,)?(\d{1,3})<i>i<\/i>)?/g)];
    let last=0;let ss='';
    for(let i in x){
        ss+=s.slice(last,x[i].index);
        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;
        ss+=x[i][0]+`</td><td style="white-space: nowrap">${value.toLocaleString()}`;
        last=x[i].index+x[i][0].length;
    }
    ss+=s.slice(last);
    a.innerHTML=ss.replace('<th>Score</th>','<th>Score</th>\n<th>Weighted</th>');
    document.body.style['maxWidth']='950px';
})();