Greasy Fork 还支持 简体中文。

Codeforces Rating Hider

Changes the displayed difficulty on Codeforces problemset to XXXX

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Codeforces Rating Hider
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Changes the displayed difficulty on Codeforces problemset to XXXX
// @author       Zafir Hasan Anogh
// @match        https://codeforces.com/
// @match        https://codeforces.com/*
// @grant        none
// @run-at       document-idle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideDifficulty() {
        const difficultySpans = document.querySelectorAll('span[title="Difficulty"]');

        difficultySpans.forEach(span => {
            if (span.innerText !== 'XXXX') {
                span.innerText = 'XXXX';
            }
        });
    }

    hideDifficulty();

    const observer = new MutationObserver(function(mutationsList, observer) {
        let needsUpdate = false;
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                for (const node of mutation.addedNodes) {
                    if (node.nodeType === Node.ELEMENT_NODE) {
                        if (node.matches('span[title="Difficulty"]') || node.querySelector('span[title="Difficulty"]')) {
                            needsUpdate = true;
                            break;
                        }
                    }
                }
            }
            if (needsUpdate) break;
        }

        if (needsUpdate) {
            hideDifficulty();
        } else {
            const anyVisibleDifficulty = document.querySelector('span[title="Difficulty"]:not(:empty)');
            if (anyVisibleDifficulty && anyVisibleDifficulty.innerText !== 'XXXX') {
                hideDifficulty();
            }
        }
    });

    const targetNode = document.body;
    const config = { childList: true, subtree: true };

    if (targetNode) {
        observer.observe(targetNode, config);
    }

    window.addEventListener('load', hideDifficulty);

})();