知乎排版修改

修改了一些排版样式

  1. // ==UserScript==
  2. // @name 知乎排版修改
  3. // @namespace https://github.com/chthub/changeZhiHuCSS
  4. // @version 2.0.1
  5. // @author CH
  6. // @description 修改了一些排版样式
  7. // @match https://www.zhihu.com/follow
  8. // @match https://www.zhihu.com/hot
  9. // @match https://www.zhihu.com/question/*
  10. // @match https://www.zhihu.com/search?*
  11. // @match https://www.zhihu.com
  12. // @match https://zhuanlan.zhihu.com/p/*
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict'
  18. var path = location.pathname.slice(0);
  19. (function () {
  20. // 修改主页样式
  21. if (path == '/' || path == '/follow' || path == '/hot') {
  22. //移除右侧栏
  23. var node1 = document.querySelector('.GlobalSideBar')
  24. node1.remove()
  25. //移除反馈框
  26. var node2 = document.querySelector('.CornerButtons')
  27. node2.remove()
  28. // 定制主框
  29. var node3 = document.querySelector(".Topstory-container")
  30. node3.style.width = '97%'
  31. node3.style.backgroundColor = '#d8e2c8'
  32. var inner = document.querySelector('.Topstory-mainColumn')
  33. inner.style.width = '100%'
  34. inner.style.fontFamily = 'Times New Roman,楷体'
  35. inner.style.fontSize = '22px'
  36. // 定制评论栏
  37. let doCSS = document.createElement('style')
  38. doCSS.innerHTML += '.RichContent-actions{height:12px !important;}'
  39. doCSS.innerHTML += ".Topstory-noMarginCard,.TopstoryItem-isRecommend,.ContentItem-actions,.AppHeader,#root,.TopstoryItem,.HotItem,.HotListNav-wrapper,.CommentsV2 ,.Topbar,.CommentsV2-footer{background-color: #d8e2c8 !important}"
  40. doCSS.innerHTML += '.VoteButton{color:#999 !important;background: #d8e2c8 !important;height:12px !important}'
  41. doCSS.innerHTML += ".ContentItem-title {font-size: 22px;}"
  42. doCSS.innerHTML += ".HotListNav-item{background-color: #bad889 !important}"
  43. //图片和视频的显示区域大小
  44. doCSS.innerHTML += '.origin_image{max-width:500px !important}'
  45. doCSS.innerHTML += '.RichText-video{max-width:500px !important}'
  46. //文章内代码区
  47. doCSS.innerHTML += '.highlight pre{font-size:medium !important;background-color: #cbde8c !important;}'
  48. document.getElementsByTagName('head')[0].appendChild(doCSS)
  49. // 固定顶部导航栏
  50. let header = document.getElementsByTagName('header')[0]
  51. window.onscroll = function () {
  52. header.className = "Sticky AppHeader"
  53. let sticky = document.querySelector('.Sticky--holder')
  54. if (sticky) {
  55. sticky.style.position = "absolute"
  56. sticky.style.height = 0
  57. }
  58. }
  59. }
  60. })();
  61. (function () {
  62. //修改专栏样式
  63. if (path.match(/\/p\/\d+/g)) {
  64. window.onload = function () {
  65. //左侧的点赞框
  66. window.onscroll = function () {
  67. let inner1 = document.querySelector(".Post-SideActions")
  68. if (inner1) {
  69. inner1.style.visibility = "hidden"
  70. }
  71. }
  72. //上方的导航栏
  73. var node = document.querySelector('.ColumnPageHeader-Wrapper')
  74. node.remove()
  75. //背景颜色
  76. var backG = document.querySelector('.Post-content')
  77. backG.style.backgroundColor = '#d8e2c8'
  78. //正文
  79. var contentTxt = document.querySelector('.Post-RichTextContainer')
  80. contentTxt.style.width = '95%'
  81. contentTxt.style.fontSize = '30px'
  82. contentTxt.style.fontFamily = 'Times New Roman,楷体'
  83. contentTxt.style.backgroundColor = '#d8e2c8'
  84.  
  85. //右侧的反馈框
  86. var inner2 = document.querySelector('.CornerButtons')
  87. inner2.remove()
  88. //推荐框
  89. var inner7 = document.querySelector('.Post-NormalSub>div.Recommendations-Main')
  90. inner7.style.width = '100%'
  91. inner7.style.backgroundColor = '#d8e2c8'
  92. //评论框
  93. var inner8 = document.querySelector('.Post-NormalSub>div.Comments-container')
  94. inner8.style.width = '100%'
  95. inner8.style.backgroundColor = '#d8e2c8'
  96. var inner9 = document.querySelector(".CommentsV2-withPagination")
  97. inner9.style.backgroundColor = '#d8e2c8'
  98. // 评论栏定制
  99. let doCSS = document.createElement('style')
  100. doCSS.innerHTML += '.RichContent-actions {bottom:auto !important;background-color: #d8e2c8 !important}'
  101. doCSS.innerHTML += '.VoteButton,.ContentItem-actions,.Topbar,.CommentsV2-footer,.App-main{background-color: #d8e2c8 !important}'
  102. //图片和视频的显示区域大小
  103. doCSS.innerHTML += '.origin_image,.TitleImage{max-width:500px !important}'
  104. doCSS.innerHTML += '.RichText-video{max-width:500px !important}'
  105. //文章内代码区
  106. doCSS.innerHTML += '.highlight pre{font-size:medium !important;background-color: #cbde8c !important;}'
  107. document.getElementsByTagName('head')[0].appendChild(doCSS)
  108. }
  109.  
  110. }
  111. })();
  112. (function () {
  113. //这里修改回答页的样式
  114. if (path.match(/\/question\/\d+/g)) {
  115. window.onload = function () {
  116. // 移除右侧栏
  117. var re = document.querySelector('.Question-sideColumn')
  118. re.remove()
  119. //修改回答区的宽度,字体大小
  120. var inner0 = document.querySelector('.Question-main')
  121. inner0.style.width = '97%'
  122. var inner = document.querySelector('.Question-mainColumn')
  123. inner.style.width = '100%'
  124. inner.style.fontSize = '30px'
  125. inner.style.fontFamily = 'Times New Roman,楷体'
  126. //移除反馈按钮
  127. var inner1 = document.querySelector(".CornerButtons")
  128. inner1.remove()
  129. // 评论栏定制
  130. let doCSS = document.createElement('style')
  131. doCSS.innerHTML += '.RichContent-actions{bottom:auto !important}'
  132. doCSS.innerHTML += '.VoteButton{color:#999 !importantbackground: none !important}'
  133. doCSS.innerHTML += '.QuestionHeader,.QuestionHeader-footer,#root,.List,.ContentItem-actions,.CommentsV2,.Topbar,.CommentsV2-footer{background-color: #d8e2c8 !important}'
  134. //图片和视频的显示区域大小
  135. doCSS.innerHTML += '.origin_image{max-width:500px !important}'
  136. doCSS.innerHTML += '.RichText-video{max-width:500px !important}'
  137. //文章内代码区
  138. doCSS.innerHTML += '.highlight pre{font-size:medium !important;background-color: #cbde8c !important;}'
  139. document.getElementsByTagName('head')[0].appendChild(doCSS)
  140. // 顶部导航栏移除
  141. let header = document.querySelector('.AppHeader')
  142. header.remove()
  143.  
  144. }
  145. }
  146. })();
  147. (function () {
  148. // 搜索页定制
  149. if (path.match(/\/search?.*/g)) {
  150. //移除侧栏
  151. var node = document.querySelector('.SearchSideBar')
  152. node.remove()
  153. //修改正文区域
  154. var inner0 = document.querySelector('.Search-container')
  155. inner0.style.width = '90%'
  156.  
  157. var inner1 = document.querySelector('.SearchMain')
  158. inner1.style.width = '100%'
  159. inner1.style.fontFamily = 'Times New Roman,楷体'
  160. inner1.style.fontSize = '26px !important'
  161. // 定制评论栏
  162. let doCSS = document.createElement('style')
  163. doCSS.innerHTML += '.RichContent-actions{height:12px !important;}'
  164. doCSS.innerHTML += ".Topstory-noMarginCard,.TopstoryItem-isRecommend,.ContentItem-actions,.AppHeader,#root,.TopstoryItem,.SearchTabs,.HotItem,.HotListNav-wrapper,.CommentsV2 ,.Topbar,.CommentsV2-footer,.SearchResult-Card{background-color: #d8e2c8 !important}"
  165. doCSS.innerHTML += '.VoteButton{color:#999 !important;background: #d8e2c8 !important;height:12px !important}'
  166. doCSS.innerHTML += ".ContentItem-title {font-size: 22px !important;};.RichText {font-size: 20px !important;}"
  167. doCSS.innerHTML += ".HotListNav-item{background-color: #bad889 !important}"
  168. //图片和视频的显示区域大小
  169. doCSS.innerHTML += '.origin_image{max-width:500px !important}'
  170. doCSS.innerHTML += '.RichText-video{max-width:500px !important}'
  171. //文章内代码区
  172. doCSS.innerHTML += '.highlight pre{font-size:medium !important;background-color: #cbde8c !important;}'
  173. document.getElementsByTagName('head')[0].appendChild(doCSS)
  174. }
  175. })();
  176. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址