mirror of
https://github.com/XIU2/UserScript.git
synced 2026-10-07 15:54:20 +00:00
新增 [宽屏显示] 支持文章页
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name 知乎美化
|
||||
// @version 1.3.7
|
||||
// @version 1.3.8
|
||||
// @author X.I.U
|
||||
// @description 宽屏显示、暗黑模式(4种)、暗黑模式跟随浏览器、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏、文章编辑页面与实际文章宽度一致
|
||||
// @match *://www.zhihu.com/*
|
||||
@@ -28,6 +28,7 @@
|
||||
['menu_widescreenDisplayQuestion', '问题页', '宽屏显示', true],
|
||||
['menu_widescreenDisplaySearch', '搜索页、话题页、圈子', '宽屏显示', true],
|
||||
['menu_widescreenDisplayCollection', '收藏页', '宽屏显示', true],
|
||||
['menu_widescreenDisplayPost', '文章页', '宽屏显示', false],
|
||||
['menu_widescreenDisplayWidth', '宽屏宽度', '宽屏宽度 (100~1000)', '1000'],
|
||||
['menu_darkMode', '暗黑模式', '暗黑模式', true],
|
||||
['menu_darkModeType', '暗黑模式切换(1~4)', '暗黑模式切换', 1],
|
||||
@@ -59,7 +60,7 @@
|
||||
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]}`)});
|
||||
} else if (menu_ALL[i][0] === 'menu_widescreenDisplay'){
|
||||
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]])});
|
||||
} 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') {
|
||||
} else if (menu_ALL[i][0].indexOf('menu_widescreenDisplay') === -1) {
|
||||
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]}`)});
|
||||
}
|
||||
}
|
||||
@@ -201,6 +202,10 @@
|
||||
.CollectionsDetailPage-mainColumn {width: inherit !important;}
|
||||
.CollectionDetailPageSideBar {display: none !important;}
|
||||
.CollectionsDetailPage {width: ${GM_getValue('menu_widescreenDisplayWidth')}px;}
|
||||
`,
|
||||
style_widescreenDisplayPost = `/* 宽屏显示 - 文章页 */
|
||||
.Post-SideActions {left: calc(10vw) !important;}
|
||||
.Post-NormalMain .Post-Header, .Post-NormalMain>div, .Post-NormalSub>div {width: ${GM_getValue('menu_widescreenDisplayWidth')}px !important;}
|
||||
`,
|
||||
style_2 = `/* 隐藏在各列表中查看文章时开头显示的大图,不影响文章、专栏页面 */
|
||||
.RichContent img.ArticleItem-image {display: none !important;}
|
||||
@@ -417,6 +422,7 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
|
||||
if (menu_value('menu_widescreenDisplayQuestion') && location.pathname.indexOf('/question/') > -1) style += style_widescreenDisplayQuestion;
|
||||
if (menu_value('menu_widescreenDisplaySearch') && (location.pathname === '/search' || location.pathname.indexOf('/club/') > -1 || location.pathname.indexOf('/topic/') > -1)) style += style_widescreenDisplaySearch;
|
||||
if (menu_value('menu_widescreenDisplayCollection') && location.pathname.indexOf('/collection/') > -1) style += style_widescreenDisplayCollection;
|
||||
if (menu_value('menu_widescreenDisplayPost') && location.hostname.indexOf('zhuanlan') > -1 && location.pathname.indexOf('/edit') === -1) style += style_widescreenDisplayPost;
|
||||
|
||||
// 调整图片最大高度
|
||||
if (menu_value('menu_picHeight')) style += style_5;
|
||||
@@ -426,7 +432,7 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
|
||||
if (menu_value('menu_hideTitle')) style += style_4;
|
||||
|
||||
// 文章编辑页面与实际文章宽度一致
|
||||
if (window.location.href.indexOf('zhuanlan') > -1 && window.location.href.indexOf('/edit') > -1) style += style_3;
|
||||
if (location.hostname.indexOf('zhuanlan') > -1 && location.pathname.indexOf('/edit') > -1) style += style_3;
|
||||
|
||||
if (document.lastChild) {
|
||||
document.lastChild.appendChild(style_Add).textContent = style;
|
||||
|
||||
Reference in New Issue
Block a user