您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Turn on/off dark mode automatically in v2ex.com based on the color scheme of OS.
当前为
// ==UserScript== // @name V2EX Auto Dark Mode // @namespace http://tampermonkey.net/ // @version 0.1 // @description Turn on/off dark mode automatically in v2ex.com based on the color scheme of OS. // @author Jiachen Chen // @match *://*.v2ex.com/* // @match *://v2ex.com/* // @icon https://www.google.com/s2/favicons?domain=v2ex.com // @grant none // ==/UserScript== (function() { 'use strict'; const toggleLink = document.querySelector('.light-toggle').getAttribute('href'); if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { if (SITE_NIGHT) { window.location.replace(toggleLink); } } window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', e => { if (SITE_NIGHT) { window.location.replace(toggleLink); } }); if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { if (SITE_NIGHT === 0) { window.location.replace(toggleLink); } } window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { if (SITE_NIGHT === 0) { window.location.replace(toggleLink); } }); })();