Codeforces Verdict Hidden Tool

The tool show codeforces submission status without which test case. For competitors practicing for the domjudge environment.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Codeforces Verdict Hidden Tool
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  The tool show codeforces submission status without which test case. For competitors practicing for the domjudge environment.
// @license      MIT
// @author       jakao
// @match        https://codeforces.com/*
// @icon         https://i.imgur.com/ldVBpM1.jpeg
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function removeOnTest() {
        console.log('?!?');
        let walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
        let node;

        while (node = walker.nextNode()) {
            let textContent = node.nodeValue;
            let index = textContent.indexOf(' on test');

            if (index !== -1) {
                node.nodeValue = textContent.substring(0, index);
                nextNode = walker.nextNode();
                nextNode.nodeValue = "";
            }
            else{
                pretestIndex = textContent.indexOf(' on pretest');
                if (pretestIndex !== -1) {
                    node.nodeValue = textContent.substring(0, pretestIndex);
                    nextNode = walker.nextNode();
                    nextNode.nodeValue = "";
                }
            }
        }
        console.log('???');
    }

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                removeOnTest();
            }
        });
    });
    console.log('!!!');

    const observerConfig = {
        childList: true,
        subtree: true,
        characterData: true
    };

    removeOnTest();

    observer.observe(document.body, observerConfig);
})();