Skip to content

Commit fe07e12

Browse files
committed
优化 [暗黑模式] 代码逻辑
1 parent da6cd4a commit fe07e12

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Zhihu-Beautification.user.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 知乎美化
3-
// @version 1.1.13
3+
// @version 1.1.14
44
// @author X.I.U
55
// @description 宽屏显示、暗黑模式(4种)、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示
66
// @match *://www.zhihu.com/*
@@ -20,7 +20,7 @@
2020
(function() {
2121
var menu_ALL = [
2222
['menu_widescreenDisplay', '宽屏显示', '宽屏显示', true],
23-
['menu_darkMode', '暗黑模式', '暗黑模式', false],
23+
['menu_darkMode', '暗黑模式', '暗黑模式', true],
2424
['menu_darkModeType', '暗黑模式切换(1~4)', '暗黑模式切换', 1],
2525
['menu_picHeight', '调整图片最大高度', '调整图片最大高度', true],
2626
['menu_postimg', '隐藏文章开头大图', '隐藏文章开头大图', true],
@@ -250,6 +250,11 @@ html {filter: brightness(75%) sepia(30%) !important;}
250250
switch(menu_value('menu_darkModeType')) {
251251
case 1:
252252
style += style_6;
253+
if (getTheme() === 'light') {
254+
document.cookie="theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/";
255+
document.getElementsByTagName('html')[0].setAttribute('data-theme', 'dark')
256+
location.reload(); // 刷新网页
257+
}
253258
break;
254259
case 2:
255260
style += style_7;

0 commit comments

Comments
 (0)