UnknownCheats Auto Dark Theme

Auto-enable dark theme on UnknownCheats

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         UnknownCheats Auto Dark Theme
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Auto-enable dark theme on UnknownCheats
// @author       LeonardoVAC
// @match        https://www.unknowncheats.me/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Simple function to check if dark mode is active
    function isDarkMode() {
        // Check for uc_dark.css in stylesheets
        const stylesheets = document.querySelectorAll('link[rel="stylesheet"]');
        for (let stylesheet of stylesheets) {
            if (stylesheet.href && stylesheet.href.includes('uc_dark.css')) {
                return true;
            }
        }
        return false;
    }

    // Simple toggle function
    function toggleTheme() {
        if (typeof window.toggle_dark_theme === 'function') {
            window.toggle_dark_theme();
            return true;
        }
        return false;
    }

    // Make function globally accessible
    window.ucIsDarkMode = isDarkMode;

    // Toggle to dark mode if currently in light mode
    function toggleToDark() {
        if (typeof window.toggle_dark_theme === 'function' && !isDarkMode()) {
            console.log('Auto-toggling to dark mode...');
            window.toggle_dark_theme();
        }
    }

    // Initialize when ready
    function init() {
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', init);
            return;
        }

        console.log('UnknownCheats Auto Dark Theme loaded');
        console.log('Current theme:', isDarkMode() ? 'Dark' : 'Light');

        // Auto-toggle to dark mode after a short delay
        toggleToDark();
    }

    init();
})();