Greasy Fork

Greasy Fork is available in English.

Hydro 难度数字转文字

将难度一栏的数字改为文字

当前为 2024-10-05 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hydro 难度数字转文字
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  将难度一栏的数字改为文字
// @author       YourName
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 定义难度对应的文字和颜色
    const difficultyMap = {
        1: { text: '入门', color: '#FE4C61' },
        2: { text: '普及-', color: '#F39C11' },
        3: { text: '普及', color: '#FFC116' },
        4: { text: '普及+', color: '#52C41A' },
        5: { text: '提高+', color: '#3498DB' },
        6: { text: '省选', color: '#9D3DCF' },
        7: { text: 'NOI', color: '#0E1D69' },
        8: { text: '未评定', color: '#BFBFBF' },
        9: { text: '未评定', color: '#BFBFBF' },
        10: { text: '未评定', color: '#BFBFBF' },
        '(无)': { text: '未评定', color: '#BFBFBF' },
    };
    window.addEventListener('load', function() {
        const difficultyCells = document.querySelectorAll('td.col--difficulty');

        difficultyCells.forEach(cell => {
            const difficultyNumber = cell.textContent.trim();
            if (difficultyMap[difficultyNumber]) {
                cell.textContent = difficultyMap[difficultyNumber].text;
                cell.style.color = difficultyMap[difficultyNumber].color;
            }
        });
    });
})();