UnknownCheats Auto Dark Theme

Auto-enable dark theme on UnknownCheats

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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();
})();