Skip to content

Commit 36c52e6

Browse files
committed
新增 [宽屏显示] 支持文章页
1 parent 547872d commit 36c52e6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Zhihu-Beautification.user.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 知乎美化
3-
// @version 1.3.7
3+
// @version 1.3.8
44
// @author X.I.U
55
// @description 宽屏显示、暗黑模式(4种)、暗黑模式跟随浏览器、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致
66
// @match *://www.zhihu.com/*
@@ -28,6 +28,7 @@
2828
['menu_widescreenDisplayQuestion', '问题页', '宽屏显示', true],
2929
['menu_widescreenDisplaySearch', '搜索页、话题页、圈子', '宽屏显示', true],
3030
['menu_widescreenDisplayCollection', '收藏页', '宽屏显示', true],
31+
['menu_widescreenDisplayPost', '文章页', '宽屏显示', false],
3132
['menu_widescreenDisplayWidth', '宽屏宽度', '宽屏宽度 (100~1000)', '1000'],
3233
['menu_darkMode', '暗黑模式', '暗黑模式', true],
3334
['menu_darkModeType', '暗黑模式切换(1~4)', '暗黑模式切换', 1],
@@ -59,7 +60,7 @@
5960
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]}`)});
6061
} else if (menu_ALL[i][0] === 'menu_widescreenDisplay'){
6162
GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){menu_setting('checkbox', menu_ALL[i][1], menu_ALL[i][2], true, [menu_ALL[i+1], menu_ALL[i+2], menu_ALL[i+3], menu_ALL[i+4], menu_ALL[i+5]])});
62-
} 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' && menu_ALL[i][0] != 'menu_widescreenDisplayWidth') {
63+
} else if (menu_ALL[i][0].indexOf('menu_widescreenDisplay') === -1) {
6364
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]}`)});
6465
}
6566
}
@@ -201,6 +202,10 @@
201202
.CollectionsDetailPage-mainColumn {width: inherit !important;}
202203
.CollectionDetailPageSideBar {display: none !important;}
203204
.CollectionsDetailPage {width: ${GM_getValue('menu_widescreenDisplayWidth')}px;}
205+
`,
206+
style_widescreenDisplayPost = `/* 宽屏显示 - 文章页 */
207+
.Post-SideActions {left: calc(10vw) !important;}
208+
.Post-NormalMain .Post-Header, .Post-NormalMain>div, .Post-NormalSub>div {width: ${GM_getValue('menu_widescreenDisplayWidth')}px !important;}
204209
`,
205210
style_2 = `/* 隐藏在各列表中查看文章时开头显示的大图,不影响文章、专栏页面 */
206211
.RichContent img.ArticleItem-image {display: none !important;}
@@ -417,6 +422,7 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
417422
if (menu_value('menu_widescreenDisplayQuestion') && location.pathname.indexOf('/question/') > -1) style += style_widescreenDisplayQuestion;
418423
if (menu_value('menu_widescreenDisplaySearch') && (location.pathname === '/search' || location.pathname.indexOf('/club/') > -1 || location.pathname.indexOf('/topic/') > -1)) style += style_widescreenDisplaySearch;
419424
if (menu_value('menu_widescreenDisplayCollection') && location.pathname.indexOf('/collection/') > -1) style += style_widescreenDisplayCollection;
425+
if (menu_value('menu_widescreenDisplayPost') && location.hostname.indexOf('zhuanlan') > -1 && location.pathname.indexOf('/edit') === -1) style += style_widescreenDisplayPost;
420426

421427
// 调整图片最大高度
422428
if (menu_value('menu_picHeight')) style += style_5;
@@ -426,7 +432,7 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
426432
if (menu_value('menu_hideTitle')) style += style_4;
427433

428434
// 文章编辑页面与实际文章宽度一致
429-
if (window.location.href.indexOf('zhuanlan') > -1 && window.location.href.indexOf('/edit') > -1) style += style_3;
435+
if (location.hostname.indexOf('zhuanlan') > -1 && location.pathname.indexOf('/edit') > -1) style += style_3;
430436

431437
if (document.lastChild) {
432438
document.lastChild.appendChild(style_Add).textContent = style;

0 commit comments

Comments
 (0)