优化 [暗黑模式] 代码逻辑

This commit is contained in:
xiu2
2021-05-07 08:46:01 +08:00
parent da6cd4a898
commit fe07e1207c
+7 -2
View File
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 知乎美化
// @version 1.1.13
// @version 1.1.14
// @author X.I.U
// @description 宽屏显示、暗黑模式(4种)、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示
// @match *://www.zhihu.com/*
@@ -20,7 +20,7 @@
(function() {
var menu_ALL = [
['menu_widescreenDisplay', '宽屏显示', '宽屏显示', true],
['menu_darkMode', '暗黑模式', '暗黑模式', false],
['menu_darkMode', '暗黑模式', '暗黑模式', true],
['menu_darkModeType', '暗黑模式切换(1~4', '暗黑模式切换', 1],
['menu_picHeight', '调整图片最大高度', '调整图片最大高度', true],
['menu_postimg', '隐藏文章开头大图', '隐藏文章开头大图', true],
@@ -250,6 +250,11 @@ html {filter: brightness(75%) sepia(30%) !important;}
switch(menu_value('menu_darkModeType')) {
case 1:
style += style_6;
if (getTheme() === 'light') {
document.cookie="theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/";
document.getElementsByTagName('html')[0].setAttribute('data-theme', 'dark')
location.reload(); // 刷新网页
}
break;
case 2:
style += style_7;