Nitro Type Focus Mode

Toggle focus mode on Nitro Type with "=" key to hide distractions and improve focus.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Nitro Type Focus Mode
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Toggle focus mode on Nitro Type with "=" key to hide distractions and improve focus.
// @author       King's Group
// @match        https://www.nitrotype.com/*
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let focusMode = false;
    const dimOverlay = document.createElement("div");
    dimOverlay.style.position = "fixed";
    dimOverlay.style.top = "0";
    dimOverlay.style.left = "0";
    dimOverlay.style.width = "100%";
    dimOverlay.style.height = "100%";
    dimOverlay.style.backgroundColor = "rgba(0, 0, 0, 0.4)";
    dimOverlay.style.zIndex = "999";
    dimOverlay.style.pointerEvents = "none";
    dimOverlay.style.transition = "opacity 0.4s ease";
    dimOverlay.style.opacity = "0";
    document.body.appendChild(dimOverlay);

    function toggleFocusMode() {
        focusMode = !focusMode;
        const elementsToHide = [
            "#header", 
            ".race-results", 
            ".race-chat", 
            ".race-track .opponents", 
            ".garage-banner", 
            ".adsbygoogle",
            "#footer",
            ".race-rankings",
            ".social-container",
            ".friends-list"
        ];

        elementsToHide.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => {
                el.style.transition = "opacity 0.4s ease";
                el.style.opacity = focusMode ? "0" : "1";
                el.style.pointerEvents = focusMode ? "none" : "auto";
            });
        });

        dimOverlay.style.opacity = focusMode ? "1" : "0";
        console.log(`🎯 Focus Mode: ${focusMode ? "ON" : "OFF"}`);
    }

    // Listen for "=" key press
    document.addEventListener("keydown", (e) => {
        if (e.key === "=") {
            toggleFocusMode();
        }
    });

})();