Skip to content

Commit 7c0ac79

Browse files
committed
新增 [宽屏显示 - 首页]、[宽屏显示 - 问题页]、[宽屏显示 - 搜索页]、[宽屏显示 - 收藏页] 脚本菜单开关; 优化 暗黑模式样式一
1 parent 51ea58e commit 7c0ac79

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

Zhihu-Beautification.user.js

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 知乎美化
3-
// @version 1.3.0
3+
// @version 1.3.1
44
// @author X.I.U
55
// @description 宽屏显示、暗黑模式(4种)、暗黑模式跟随浏览器、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致、屏蔽登录提示
66
// @match *://www.zhihu.com/*
@@ -24,6 +24,10 @@
2424
'use strict';
2525
var menu_ALL = [
2626
['menu_widescreenDisplay', '宽屏显示', '宽屏显示', true],
27+
['menu_widescreenDisplayIndex', '宽屏显示 - 首页', '宽屏显示 - 首页', true],
28+
['menu_widescreenDisplayQuestion', '宽屏显示 - 问题页', '宽屏显示 - 问题页', true],
29+
['menu_widescreenDisplaySearch', '宽屏显示 - 搜索页', '宽屏显示 - 搜索页', true],
30+
['menu_widescreenDisplayCollection', '宽屏显示 - 收藏页', '宽屏显示 - 收藏页', true],
2731
['menu_darkMode', '暗黑模式', '暗黑模式', true],
2832
['menu_darkModeType', '暗黑模式切换(1~4)', '暗黑模式切换', 1],
2933
['menu_darkModeAuto', '暗黑模式跟随浏览器', '暗黑模式跟随浏览器', false],
@@ -52,6 +56,10 @@
5256
GM_setValue('menu_darkModeType', menu_ALL[i][3]);
5357
}
5458
menu_ID[i] = GM_registerMenuCommand(`${menu_num(menu_ALL[i][3])} ${menu_ALL[i][1]}`, function(){menu_toggle(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`)});
59+
} else if (menu_ALL[i][0] === 'menu_widescreenDisplayIndex' || menu_ALL[i][0] === 'menu_widescreenDisplayQuestion' || menu_ALL[i][0] === 'menu_widescreenDisplaySearch' || menu_ALL[i][0] === 'menu_widescreenDisplayCollection') {
60+
if (menu_value('menu_widescreenDisplay')) {
61+
menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
62+
}
5563
} else {
5664
menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
5765
}
@@ -122,7 +130,7 @@
122130

123131
// 添加样式
124132
function addStyle() {
125-
let style = `/* 屏蔽登录提示 */
133+
let style = `/* 屏蔽登录提示(问题页中间的元素) */
126134
.Question-mainColumnLogin {display: none !important;}
127135
/* 屏蔽首页广告 */
128136
.TopstoryItem--advertCard {display: none !important;}
@@ -131,19 +139,23 @@
131139
/* 屏蔽文章页推荐文章 */
132140
.Recommendations-Main {display: none !important;}
133141
`,
134-
style_1 = `/* 宽屏显示 */
135-
.GlobalSideBar, .Question-sideColumn, .ContentLayout-sideColumn, .SearchSideBar, .Card.QuestionHeaderTopicMeta, .ClubSideBar {
136-
display: none !important;
137-
}
138-
.Topstory-mainColumn, .Question-mainColumn, .ContentLayout-mainColumn,.SearchMain, .QuestionWaiting-mainColumn, .Club-mainColumn, .Post-mainColumn {
139-
width: 1000px !important;
140-
}
141-
.QuestionWaiting-mainColumn {
142-
margin-right: 0 !important;
143-
}
144-
.ImageMessage-ImageView {
145-
z-index: 999 !important;
146-
}`,
142+
style_widescreenDisplayIndex = `/* 宽屏显示 - 首页 */
143+
.Topstory-mainColumn {width: 1000px !important;}
144+
.GlobalSideBar {display: none !important;}
145+
`,
146+
style_widescreenDisplayQuestion = `/* 宽屏显示 - 问题页 */
147+
.Question-mainColumn, .ListShortcut {width: 1000px !important;}
148+
.Question-sideColumn {display: none !important;}
149+
.QuestionWaiting-mainColumn {margin-right: 0 !important;}
150+
`,
151+
style_widescreenDisplaySearch = `/* 宽屏显示 - 搜索页 */
152+
.SearchMain, .ContentLayout-mainColumn, .QuestionWaiting-mainColumn, .Club-mainColumn, .Post-mainColumn {width: 1000px !important;}
153+
.SearchSideBar, .ContentLayout-sideColumn, .Card.QuestionHeaderTopicMeta, .ClubSideBar {display: none !important;}
154+
`,
155+
style_widescreenDisplayCollection = `/* 宽屏显示 - 收藏页 */
156+
.CollectionsDetailPage-mainColumn {width: 1000px !important;}
157+
.CollectionDetailPageSideBar {display: none !important;}
158+
`,
147159
style_2 = `/* 隐藏在各列表中查看文章时开头显示的大图,不影响文章、专栏页面 */
148160
.RichContent img.ArticleItem-image {display: none !important;}
149161
`,
@@ -175,8 +187,8 @@ html[data-theme=dark] .Highlight em {color: #c33c39 !important;}
175187
/* 背景颜色 - 网页 */
176188
html[data-theme=dark] body, html[data-theme=dark] .Select-option:focus {background: #22272E !important;}
177189
/* 背景颜色 - 问题 */
178-
html[data-theme=dark] .AppHeader, html[data-theme=dark] .QuestionHeader, html[data-theme=dark] .QuestionHeader-footer, 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, html[data-theme=dark] .Popover-arrow:after, html[data-theme=dark] .CommentEditorV2-inputWrap, html[data-theme=dark] .ProfileHeader-wrapper, html[data-theme=dark] .UserCover, html[data-theme=dark] .AnswerForm-footer, html[data-theme=dark] .Editable-toolbar, html[data-theme=dark] .AnswerForm-fullscreenContent .Editable-toolbar, html[data-theme=dark] .KfeCollection-PcCollegeCard-wrapper, html[data-theme=dark] .KfeCollection-PcCollegeCard-root, html[data-theme=dark] .HotItem, html[data-theme=dark] .HotList, html[data-theme=dark] .HotListNavEditPad, html[data-theme=dark] .QuestionWaiting-typesTopper, html[data-theme=dark] .QuestionWaiting-types, html[data-theme=dark] .PostItem, html[data-theme=dark] .ClubSideBar section, html[data-theme=dark] .SearchSubTabs, html[data-theme=dark] .Club-SearchPosts-Content, html[data-theme=dark] .Club-content, html[data-theme=dark] .ClubJoinOrCheckinButton, html[data-theme=dark] .ClubEdit, html[data-theme=dark] .CornerButton, html[data-theme=dark] .Notifications-Section-header, html[data-theme=dark] .NotificationList, .NotificationList-Item.NotificationList-Item:after, .NotificationList-DateSplit.NotificationList-DateSplit:after, html[data-theme=dark] .Chat, .ChatUserListItem:after, .ChatListGroup-SectionTitle--bottomBorder:after, html[data-theme=dark] .ActionMenu, .ChatSideBar-Search--active, html[data-theme=dark] .ChatSideBar-Search-ResultListWrap, html[data-theme=dark] .QuestionMainDivider-inner, html[data-theme=dark] .Topic-bar, html[data-theme=dark] .AnnotationTag, html[data-theme=dark] .HoverCard, html[data-theme=dark] .HoverCard-loading, html[data-theme=dark] .ExploreSpecialCard, html[data-theme=dark] .ExploreHomePage-ContentSection-moreButton a, html[data-theme=dark] .ExploreRoundtableCard, html[data-theme=dark] .ExploreCollectionCard, html[data-theme=dark] .ExploreColumnCard, html[data-theme=dark] .RichText .lazy[data-lazy-status], html[data-theme=dark] #TopstoryContent > div:first-child, html[data-theme=dark] .Topstory-newUserFollowCountPanel {background: #2D333B !important;}
179-
html[data-theme=dark] .CommentListV2-header-divider, html[data-theme=dark] .CommentsV2-openComment-divider, html[data-theme=dark] .AnswerForm-fullscreenScroller, html[data-theme=dark] .HotListNav-item, html[data-theme=dark] .AutoInviteItem-wrapper--desktop, html[data-theme=dark] .ExploreSpecialCard-contentTag, html[data-theme=dark] .ExploreCollectionCard-contentTypeTag, html[data-theme=dark] .Reward-TipjarDialog-tagLine {background-color: #222933 !important;}
190+
html[data-theme=dark] .AppHeader, html[data-theme=dark] .QuestionHeader, html[data-theme=dark] .QuestionHeader-footer, 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, html[data-theme=dark] .Popover-arrow:after, html[data-theme=dark] .CommentEditorV2-inputWrap, html[data-theme=dark] .ProfileHeader-wrapper, html[data-theme=dark] .UserCover, html[data-theme=dark] .AnswerForm-footer, html[data-theme=dark] .Editable-toolbar, html[data-theme=dark] .AnswerForm-fullscreenContent .Editable-toolbar, html[data-theme=dark] .KfeCollection-PcCollegeCard-wrapper, html[data-theme=dark] .KfeCollection-PcCollegeCard-root, html[data-theme=dark] .HotItem, html[data-theme=dark] .HotList, html[data-theme=dark] .HotListNavEditPad, html[data-theme=dark] .QuestionWaiting-typesTopper, html[data-theme=dark] .QuestionWaiting-types, html[data-theme=dark] .PostItem, html[data-theme=dark] .ClubSideBar section, html[data-theme=dark] .SearchSubTabs, html[data-theme=dark] .Club-SearchPosts-Content, html[data-theme=dark] .Club-content, html[data-theme=dark] .ClubJoinOrCheckinButton, html[data-theme=dark] .ClubEdit, html[data-theme=dark] .CornerButton, html[data-theme=dark] .Notifications-Section-header, html[data-theme=dark] .NotificationList, .NotificationList-Item.NotificationList-Item:after, .NotificationList-DateSplit.NotificationList-DateSplit:after, html[data-theme=dark] .Chat, .ChatUserListItem:after, .ChatListGroup-SectionTitle--bottomBorder:after, html[data-theme=dark] .ActionMenu, .ChatSideBar-Search--active, html[data-theme=dark] .ChatSideBar-Search-ResultListWrap, html[data-theme=dark] .QuestionMainDivider-inner, html[data-theme=dark] .Topic-bar, html[data-theme=dark] .AnnotationTag, html[data-theme=dark] .HoverCard, html[data-theme=dark] .HoverCard-loading, html[data-theme=dark] .ExploreSpecialCard, html[data-theme=dark] .ExploreHomePage-ContentSection-moreButton a, html[data-theme=dark] .ExploreRoundtableCard, html[data-theme=dark] .ExploreCollectionCard, html[data-theme=dark] .ExploreColumnCard, html[data-theme=dark] .RichText .lazy[data-lazy-status], html[data-theme=dark] #TopstoryContent > div:first-child, html[data-theme=dark] .Topstory-newUserFollowCountPanel, html[data-theme=dark] .AnswerForm-fullscreenContent .RichText {background: #2D333B !important;}
191+
html[data-theme=dark] .CommentListV2-header-divider, html[data-theme=dark] .CommentsV2-openComment-divider, html[data-theme=dark] .AnswerForm-fullscreenScroller, html[data-theme=dark] .HotListNav-item, html[data-theme=dark] .AutoInviteItem-wrapper--desktop, html[data-theme=dark] .ExploreSpecialCard-contentTag, html[data-theme=dark] .ExploreCollectionCard-contentTypeTag, html[data-theme=dark] .Reward-TipjarDialog-tagLine, html[data-theme=dark] .AnswerForm-footer.useNewEditorSetting > div, html[data-theme=dark] .AnswerForm-fullscreenContent > div:first-child, html[data-theme=dark] .Editable-toolbar button:hover, html[data-theme=dark] .AuthorInfo.AnswerAdd-info + div {background-color: #222933 !important;}
180192
html[data-theme=dark] .CornerButton:hover {background: #3f4752 !important;} /* 右下角按钮 */
181193
182194
/* 背景颜色 - 引用 */
@@ -225,8 +237,8 @@ html[data-theme=dark] img {opacity: 0.8 !important;}
225237
html[data-theme=dark] .GifPlayer img, html[data-theme=dark] .ImageView-img {opacity: 1 !important;}
226238
227239
/* 边框 */
228-
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, html[data-theme=dark] .Tabs, html[data-theme=dark] .Popover-arrow:after {border-bottom: 1px solid #282d35 !important;}
229-
html[data-theme=dark] .CommentEditorV2-inputWrap--active, html[data-theme=dark] .CommentEditorV2-inputWrap, html[data-theme=dark] .PostItem {border: none !important;}
240+
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, html[data-theme=dark] .Tabs, html[data-theme=dark] .Popover-arrow:after, html[data-theme=dark] .SelfCollectionItem-innerContainer, html[data-theme=dark] .CollectionDetailPageItem-innerContainer {border-bottom: 1px solid #282d35 !important;}
241+
html[data-theme=dark] .CommentEditorV2-inputWrap--active, html[data-theme=dark] .CommentEditorV2-inputWrap, html[data-theme=dark] .PostItem, html[data-theme=dark] .AnswerForm .Editable-toolbar, html[data-theme=dark] .Editable-toolbar span {border: none !important;}
230242
html[data-theme=dark] .InputLike {border: 1px solid #424b56 !important;}
231243
html[data-theme=dark] .Popover .InputLike {border: 1px solid #2d333b !important;}
232244
html[data-theme=dark] .HotLanding-contentItem:not(:last-child) {border-bottom: 1px solid #424b56 !important;}
@@ -355,7 +367,12 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
355367
}
356368

357369
// 宽屏显示
358-
if (menu_value('menu_widescreenDisplay')) style += style_1;
370+
if (menu_value('menu_widescreenDisplay')){
371+
if (menu_value('menu_widescreenDisplayIndex')) style += style_widescreenDisplayIndex;
372+
if (menu_value('menu_widescreenDisplayQuestion') && location.pathname.indexOf('/question/') > -1) style += style_widescreenDisplayQuestion;
373+
if (menu_value('menu_widescreenDisplaySearch') && (location.pathname === '/search' || location.pathname.indexOf('/club/') > -1 || location.pathname.indexOf('/topic/') > -1)) style += style_widescreenDisplaySearch;
374+
if (menu_value('menu_widescreenDisplayCollection') && location.pathname.indexOf('/collection/') > -1) style += style_widescreenDisplayCollection;
375+
}
359376
// 调整图片最大高度
360377
if (menu_value('menu_picHeight')) style += style_5;
361378
// 隐藏文章开头大图

0 commit comments

Comments
 (0)