Skip to content

Commit 5ccf5f0

Browse files
committed
新增 [优化暗黑模式(知乎自带)] 功能
1 parent 93857fb commit 5ccf5f0

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

Zhihu-Beautification.user.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 知乎美化
3-
// @version 1.1.2
3+
// @version 1.1.3
44
// @author X.I.U
5-
// @description 宽屏显示、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示
5+
// @description 宽屏显示、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、优化暗黑模式(知乎自带)、文章编辑页面与实际文章宽度一致、屏蔽登录提示
66
// @match *://www.zhihu.com/*
77
// @match *://zhuanlan.zhihu.com/p/*
88
// @icon https://static.zhihu.com/heifetz/favicon.ico
@@ -22,7 +22,8 @@
2222
['menu_widescreenDisplay', '宽屏显示', '一键收起回答', true],
2323
['menu_picHeight', '调整图片最大高度', '调整图片最大高度', true],
2424
['menu_postimg', '隐藏文章开头大图', '隐藏文章开头大图', true],
25-
['menu_hideTitle', '向下翻时自动隐藏顶栏', '向下翻时自动隐藏顶栏', true]
25+
['menu_hideTitle', '向下翻时自动隐藏顶栏', '向下翻时自动隐藏顶栏', true],
26+
['menu_darkMode', '优化暗黑模式(知乎自带)', '优化暗黑模式', true]
2627
], menu_ID = [];
2728
for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值
2829
if (GM_getValue(menu_ALL[i][0]) == null){GM_setValue(menu_ALL[i][0], menu_ALL[i][3])};
@@ -116,6 +117,25 @@ header.is-hidden {
116117
max-height: 500px;
117118
width: auto;
118119
}
120+
`,
121+
style_6 = `/* 优化暗黑模式(知乎自带)*/
122+
/* 文字颜色 */
123+
html[data-theme=dark] body {color: #ccc !important;}
124+
html[data-theme=dark] .ContentItem-title, html[data-theme=dark] .QuestionHeader-title {color: #ddd !important;}
125+
/* 背景颜色 - 网页 */
126+
html[data-theme=dark] body {background: #22272E !important;}
127+
/* 背景颜色 - 问题 */
128+
html[data-theme=dark] .AppHeader, html[data-theme=dark] .QuestionHeader, html[data-theme=dark] .QuestionHeader-footer, html[data-theme=dark] .Input-wrapper.Input-wrapper--grey, html[data-theme=dark] .EmoticonsFooter-item--selected, html[data-theme=dark] .Card, html[data-theme=dark] .ContentItem-actions, html[data-theme=dark] .MoreAnswers .List-headerText, html[data-theme=dark] .CommentsV2-withPagination, html[data-theme=dark] .Topbar, html[data-theme=dark] .CommentsV2-footer, html[data-theme=dark] .CommentEditorV2-inputWrap--active, html[data-theme=dark] .InputLike, html[data-theme=dark] .Popover-content, html[data-theme=dark] .Notifications-footer, html[data-theme=dark] .Messages-footer, html[data-theme=dark] .Modal-inner, html[data-theme=dark] .Emoticons, html[data-theme=dark] .EmoticonsFooter, html[data-theme=dark] .SearchTabs {background: #1c2129 !important;}
129+
html[data-theme=dark] .CommentListV2-header-divider, html[data-theme=dark] .CommentsV2-openComment-divider {background-color: #222933 !important;}
130+
/* 背景颜色 - 用户页面 */
131+
html[data-theme=dark] .ProfileHeader-wrapper, html[data-theme=dark] .UserCover {background: #1c2129 !important;}
132+
/* 背景颜色 - 用户页面 - 封面大图 */
133+
html[data-theme=dark] .UserCover {opacity: 0.7;}
134+
/* 边框 */
135+
html[data-theme=dark] .Topbar, html[data-theme=dark] .CommentsV2-footer, html[data-theme=dark] .Topstory-mainColumnCard .Card:not(.Topstory-tabCard), html[data-theme=dark] .NestComment:not(:last-child):after, html[data-theme=dark] .NestComment--rootComment:after, html[data-theme=dark] .NestComment .NestComment--child:after, html[data-theme=dark] .NestComment .NestComment--child:after, html[data-theme=dark] .CommentsV2-replyNum, html[data-theme=dark] .CommentItemV2:not(:first-child):after {border-bottom: 1px solid #1c2129 !important;}
136+
/* 背景颜色 - 专栏/文章 */
137+
html[data-theme=dark] .WhiteBg-body, html[data-theme=dark] .Post-content {background: #22272E !important;}
138+
html[data-theme=dark] .ColumnPageHeader {background: #1c2129 !important;}
119139
`
120140
let style_Add = document.createElement('style');
121141
// 宽屏显示
@@ -134,6 +154,10 @@ header.is-hidden {
134154
if (menu_value('menu_hideTitle')) {
135155
style += style_4;
136156
}
157+
// 优化暗黑模式(知乎自带)
158+
if (menu_value('menu_darkMode')) {
159+
style += style_6;
160+
}
137161
// 文章编辑页面与实际文章宽度一致
138162
if(window.location.href.indexOf("zhuanlan") > -1){
139163
if(window.location.href.indexOf("/edit") > -1){

0 commit comments

Comments
 (0)