您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
开启知乎夜间模式,并且跟随系统主题自动切换,切换后刷新网页不会出现闪白的情况
当前为
// ==UserScript== // @name 知乎夜间模式 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 开启知乎夜间模式,并且跟随系统主题自动切换,切换后刷新网页不会出现闪白的情况 // @author Starry // @match *://*.zhihu.com/* // @grant none // @run-at document-end // ==/UserScript== ;(function () { 'use strict' const queryString = '(prefers-color-scheme: dark)' const nowSysTheme = () => window.matchMedia(queryString).matches const changeTheme = isDark => { if (isDark) { fetch('/?theme=dark') document .getElementsByTagName('html')[0] .setAttribute('data-theme', 'dark') } else { fetch('/?theme=light') var html = document.getElementsByTagName('html')[0] html.getAttribute('data-theme') ? html.setAttribute('data-theme', 'light') : null } } changeTheme(nowSysTheme()) window.matchMedia(queryString).addEventListener('change', function (e) { changeTheme(e.matches) }) })()