6767 }
6868 GM_setValue ( `${ Name } ` , menu_status ) ;
6969 if ( menu_status === 1 ) { // 设置 Cookie
70- if ( getTheme ( ) === 'light' ) document . cookie = " theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/" ;
70+ if ( getTheme ( ) === 'light' ) document . cookie = ' theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/' ;
7171 } else {
72- if ( getTheme ( ) === 'dark' ) document . cookie = " theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" ;
72+ if ( getTheme ( ) === 'dark' ) document . cookie = ' theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' ;
7373 }
7474 if ( menu_value ( 'menu_darkMode' ) ) {
7575 location . reload ( ) ; // 刷新网页
7979 }
8080 } ;
8181
82+ // 菜单数字图标
8283 function menu_num ( num ) {
83- switch ( num ) {
84- case 1 :
85- return '1️⃣'
86- break ;
87- case 2 :
88- return '2️⃣'
89- break ;
90- case 3 :
91- return '3️⃣'
92- break ;
93- case 4 :
94- return '4️⃣'
95- break ;
96- }
84+ return [ '0️⃣' , '1️⃣' , '2️⃣' , '3️⃣' , '4️⃣' , '5️⃣' , '6️⃣' , '7️⃣' , '8️⃣' , '9️⃣' , '🔟' ] [ num ]
9785 }
9886
9987 // 菜单开关
10290 GM_setValue ( `${ Name } ` , false ) ;
10391
10492 if ( Name === 'menu_darkMode' ) { // 暗黑模式
105- if ( getTheme ( ) === 'dark' ) document . cookie = " theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" ;
93+ if ( getTheme ( ) === 'dark' ) document . cookie = ' theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' ;
10694 location . reload ( ) ; // 刷新网页
10795 } else {
10896 GM_notification ( { text : `已关闭 [${ Tips } ] 功能\n(刷新网页后生效)` , timeout : 3500 } ) ;
112100
113101 if ( Name === 'menu_darkMode' ) {
114102 if ( menu_value ( 'menu_darkModeType' ) === 1 ) {
115- if ( getTheme ( ) === 'light' ) document . cookie = " theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/" ;
103+ if ( getTheme ( ) === 'light' ) document . cookie = ' theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/' ;
116104 } else {
117- if ( getTheme ( ) === 'dark' ) document . cookie = " theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" ;
105+ if ( getTheme ( ) === 'dark' ) document . cookie = ' theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' ;
118106 }
119107 location . reload ( ) ; // 刷新网页
120108 } else {
@@ -254,6 +242,10 @@ html[data-theme=dark] body::-webkit-scrollbar-thumb, html[data-theme="dark"] .Me
254242html[data-theme=dark] body::-webkit-scrollbar-track {background: #22272e !important;}
255243html[data-theme=dark] .MessagesBox::-webkit-scrollbar-track, html[data-theme="dark"] .Messages-list::-webkit-scrollbar-track, html[data-theme=dark] .PushNotifications-list::-webkit-scrollbar-track, html[data-theme=dark] .CommentListV2::-webkit-scrollbar-track, .ChatListGroup-SectionContent::-webkit-scrollbar-track, html[data-theme=dark] .ChatSideBar-Search-ResultListWrap::-webkit-scrollbar-track, html[data-theme=dark] .ChatBox textarea.Input::-webkit-scrollbar-track {background: #2d333b !important;}
256244
245+ /* 滚动条 - 回答目录 */
246+ html[data-theme=dark] .AnswerItem .RichContent-hasCatalog .RichContent-inner .Catalog.isCatalogV2::-webkit-scrollbar {width: 0 !important;}
247+ html[data-theme=dark] .AnswerItem .RichContent-hasCatalog .RichContent-inner .Catalog.isCatalogV2 > :first-child {background: #2D333B !important;}
248+
257249html {scrollbar-width: thin; scrollbar-color: #3f4752 #22272e;}
258250.MessagesBox, .Messages-list, .PushNotifications-list, .CommentListV2, .ChatListGroup-SectionContent, .ChatSideBar-Search-ResultListWrap {scrollbar-width: thin; scrollbar-color: #3f4752 #2D333B;}
259251
@@ -308,21 +300,24 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
308300`
309301 let style_Add = document . createElement ( 'style' ) ;
310302
311- // 暗黑模式
303+ // 如果开启了暗黑模式
312304 if ( menu_value ( 'menu_darkMode' ) ) {
305+ // 如果暗黑模式为 1
313306 if ( menu_value ( 'menu_darkModeType' ) === 1 ) {
307+ // 如果当前知乎主题为白天模式,那就是改为暗黑模式
314308 if ( getTheme ( ) === 'light' ) {
315- document . cookie = " theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/" ;
309+ document . cookie = ' theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/' ;
316310 document . lastChild . setAttribute ( 'data-theme' , 'dark' ) ;
317311 location . reload ( ) ; // 刷新网页
318312 }
313+ // 如果是问题日志页,则改为暗黑模式
319314 if ( location . pathname . indexOf ( '/log' ) > - 1 ) {
320315 document . documentElement . setAttribute ( 'data-theme' , 'dark' ) ;
321316 style_darkMode_1 += style_darkMode_1_x ;
322317 }
323- } else {
318+ } else { // 如果是其他暗黑模式,则需要确保为白天模式
324319 if ( getTheme ( ) === 'dark' ) {
325- document . cookie = " theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" ;
320+ document . cookie = ' theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' ;
326321 document . lastChild . setAttribute ( 'data-theme' , 'light' ) ;
327322 location . reload ( ) ; // 刷新网页
328323 }
@@ -348,67 +343,42 @@ html {filter: brightness(75%) sepia(30%) !important; background-image: url();}
348343 }
349344 } else {
350345 if ( getTheme ( ) === 'dark' ) {
351- document . cookie = " theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" ;
346+ document . cookie = ' theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/' ;
352347 document . lastChild . setAttribute ( 'data-theme' , 'light' ) ;
353348 location . reload ( ) ; // 刷新网页
354349 }
355350 }
356351
357352 // 宽屏显示
358- if ( menu_value ( 'menu_widescreenDisplay' ) ) {
359- style += style_1 ;
360- }
361-
353+ if ( menu_value ( 'menu_widescreenDisplay' ) ) style += style_1 ;
362354 // 调整图片最大高度
363- if ( menu_value ( 'menu_picHeight' ) ) {
364- style += style_5 ;
365- }
366-
355+ if ( menu_value ( 'menu_picHeight' ) ) style += style_5 ;
367356 // 隐藏文章开头大图
368- if ( menu_value ( 'menu_postimg' ) ) {
369- style += style_2 ;
370- }
371-
357+ if ( menu_value ( 'menu_postimg' ) ) style += style_2 ;
372358 // 向下翻时自动隐藏顶栏
373- if ( menu_value ( 'menu_hideTitle' ) ) {
374- style += style_4 ;
375- }
359+ if ( menu_value ( 'menu_hideTitle' ) ) style += style_4 ;
376360
377361 // 文章编辑页面与实际文章宽度一致
378- if ( window . location . href . indexOf ( "zhuanlan" ) > - 1 ) {
379- if ( window . location . href . indexOf ( "/edit" ) > - 1 ) {
380- style += style_3 ;
381- }
382- }
383-
384- /*style_Add.innerHTML = style;
385- if (document.head) {
386- document.head.appendChild(style_Add);
387- } else {
388- let timer = setInterval(function(){
389- if (document.head) {
390- document.head.appendChild(style_Add);
391- clearInterval(timer);
392- }
393- }, 1);
394- }*/
362+ if ( window . location . href . indexOf ( 'zhuanlan' ) > - 1 && window . location . href . indexOf ( '/edit' ) > - 1 ) style += style_3 ;
395363
396364 if ( document . lastChild ) {
397365 document . lastChild . appendChild ( style_Add ) . textContent = style ;
398366 } else { // 避免网站加载速度太慢的备用措施
399- let timer1 = setInterval ( function ( ) { // 每 5 毫秒检查一下 html 是否已存在
367+ let timer1 = setInterval ( function ( ) { // 每 10 毫秒检查一下 html 是否已存在
400368 if ( document . lastChild ) {
401369 clearInterval ( timer1 ) ; // 取消定时器
402370 document . lastChild . appendChild ( style_Add ) . textContent = style ;
403371 }
404- } , 5 ) ;
372+ } , 10 ) ;
405373 }
406374 }
375+
376+
377+ // 获取知乎 Cookie 中的主题类型
407378 function getTheme ( ) {
408- let name = "theme=" ;
409- let ca = document . cookie . split ( ';' ) ;
410- for ( let i = 0 ; i < ca . length ; i ++ )
411- {
379+ let name = "theme=" ,
380+ ca = document . cookie . split ( ';' ) ;
381+ for ( let i = 0 ; i < ca . length ; i ++ ) {
412382 let c = ca [ i ] . trim ( ) ;
413383 if ( c . indexOf ( name ) == 0 ) return c . substring ( name . length , c . length ) ;
414384 }
0 commit comments