Graphomata Weighted Score Display

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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';
})();