您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically switch the dark mode according to the system settings, which uses the official style
// ==UserScript== // @name YouTube auto dark mode // @version 1.0.0 // @description Automatically switch the dark mode according to the system settings, which uses the official style // @namespace https://youtube.com/ // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @author bowencool // @license MIT // @homepageURL https://gf.qytechs.cn/scripts/460040 // @supportURL https://github.com/bowencool/Tampermonkey-Scripts/issues // @grant none // ==/UserScript== (function () { "use strict"; window .matchMedia("(prefers-color-scheme: dark)") .addEventListener("change", (e) => { toggle(e.matches); }); function toggle( isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches ) { const currentTheme = document.querySelector("html").getAttribute("dark"); console.log({ isDarkMode, currentTheme }); if (isDarkMode) { if (currentTheme !== null) return; document.querySelector("html").setAttribute("dark", ""); } else { if (currentTheme === null) return; document.querySelector("html").removeAttribute("dark"); } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址