您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Chrome-like dark mode with adjusted colors for better readability.
// ==UserScript== // @name Universal Dark Mode 2 (Chrome-like) // @match *://*/* // @grant none // @version 1.5 // @author almahmud & gpt // @homepageURL https://github.com/almahmudbd/universal-dark-mode // @description Chrome-like dark mode with adjusted colors for better readability. // @license GPL-2.0 // @run-at document-start // @namespace https://greasyfork.org/users/1238578 // ==/UserScript== const setDarkModeCookie = (value) => { document.cookie = `darkMode=${value}; path=/; max-age=2592000`; // 1 month expiration }; const getDarkModeCookie = () => { const match = document.cookie.match(/darkMode=([^;]+)/); return match ? match[1] === 'true' : false; // Default to false }; const isDarkMode = getDarkModeCookie(); // Set a base background color to prevent flash document.documentElement.style.backgroundColor = "#263238"; // Dark grey-blue color for background const applyDarkModeStyles = () => { const elements = document.querySelectorAll("*"); elements.forEach((element) => { const computedStyle = window.getComputedStyle(element); const backgroundColor = computedStyle.backgroundColor; // Apply dark background to all elements except images and videos if (!backgroundColor.includes("rgba") && !backgroundColor.includes("transparent")) { element.style.backgroundColor = "#263238"; } // Change text color to white element.style.color = "#ffffff"; }); }; // Apply dark mode immediately if cookie is set if (isDarkMode) { applyDarkModeStyles(); } // Adjust colors function const adjustColors = () => { const elements = document.querySelectorAll("*"); elements.forEach((element) => { const computedStyle = window.getComputedStyle(element); if (computedStyle.backgroundColor !== "rgba(0, 0, 0, 0)" && computedStyle.backgroundColor !== "transparent") { element.style.backgroundColor = "#263238"; // Dark grey-blue for background } element.style.color = "#ffffff"; // White text color }); }; // Adjust colors when the document is ready document.onreadystatechange = () => { if (isDarkMode) { adjustColors(); } }; // Observe changes in the DOM new MutationObserver(adjustColors).observe(document.body, { subtree: true, childList: true });