Roblox Force Dark Theme

Always forces Roblox to use the Dark theme

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Roblox Force Dark Theme
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Always forces Roblox to use the Dark theme
// @author       Fidelity
// @match        https://www.roblox.com/*
// @icon         https://img.icons8.com/?size=100&id=101343&format=png&color=FFFFFF
// @license      MIT
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
    function SetDarkMode() {
        localStorage.setItem('theme', `{"version":0,"data":[[${document.querySelector('meta[name="user-data"]').dataset.userid},1]]}`);
        document.documentElement.classList.add('dark-theme');
        if (document.body) {
            document.body.classList.remove('system-theme');
            document.body.classList.remove('light-theme');
            document.body.classList.add('dark-theme');
        }
    }

    SetDarkMode();
    document.addEventListener('DOMContentLoaded', SetDarkMode);

    new MutationObserver(() => {
        const el = document.body || document.documentElement;
        if (!el.classList.contains('dark-theme')) {
            SetDarkMode();
        }
    }).observe(document.documentElement, {
        attributes: true,
        attributeFilter: ['class'],
        subtree: true
    });
})();