Nitro Type - Hide Speed During Race

Hides WPM/speed during races to reduce anxiety, shows it again after race ends

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 // ==UserScript==

// @name         Nitro Type - Hide Speed During Race

// @namespace    nitrotype-hide-speed

// @version      1.0

// @description  Hides WPM/speed during races to reduce anxiety, shows it again after race ends

// @match        https://www.nitrotype.com/*

// @grant        none

// ==/UserScript==

(function () {

    'use strict';

    const HIDE_STYLE = 'visibility: hidden !important;';

    const SHOW_STYLE = 'visibility: visible !important;';

    function hideSpeed() {

        const speedElements = document.querySelectorAll(

            '.raceStats, .raceStats__wpm, .raceStats__value'

        );

        speedElements.forEach(el => el.style = HIDE_STYLE);

    }

    function showSpeed() {

        const speedElements = document.querySelectorAll(

            '.raceStats, .raceStats__wpm, .raceStats__value'

        );

        speedElements.forEach(el => el.style = SHOW_STYLE);

    }

    // Observe page changes (Nitro Type is SPA-based)

    const observer = new MutationObserver(() => {

        const inRace = document.querySelector('.raceContainer');

        const raceFinished = document.querySelector('.results');

        if (inRace && !raceFinished) {

            hideSpeed();

        }

        if (raceFinished) {

            showSpeed();

        }

    });

    observer.observe(document.body, {

        childList: true,

        subtree: true

    });

})();