Dark Mode

5/15/2025, 3:06:18 PM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Dark Mode
// @namespace   Violentmonkey Scripts
// @match       *://jav.guru/*
// @grant       none
// @version     1.0
// @author      -
// @description 5/15/2025, 3:06:18 PM
// ==/UserScript==

(function () {
    function addDarkClass() {
        if (!document.body.classList.contains("wp-night-mode-on")) {
            document.body.classList.add("wp-night-mode-on");
            console.log("[VM] wp-night-mode-on class added");
        }
    }

    // Wait until the DOM is ready and the body exists
    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", addDarkClass);
    } else {
        addDarkClass();
    }

    // Also use MutationObserver in case body is changed or replaced
    const observer = new MutationObserver(() => {
        addDarkClass();
    });

    observer.observe(document.documentElement, { childList: true, subtree: true });
})();