show JOI difficulty vote value

show JOI difficulty vote value user script

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         show JOI difficulty vote value
// @namespace    http://twitter.com/DeltaStruct
// @version      1.3
// @description  show JOI difficulty vote value user script
// @author       DeltaStruct
// @match        https://joi.goodbaton.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

window.onload = (function() {
    'use strict';
    var par = document.querySelectorAll("table.DifficultyList_self_KqSSj > tbody > tr");
    var name = document.getElementsByClassName("DifficultyListItem_taskname_CAZIu");
    var day = document.getElementsByClassName("DifficultyListItem_source_SGqCh");
    var attr = [
        "LevelColor_level0_r8zaq",
        "LevelColor_level1_We_DS",
        "LevelColor_level2_r_2Ty",
        "LevelColor_level3_alWBg",
        "LevelColor_level4_fOPlt",
        "LevelColor_level5_kB3gW",
        "LevelColor_level6_Z8Lpr",
        "LevelColor_level7_H7ZIo",
        "LevelColor_level8_vWDa8",
        "LevelColor_level9_izZRQ",
        "LevelColor_level10_ObLz5",
        "LevelColor_level11_xfLN8",
        "LevelColor_level12_qa8z6"
    ];
    var url = [];
    var nw = document.createElement("th");
    var txt = document.createTextNode("投票値");
    nw.appendChild(txt);
    document.querySelector("thead.DifficultyList_header_kKDc5 > tr").insertBefore(nw,document.querySelectorAll("thead.DifficultyList_header_kKDc5 > tr > th")[1]);
    for (var i = 0;i < name.length;++i){
        url.push(day[i].innerHTML.replace("一次予選","予選1-").replace("二次予選","予選2-").replace("春トレ","春合宿").replace("セミファイナル","本選").replace("ファイナル","春合宿"));
        var ne = document.createElement("td");
        var text = document.createTextNode(":|");
        ne. classList.add("DifficultyListItem_level_WJAu6","vote_level");
        ne.appendChild(text);
        par[i].insertBefore(ne,name[i]);
    }
    var vote = document.getElementsByClassName("vote_level");
    try {
        const response = fetch("https://raw.githubusercontent.com/DeltaStruct/JOI_Difficulty_Acquisition/refs/heads/main/main.json").then(response => {
            return response.json();
        }).then(json => {
            for (var i = 0;i < name.length;++i) if (url[i] in json){
                var nw = vote[i];
                var lv = Math.max(0,Math.min(12,Math.round(parseFloat(json[url[i]]))));
                console.log(lv);
                nw. classList.add(attr[lv]);
                nw.textContent = json[url[i]];
            } else {
                var nw = vote[i];
                nw. classList.add("LevelColor_level0_r8zaq");
                nw.textContent = '?';
            }
        }).catch(e => {
            console.log(e.message);
            for (var i = 0;i < name.length;++i){
                var nw = vote[i];
                nw. classList.add("LevelColor_level0_r8zaq");
                nw.textContent = ':(';
            }
        });
    } catch(e) {
        console.log(e.message);
        for (var i = 0;i < name.length;++i){
            var nw = vote[i];
            nw. classList.add("LevelColor_level0_r8zaq");
            nw.textContent = ':(';
        }
    }
    /*
    return 0;
    for (var i = 0;i < name.length;++i){
        fetch(url[i]).then(response => {
            var idx = url.indexOf(decodeURI(response.url));
            if (response.ok){
                response.text().then(text => {
                    var nw = vote[idx];
                    var lv = Math.max(0,Math.min(12,Math.round(parseFloat(text))));
                    nw. classList.add(attr[lv]);
                    nw.textContent = text;
                });
            } else {
                var nw = vote[idx];
                nw. classList.add("LevelColor_level0_r8zaq");
                nw.textContent = '?';
            }
        });
    }*/
})();