v2ex.min - V2EX 极简风格

V2EX 极简风格,简洁风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。

  1. // ==UserScript==
  2. // @name v2ex.min - V2EX 极简风格
  3. // @name:en v2ex.min - V2EX Minimalist (极简风格)
  4. // @name:zh-CN v2ex.min - V2EX 极简风格
  5. // @namespace https://github.com/v2hot/v2ex.min
  6. // @homepageURL https://github.com/v2hot/v2ex.min#readme
  7. // @supportURL https://github.com/v2hot/v2ex.min/issues
  8. // @version 0.2.1
  9. // @description V2EX 极简风格,简洁风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。
  10. // @description:en V2EX minimalist style,简洁风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。
  11. // @description:zh-CN V2EX 极简风格,简洁风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。
  12. // @icon https://www.v2ex.com/favicon.ico
  13. // @author Pipecraft
  14. // @license MIT
  15. // @run-at document-start
  16. // @match https://*.v2ex.com/*
  17. // @match https://v2hot.pipecraft.net/*
  18. // @grant GM.getValue
  19. // @grant GM.setValue
  20. // @grant GM_addValueChangeListener
  21. // @grant GM_removeValueChangeListener
  22. // @grant GM_addElement
  23. // @grant GM_addStyle
  24. // @grant GM.registerMenuCommand
  25. // ==/UserScript==
  26. //
  27. ;(() => {
  28. "use strict"
  29. var listeners = {}
  30. var getValue = async (key) => {
  31. const value = await GM.getValue(key)
  32. return value && value !== "undefined" ? JSON.parse(value) : void 0
  33. }
  34. var setValue = async (key, value) => {
  35. if (value !== void 0) {
  36. const newValue = JSON.stringify(value)
  37. if (listeners[key]) {
  38. const oldValue = await GM.getValue(key)
  39. await GM.setValue(key, newValue)
  40. if (newValue !== oldValue) {
  41. for (const func of listeners[key]) {
  42. func(key, oldValue, newValue)
  43. }
  44. }
  45. } else {
  46. await GM.setValue(key, newValue)
  47. }
  48. }
  49. }
  50. var _addValueChangeListener = (key, func) => {
  51. listeners[key] = listeners[key] || []
  52. listeners[key].push(func)
  53. return () => {
  54. if (listeners[key] && listeners[key].length > 0) {
  55. for (let i = listeners[key].length - 1; i >= 0; i--) {
  56. if (listeners[key][i] === func) {
  57. listeners[key].splice(i, 1)
  58. }
  59. }
  60. }
  61. }
  62. }
  63. var addValueChangeListener = (key, func) => {
  64. if (typeof GM_addValueChangeListener !== "function") {
  65. console.warn("Do not support GM_addValueChangeListener!")
  66. return _addValueChangeListener(key, func)
  67. }
  68. const listenerId = GM_addValueChangeListener(key, func)
  69. return () => {
  70. GM_removeValueChangeListener(listenerId)
  71. }
  72. }
  73. var doc = document
  74. var $ = (selectors, element) => (element || doc).querySelector(selectors)
  75. var $$ = (selectors, element) => [
  76. ...(element || doc).querySelectorAll(selectors),
  77. ]
  78. var createElement = (tagName, attributes) =>
  79. setAttributes(doc.createElement(tagName), attributes)
  80. var addElement = (parentNode, tagName, attributes) => {
  81. if (!parentNode) {
  82. return
  83. }
  84. if (typeof parentNode === "string") {
  85. attributes = tagName
  86. tagName = parentNode
  87. parentNode = doc.head
  88. }
  89. if (typeof tagName === "string") {
  90. const element = createElement(tagName, attributes)
  91. parentNode.append(element)
  92. return element
  93. }
  94. setAttributes(tagName, attributes)
  95. parentNode.append(tagName)
  96. return tagName
  97. }
  98. var addStyle = (styleText) => {
  99. const element = createElement("style", { textContent: styleText })
  100. doc.head.append(element)
  101. return element
  102. }
  103. var addEventListener = (element, type, listener, options) => {
  104. if (!element) {
  105. return
  106. }
  107. if (typeof type === "object") {
  108. for (const type1 in type) {
  109. if (Object.hasOwn(type, type1)) {
  110. element.addEventListener(type1, type[type1])
  111. }
  112. }
  113. } else if (typeof type === "string" && typeof listener === "function") {
  114. element.addEventListener(type, listener, options)
  115. }
  116. }
  117. var removeEventListener = (element, type, listener, options) => {
  118. if (!element) {
  119. return
  120. }
  121. if (typeof type === "object") {
  122. for (const type1 in type) {
  123. if (Object.hasOwn(type, type1)) {
  124. element.removeEventListener(type1, type[type1])
  125. }
  126. }
  127. } else if (typeof type === "string" && typeof listener === "function") {
  128. element.removeEventListener(type, listener, options)
  129. }
  130. }
  131. var setAttribute = (element, name, value) =>
  132. element ? element.setAttribute(name, value) : void 0
  133. var setAttributes = (element, attributes) => {
  134. if (element && attributes) {
  135. for (const name in attributes) {
  136. if (Object.hasOwn(attributes, name)) {
  137. const value = attributes[name]
  138. if (value === void 0) {
  139. continue
  140. }
  141. if (/^(value|textContent|innerText|innerHTML)$/.test(name)) {
  142. element[name] = value
  143. } else if (name === "style") {
  144. setStyle(element, value, true)
  145. } else if (/on\w+/.test(name)) {
  146. const type = name.slice(2)
  147. addEventListener(element, type, value)
  148. } else {
  149. setAttribute(element, name, value)
  150. }
  151. }
  152. }
  153. }
  154. return element
  155. }
  156. var addClass = (element, className) => {
  157. if (!element || !element.classList) {
  158. return
  159. }
  160. element.classList.add(className)
  161. }
  162. var removeClass = (element, className) => {
  163. if (!element || !element.classList) {
  164. return
  165. }
  166. element.classList.remove(className)
  167. }
  168. var setStyle = (element, values, overwrite) => {
  169. if (!element) {
  170. return
  171. }
  172. const style = element.style
  173. if (typeof values === "string") {
  174. style.cssText = overwrite ? values : style.cssText + ";" + values
  175. return
  176. }
  177. if (overwrite) {
  178. style.cssText = ""
  179. }
  180. for (const key in values) {
  181. if (Object.hasOwn(values, key)) {
  182. style[key] = values[key].replace("!important", "")
  183. }
  184. }
  185. }
  186. if (typeof Object.hasOwn !== "function") {
  187. Object.hasOwn = (instance, prop) =>
  188. Object.prototype.hasOwnProperty.call(instance, prop)
  189. }
  190. var parseInt10 = (number, defaultValue) => {
  191. if (typeof number === "number" && !Number.isNaN(number)) {
  192. return number
  193. }
  194. if (typeof defaultValue !== "number") {
  195. defaultValue = Number.NaN
  196. }
  197. if (!number) {
  198. return defaultValue
  199. }
  200. const result = Number.parseInt(number, 10)
  201. return Number.isNaN(result) ? defaultValue : result
  202. }
  203. var headFuncArray = []
  204. var bodyFuncArray = []
  205. var headBodyObserver
  206. var startObserveHeadBodyExists = () => {
  207. if (headBodyObserver) {
  208. return
  209. }
  210. headBodyObserver = new MutationObserver(() => {
  211. if (doc.head && doc.body) {
  212. headBodyObserver.disconnect()
  213. }
  214. if (doc.head && headFuncArray.length > 0) {
  215. for (const func of headFuncArray) {
  216. func()
  217. }
  218. headFuncArray.length = 0
  219. }
  220. if (doc.body && bodyFuncArray.length > 0) {
  221. for (const func of bodyFuncArray) {
  222. func()
  223. }
  224. bodyFuncArray.length = 0
  225. }
  226. })
  227. headBodyObserver.observe(doc, {
  228. childList: true,
  229. subtree: true,
  230. })
  231. }
  232. var runWhenHeadExists = (func) => {
  233. if (!doc.head) {
  234. headFuncArray.push(func)
  235. startObserveHeadBodyExists()
  236. return
  237. }
  238. func()
  239. }
  240. var runWhenBodyExists = (func) => {
  241. if (!doc.body) {
  242. bodyFuncArray.push(func)
  243. startObserveHeadBodyExists()
  244. return
  245. }
  246. func()
  247. }
  248. var addElement2 =
  249. typeof GM_addElement === "function"
  250. ? (parentNode, tagName, attributes) => {
  251. if (!parentNode) {
  252. return
  253. }
  254. if (typeof parentNode === "string") {
  255. attributes = tagName
  256. tagName = parentNode
  257. parentNode = doc.head
  258. }
  259. if (typeof tagName === "string") {
  260. const element = GM_addElement(tagName)
  261. setAttributes(element, attributes)
  262. parentNode.append(element)
  263. return element
  264. }
  265. setAttributes(tagName, attributes)
  266. parentNode.append(tagName)
  267. return tagName
  268. }
  269. : addElement
  270. var addStyle2 =
  271. typeof GM_addStyle === "function"
  272. ? (styleText) => GM_addStyle(styleText)
  273. : addStyle
  274. var registerMenuCommand = (name, callback, accessKey) => {
  275. if (window !== top) {
  276. return
  277. }
  278. if (typeof GM.registerMenuCommand !== "function") {
  279. console.warn("Do not support GM.registerMenuCommand!")
  280. return
  281. }
  282. GM.registerMenuCommand(name, callback, accessKey)
  283. }
  284. var style_default = `#browser_extension_settings_container{--browser-extension-settings-background-color: #f2f2f7;--browser-extension-settings-text-color: #444444;--browser-extension-settings-link-color: #217dfc;--sb-track-color: #00000000;--sb-thumb-color: #33334480;--sb-size: 2px;position:fixed;top:10px;right:30px;max-height:90%;height:600px;overflow:hidden;display:none;z-index:100000;border-radius:5px;-webkit-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);-moz-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);box-shadow:0px 10px 39px 10px rgba(62,66,66,.22) !important}#browser_extension_settings_container .browser_extension_settings_wrapper{display:flex;height:100%;overflow:hidden;background-color:var(--browser-extension-settings-background-color)}#browser_extension_settings_container .browser_extension_settings_wrapper h1{font-size:26px;font-weight:800;border:none}#browser_extension_settings_container .browser_extension_settings_wrapper h2{font-size:18px;font-weight:600;border:none}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container{overflow-x:auto;box-sizing:border-box;padding:10px 15px;background-color:var(--browser-extension-settings-background-color);color:var(--browser-extension-settings-text-color)}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div{background-color:#fff;font-size:14px;border-top:1px solid #ccc;padding:6px 15px 6px 15px}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a:visited,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a:visited{display:flex;justify-content:space-between;align-items:center;cursor:pointer;text-decoration:none;color:var(--browser-extension-settings-text-color)}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a:hover,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a:visited:hover,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a:hover,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a:visited:hover{text-decoration:none;color:var(--browser-extension-settings-text-color)}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a span,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div a:visited span,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a span,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div a:visited span{margin-right:10px;line-height:24px}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div.active,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div:hover,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div.active,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div:hover{background-color:#e4e4e6}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div.active a,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div.active a{cursor:default}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div:first-of-type,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div:first-of-type{border-top:none;border-top-right-radius:10px;border-top-left-radius:10px}#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .installed_extension_list div:last-of-type,#browser_extension_settings_container .browser_extension_settings_wrapper .extension_list_container .related_extension_list div:last-of-type{border-bottom-right-radius:10px;border-bottom-left-radius:10px}#browser_extension_settings_container .thin_scrollbar{scrollbar-color:var(--sb-thumb-color) var(--sb-track-color);scrollbar-width:thin}#browser_extension_settings_container .thin_scrollbar::-webkit-scrollbar{width:var(--sb-size)}#browser_extension_settings_container .thin_scrollbar::-webkit-scrollbar-track{background:var(--sb-track-color);border-radius:10px}#browser_extension_settings_container .thin_scrollbar::-webkit-scrollbar-thumb{background:var(--sb-thumb-color);border-radius:10px}#browser_extension_settings_main{min-width:250px;overflow-y:auto;overflow-x:hidden;box-sizing:border-box;padding:10px 15px;background-color:var(--browser-extension-settings-background-color);color:var(--browser-extension-settings-text-color)}#browser_extension_settings_main h2{text-align:center;margin:5px 0 0;font-size:18px;font-weight:600;border:none}#browser_extension_settings_main footer{display:flex;justify-content:center;flex-direction:column;font-size:11px;margin:10px auto 0px;background-color:var(--browser-extension-settings-background-color);color:var(--browser-extension-settings-text-color)}#browser_extension_settings_main footer a{color:var(--browser-extension-settings-link-color) !important;text-decoration:none;padding:0}#browser_extension_settings_main footer p{text-align:center;padding:0;margin:2px;line-height:13px}#browser_extension_settings_main a.navigation_go_previous{color:var(--browser-extension-settings-link-color);cursor:pointer;display:none}#browser_extension_settings_main a.navigation_go_previous::before{content:"< "}#browser_extension_settings_main .option_groups{background-color:#fff;padding:6px 15px 6px 15px;border-radius:10px;display:flex;flex-direction:column;margin:10px 0 0}#browser_extension_settings_main .option_groups .action{font-size:14px;padding:6px 0 6px 0;color:var(--browser-extension-settings-link-color);cursor:pointer}#browser_extension_settings_main .bes_external_link{font-size:14px;padding:6px 0 6px 0}#browser_extension_settings_main .bes_external_link a,#browser_extension_settings_main .bes_external_link a:visited,#browser_extension_settings_main .bes_external_link a:hover{color:var(--browser-extension-settings-link-color);text-decoration:none;cursor:pointer}#browser_extension_settings_main .option_groups textarea{font-size:12px;margin:10px 0 10px 0;height:100px;width:100%;border:1px solid #a9a9a9;border-radius:4px;box-sizing:border-box}#browser_extension_settings_main .switch_option{display:flex;justify-content:space-between;align-items:center;padding:6px 0 6px 0;font-size:14px}#browser_extension_settings_main .option_groups>*{border-top:1px solid #ccc}#browser_extension_settings_main .option_groups>*:first-child{border-top:none}#browser_extension_settings_main .switch_option>span{margin-right:10px}#browser_extension_settings_main .option_groups .bes_tip{position:relative;margin:0;padding:0 15px 0 0;border:none;max-width:none;font-size:14px}#browser_extension_settings_main .option_groups .bes_tip .bes_tip_anchor{cursor:help;text-decoration:underline}#browser_extension_settings_main .option_groups .bes_tip .bes_tip_content{position:absolute;bottom:15px;left:0;background-color:#fff;color:var(--browser-extension-settings-text-color);text-align:left;padding:10px;display:none;border-radius:5px;-webkit-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);-moz-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);box-shadow:0px 10px 39px 10px rgba(62,66,66,.22) !important}#browser_extension_settings_main .option_groups .bes_tip .bes_tip_anchor:hover+.bes_tip_content,#browser_extension_settings_main .option_groups .bes_tip .bes_tip_content:hover{display:block}#browser_extension_settings_main .option_groups .bes_tip p,#browser_extension_settings_main .option_groups .bes_tip pre{margin:revert;padding:revert}#browser_extension_settings_main .option_groups .bes_tip pre{font-family:Consolas,panic sans,bitstream vera sans mono,Menlo,microsoft yahei,monospace;font-size:13px;letter-spacing:.015em;line-height:120%;white-space:pre;overflow:auto;background-color:#f5f5f5;word-break:normal;overflow-wrap:normal;padding:.5em;border:none}#browser_extension_settings_main .container{--button-width: 51px;--button-height: 24px;--toggle-diameter: 20px;--color-off: #e9e9eb;--color-on: #34c759;width:var(--button-width);height:var(--button-height);position:relative;padding:0;margin:0;flex:none;user-select:none}#browser_extension_settings_main input[type=checkbox]{opacity:0;width:0;height:0;position:absolute}#browser_extension_settings_main .switch{width:100%;height:100%;display:block;background-color:var(--color-off);border-radius:calc(var(--button-height)/2);border:none;cursor:pointer;transition:all .2s ease-out}#browser_extension_settings_main .switch::before{display:none}#browser_extension_settings_main .slider{width:var(--toggle-diameter);height:var(--toggle-diameter);position:absolute;left:2px;top:calc(50% - var(--toggle-diameter)/2);border-radius:50%;background:#fff;box-shadow:0px 3px 8px rgba(0,0,0,.15),0px 3px 1px rgba(0,0,0,.06);transition:all .2s ease-out;cursor:pointer}#browser_extension_settings_main input[type=checkbox]:checked+.switch{background-color:var(--color-on)}#browser_extension_settings_main input[type=checkbox]:checked+.switch .slider{left:calc(var(--button-width) - var(--toggle-diameter) - 2px)}#browser_extension_side_menu{min-height:100px;width:40px;opacity:0;position:fixed;top:80px;right:0;padding-top:20px;z-index:10000}#browser_extension_side_menu:hover{opacity:1}#browser_extension_side_menu button{cursor:pointer;width:24px;height:24px;border:none;background-color:rgba(0,0,0,0);background-image:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M12.0002 16C14.2094 16 16.0002 14.2091 16.0002 12C16.0002 9.79086 14.2094 8 12.0002 8C9.79109 8 8.00023 9.79086 8.00023 12C8.00023 14.2091 9.79109 16 12.0002 16ZM12.0002 14C13.1048 14 14.0002 13.1046 14.0002 12C14.0002 10.8954 13.1048 10 12.0002 10C10.8957 10 10.0002 10.8954 10.0002 12C10.0002 13.1046 10.8957 14 12.0002 14Z' fill='black'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15.1182 1.86489L15.5203 4.81406C15.8475 4.97464 16.1621 5.1569 16.4623 5.35898L19.2185 4.23223C19.6814 4.043 20.2129 4.2248 20.463 4.65787L22.5901 8.34213C22.8401 8.77521 22.7318 9.3264 22.3365 9.63266L19.9821 11.4566C19.9941 11.6362 20.0002 11.8174 20.0002 12C20.0002 12.1826 19.9941 12.3638 19.9821 12.5434L22.3365 14.3673C22.7318 14.6736 22.8401 15.2248 22.5901 15.6579L20.463 19.3421C20.2129 19.7752 19.6814 19.957 19.2185 19.7678L16.4623 18.641C16.1621 18.8431 15.8475 19.0254 15.5203 19.1859L15.1182 22.1351C15.0506 22.6306 14.6274 23 14.1273 23H9.87313C9.37306 23 8.94987 22.6306 8.8823 22.1351L8.48014 19.1859C8.15296 19.0254 7.83835 18.8431 7.53818 18.641L4.78195 19.7678C4.31907 19.957 3.78756 19.7752 3.53752 19.3421L1.41042 15.6579C1.16038 15.2248 1.26869 14.6736 1.66401 14.3673L4.01841 12.5434C4.00636 12.3638 4.00025 12.1826 4.00025 12C4.00025 11.8174 4.00636 11.6362 4.01841 11.4566L1.66401 9.63266C1.26869 9.3264 1.16038 8.77521 1.41041 8.34213L3.53752 4.65787C3.78755 4.2248 4.31906 4.043 4.78195 4.23223L7.53818 5.35898C7.83835 5.1569 8.15296 4.97464 8.48014 4.81406L8.8823 1.86489C8.94987 1.3694 9.37306 1 9.87313 1H14.1273C14.6274 1 15.0506 1.3694 15.1182 1.86489ZM13.6826 6.14004L14.6392 6.60948C14.8842 6.72975 15.1201 6.86639 15.3454 7.01805L16.231 7.61423L19.1674 6.41382L20.4216 8.58619L17.9153 10.5278L17.9866 11.5905C17.9956 11.7255 18.0002 11.8621 18.0002 12C18.0002 12.1379 17.9956 12.2745 17.9866 12.4095L17.9153 13.4722L20.4216 15.4138L19.1674 17.5862L16.231 16.3858L15.3454 16.982C15.1201 17.1336 14.8842 17.2702 14.6392 17.3905L13.6826 17.86L13.2545 21H10.746L10.3178 17.86L9.36131 17.3905C9.11626 17.2702 8.88037 17.1336 8.6551 16.982L7.76954 16.3858L4.83313 17.5862L3.57891 15.4138L6.0852 13.4722L6.01392 12.4095C6.00487 12.2745 6.00024 12.1379 6.00024 12C6.00024 11.8621 6.00487 11.7255 6.01392 11.5905L6.0852 10.5278L3.57891 8.58619L4.83312 6.41382L7.76953 7.61423L8.6551 7.01805C8.88037 6.86639 9.11625 6.72976 9.36131 6.60949L10.3178 6.14004L10.746 3H13.2545L13.6826 6.14004Z' fill='black'/%3E%3C/svg%3E")}#browser_extension_side_menu button:hover{opacity:70%}#browser_extension_side_menu button:active{opacity:100%}@media(max-width: 500px){#browser_extension_settings_container{right:10px}#browser_extension_settings_container .extension_list_container{display:none}#browser_extension_settings_container .extension_list_container.bes_active{display:block}#browser_extension_settings_container .extension_list_container.bes_active+div{display:none}#browser_extension_settings_main a.navigation_go_previous{display:block}}`
  285. function createSwitch(options = {}) {
  286. const container = createElement("label", { class: "container" })
  287. const checkbox = createElement(
  288. "input",
  289. options.checked ? { type: "checkbox", checked: "" } : { type: "checkbox" }
  290. )
  291. addElement2(container, checkbox)
  292. const switchElm = createElement("span", { class: "switch" })
  293. addElement2(switchElm, "span", { class: "slider" })
  294. addElement2(container, switchElm)
  295. if (options.onchange) {
  296. addEventListener(checkbox, "change", options.onchange)
  297. }
  298. return container
  299. }
  300. function createSwitchOption(text, options) {
  301. const div = createElement("div", { class: "switch_option" })
  302. addElement2(div, "span", { textContent: text })
  303. div.append(createSwitch(options))
  304. return div
  305. }
  306. var besVersion = 17
  307. var openButton = `<svg viewBox="0 0 60.2601318359375 84.8134765625" version="1.1" xmlns="http://www.w3.org/2000/svg" class=" glyph-box" style="height: 9.62969px; width: 6.84191px;"><g transform="matrix(1 0 0 1 -6.194965820312518 77.63671875)"><path d="M66.4551-35.2539C66.4551-36.4746 65.9668-37.5977 65.0391-38.4766L26.3672-76.3672C25.4883-77.1973 24.4141-77.6367 23.1445-77.6367C20.6543-77.6367 18.7012-75.7324 18.7012-73.1934C18.7012-71.9727 19.1895-70.8496 19.9707-70.0195L55.5176-35.2539L19.9707-0.488281C19.1895 0.341797 18.7012 1.41602 18.7012 2.68555C18.7012 5.22461 20.6543 7.12891 23.1445 7.12891C24.4141 7.12891 25.4883 6.68945 26.3672 5.81055L65.0391-32.0312C65.9668-32.959 66.4551-34.0332 66.4551-35.2539Z"></path></g></svg>`
  308. var openInNewTabButton = `<svg viewBox="0 0 72.127685546875 72.2177734375" version="1.1" xmlns="http://www.w3.org/2000/svg" class=" glyph-box" style="height: 8.19958px; width: 8.18935px;"><g transform="matrix(1 0 0 1 -12.451127929687573 71.3388671875)"><path d="M84.5703-17.334L84.5215-66.4551C84.5215-69.2383 82.7148-71.1914 79.7852-71.1914L30.6641-71.1914C27.9297-71.1914 26.0742-69.0918 26.0742-66.748C26.0742-64.4043 28.1738-62.4023 30.4688-62.4023L47.4609-62.4023L71.2891-63.1836L62.207-55.2246L13.8184-6.73828C12.9395-5.85938 12.4512-4.73633 12.4512-3.66211C12.4512-1.31836 14.5508 0.878906 16.9922 0.878906C18.1152 0.878906 19.1895 0.488281 20.0684-0.439453L68.5547-48.877L76.6113-58.0078L75.7324-35.2051L75.7324-17.1387C75.7324-14.8438 77.7344-12.6953 80.127-12.6953C82.4707-12.6953 84.5703-14.6973 84.5703-17.334Z"></path></g></svg>`
  309. var relatedExtensions = [
  310. {
  311. id: "utags",
  312. title: "\u{1F3F7}\uFE0F UTags - Add usertags to links",
  313. url: "https://gf.qytechs.cn/scripts/460718",
  314. },
  315. {
  316. id: "links-helper",
  317. title: "\u{1F517} \u94FE\u63A5\u52A9\u624B",
  318. description:
  319. "\u5728\u65B0\u6807\u7B7E\u9875\u4E2D\u6253\u5F00\u7B2C\u4E09\u65B9\u7F51\u7AD9\u94FE\u63A5\uFF0C\u56FE\u7247\u94FE\u63A5\u8F6C\u56FE\u7247\u6807\u7B7E\u7B49",
  320. url: "https://gf.qytechs.cn/scripts/464541",
  321. },
  322. {
  323. id: "v2ex.rep",
  324. title:
  325. "V2EX.REP - \u4E13\u6CE8\u63D0\u5347 V2EX \u4E3B\u9898\u56DE\u590D\u6D4F\u89C8\u4F53\u9A8C",
  326. url: "https://gf.qytechs.cn/scripts/466589",
  327. },
  328. {
  329. id: "v2ex.min",
  330. title: "v2ex.min - V2EX \u6781\u7B80\u98CE\u683C",
  331. url: "https://gf.qytechs.cn/scripts/463552",
  332. },
  333. ]
  334. var getInstalledExtesionList = () => {
  335. return $(".extension_list_container .installed_extension_list")
  336. }
  337. var getRelatedExtesionList = () => {
  338. return $(".extension_list_container .related_extension_list")
  339. }
  340. var isInstalledExtension = (id) => {
  341. const list = getInstalledExtesionList()
  342. if (!list) {
  343. return false
  344. }
  345. const installed = $(`[data-extension-id="${id}"]`, list)
  346. return Boolean(installed)
  347. }
  348. var addCurrentExtension = (extension) => {
  349. const list = getInstalledExtesionList()
  350. if (!list) {
  351. return
  352. }
  353. if (isInstalledExtension(extension.id)) {
  354. return
  355. }
  356. const element = createInstalledExtension(extension)
  357. list.append(element)
  358. const list2 = getRelatedExtesionList()
  359. if (list2) {
  360. updateRelatedExtensions(list2)
  361. }
  362. }
  363. var activeExtension = (id) => {
  364. const list = getInstalledExtesionList()
  365. if (!list) {
  366. return false
  367. }
  368. for (const element of $$(".active", list)) {
  369. removeClass(element, "active")
  370. }
  371. const installed = $(`[data-extension-id="${id}"]`, list)
  372. if (installed) {
  373. addClass(installed, "active")
  374. }
  375. }
  376. var activeExtensionList = () => {
  377. const extensionListContainer = $(".extension_list_container")
  378. if (extensionListContainer) {
  379. addClass(extensionListContainer, "bes_active")
  380. }
  381. }
  382. var deactiveExtensionList = () => {
  383. const extensionListContainer = $(".extension_list_container")
  384. if (extensionListContainer) {
  385. removeClass(extensionListContainer, "bes_active")
  386. }
  387. }
  388. var createInstalledExtension = (installedExtension) => {
  389. const div = createElement("div", {
  390. class: "installed_extension",
  391. "data-extension-id": installedExtension.id,
  392. })
  393. const a = addElement2(div, "a", {
  394. onclick: installedExtension.onclick,
  395. })
  396. addElement2(a, "span", {
  397. textContent: installedExtension.title,
  398. })
  399. const svg = addElement2(a, "svg")
  400. svg.outerHTML = openButton
  401. return div
  402. }
  403. var updateRelatedExtensions = (container) => {
  404. container.innerHTML = ""
  405. for (const relatedExtension of relatedExtensions) {
  406. if (isInstalledExtension(relatedExtension.id)) {
  407. continue
  408. }
  409. const div4 = addElement2(container, "div", {
  410. class: "related_extension",
  411. })
  412. const a = addElement2(div4, "a", {
  413. href: relatedExtension.url,
  414. target: "_blank",
  415. })
  416. addElement2(a, "span", {
  417. textContent: relatedExtension.title,
  418. })
  419. const svg = addElement2(a, "svg")
  420. svg.outerHTML = openInNewTabButton
  421. }
  422. }
  423. function createExtensionList(installedExtensions) {
  424. const div = createElement("div", {
  425. class: "extension_list_container thin_scrollbar",
  426. })
  427. addElement2(div, "h1", { textContent: "Settings" })
  428. const div2 = addElement2(div, "div", {
  429. class: "installed_extension_list",
  430. })
  431. for (const installedExtension of installedExtensions) {
  432. if (isInstalledExtension(installedExtension.id)) {
  433. continue
  434. }
  435. const element = createInstalledExtension(installedExtension)
  436. div2.append(element)
  437. }
  438. addElement2(div, "h2", { textContent: "Other Extensions" })
  439. const div3 = addElement2(div, "div", {
  440. class: "related_extension_list",
  441. })
  442. updateRelatedExtensions(div3)
  443. return div
  444. }
  445. var prefix = "browser_extension_settings_"
  446. var randomId = String(Math.round(Math.random() * 1e4))
  447. var settingsContainerId = prefix + "container_" + randomId
  448. var settingsElementId = prefix + "main_" + randomId
  449. var getSettingsElement = () => $("#" + settingsElementId)
  450. var getSettingsStyle = () =>
  451. style_default
  452. .replace(/browser_extension_settings_container/gm, settingsContainerId)
  453. .replace(/browser_extension_settings_main/gm, settingsElementId)
  454. var storageKey = "settings"
  455. var settingsOptions
  456. var settingsTable = {}
  457. var settings = {}
  458. async function getSettings() {
  459. var _a
  460. return (_a = await getValue(storageKey)) != null ? _a : {}
  461. }
  462. async function saveSattingsValue(key, value) {
  463. const settings2 = await getSettings()
  464. settings2[key] =
  465. settingsTable[key] && settingsTable[key].defaultValue === value
  466. ? void 0
  467. : value
  468. await setValue(storageKey, settings2)
  469. }
  470. async function resetSattingsValues() {
  471. await setValue(storageKey, {})
  472. }
  473. async function saveSattingsValues(values) {
  474. const settings2 = await getSettings()
  475. for (const key in values) {
  476. if (Object.hasOwn(values, key)) {
  477. const value = values[key]
  478. settings2[key] =
  479. settingsTable[key] && settingsTable[key].defaultValue === value
  480. ? void 0
  481. : value
  482. }
  483. }
  484. await setValue(storageKey, settings2)
  485. }
  486. function getSettingsValue(key) {
  487. var _a
  488. return Object.hasOwn(settings, key)
  489. ? settings[key]
  490. : (_a = settingsTable[key]) == null
  491. ? void 0
  492. : _a.defaultValue
  493. }
  494. var closeModal = () => {
  495. const settingsContainer = getSettingsContainer()
  496. if (settingsContainer) {
  497. settingsContainer.style.display = "none"
  498. }
  499. removeEventListener(document, "click", onDocumentClick, true)
  500. removeEventListener(document, "keydown", onDocumentKeyDown, true)
  501. }
  502. var onDocumentClick = (event) => {
  503. const target = event.target
  504. if (target == null ? void 0 : target.closest(`.${prefix}container`)) {
  505. return
  506. }
  507. closeModal()
  508. }
  509. var onDocumentKeyDown = (event) => {
  510. if (event.defaultPrevented) {
  511. return
  512. }
  513. if (event.key === "Escape") {
  514. closeModal()
  515. event.preventDefault()
  516. }
  517. }
  518. async function updateOptions() {
  519. if (!getSettingsElement()) {
  520. return
  521. }
  522. for (const key in settingsTable) {
  523. if (Object.hasOwn(settingsTable, key)) {
  524. const item = settingsTable[key]
  525. const type = item.type || "switch"
  526. switch (type) {
  527. case "switch": {
  528. const checkbox = $(
  529. `#${settingsElementId} .option_groups .switch_option[data-key="${key}"] input`
  530. )
  531. if (checkbox) {
  532. checkbox.checked = getSettingsValue(key)
  533. }
  534. break
  535. }
  536. case "textarea": {
  537. const textArea = $(
  538. `#${settingsElementId} .option_groups textarea[data-key="${key}"]`
  539. )
  540. if (textArea) {
  541. textArea.value = getSettingsValue(key)
  542. }
  543. break
  544. }
  545. default: {
  546. break
  547. }
  548. }
  549. }
  550. }
  551. if (typeof settingsOptions.onViewUpdate === "function") {
  552. const settingsMain = createSettingsElement()
  553. settingsOptions.onViewUpdate(settingsMain)
  554. }
  555. }
  556. function getSettingsContainer() {
  557. const container = $(`.${prefix}container`)
  558. if (container) {
  559. const theVersion = parseInt10(container.dataset.besVersion, 0)
  560. if (theVersion < besVersion) {
  561. container.id = settingsContainerId
  562. container.dataset.besVersion = String(besVersion)
  563. }
  564. return container
  565. }
  566. return addElement2(doc.body, "div", {
  567. id: settingsContainerId,
  568. class: `${prefix}container`,
  569. "data-bes-version": besVersion,
  570. style: "display: none;",
  571. })
  572. }
  573. function getSettingsWrapper() {
  574. const container = getSettingsContainer()
  575. return (
  576. $(`.${prefix}wrapper`, container) ||
  577. addElement2(container, "div", {
  578. class: `${prefix}wrapper`,
  579. })
  580. )
  581. }
  582. function initExtensionList() {
  583. const wrapper = getSettingsWrapper()
  584. if (!$(".extension_list_container", wrapper)) {
  585. const list = createExtensionList([])
  586. wrapper.append(list)
  587. }
  588. addCurrentExtension({
  589. id: settingsOptions.id,
  590. title: settingsOptions.title,
  591. onclick: showSettings,
  592. })
  593. }
  594. function createSettingsElement() {
  595. let settingsMain = getSettingsElement()
  596. if (!settingsMain) {
  597. const wrapper = getSettingsWrapper()
  598. for (const element of $$(`.${prefix}main`)) {
  599. element.remove()
  600. }
  601. settingsMain = addElement2(wrapper, "div", {
  602. id: settingsElementId,
  603. class: `${prefix}main thin_scrollbar`,
  604. })
  605. addElement2(settingsMain, "a", {
  606. textContent: "Settings",
  607. class: "navigation_go_previous",
  608. onclick() {
  609. activeExtensionList()
  610. },
  611. })
  612. if (settingsOptions.title) {
  613. addElement2(settingsMain, "h2", { textContent: settingsOptions.title })
  614. }
  615. const optionGroups = []
  616. const getOptionGroup = (index) => {
  617. if (index > optionGroups.length) {
  618. for (let i = optionGroups.length; i < index; i++) {
  619. optionGroups.push(
  620. addElement2(settingsMain, "div", {
  621. class: "option_groups",
  622. })
  623. )
  624. }
  625. }
  626. return optionGroups[index - 1]
  627. }
  628. for (const key in settingsTable) {
  629. if (Object.hasOwn(settingsTable, key)) {
  630. const item = settingsTable[key]
  631. const type = item.type || "switch"
  632. const group = item.group || 1
  633. const optionGroup = getOptionGroup(group)
  634. switch (type) {
  635. case "switch": {
  636. const switchOption = createSwitchOption(item.title, {
  637. async onchange(event) {
  638. const checkbox = event.target
  639. if (checkbox) {
  640. await saveSattingsValue(key, checkbox.checked)
  641. }
  642. },
  643. })
  644. switchOption.dataset.key = key
  645. addElement2(optionGroup, switchOption)
  646. break
  647. }
  648. case "textarea": {
  649. let timeoutId
  650. const div = addElement2(optionGroup, "div", {
  651. class: "bes_textarea",
  652. })
  653. addElement2(div, "textarea", {
  654. "data-key": key,
  655. placeholder: item.placeholder || "",
  656. onkeyup(event) {
  657. const textArea = event.target
  658. if (timeoutId) {
  659. clearTimeout(timeoutId)
  660. timeoutId = void 0
  661. }
  662. timeoutId = setTimeout(async () => {
  663. if (textArea) {
  664. await saveSattingsValue(key, textArea.value.trim())
  665. }
  666. }, 100)
  667. },
  668. })
  669. break
  670. }
  671. case "action": {
  672. addElement2(optionGroup, "a", {
  673. class: "action",
  674. textContent: item.title,
  675. onclick: item.onclick,
  676. })
  677. break
  678. }
  679. case "externalLink": {
  680. const div4 = addElement2(optionGroup, "div", {
  681. class: "bes_external_link",
  682. })
  683. addElement2(div4, "a", {
  684. textContent: item.title,
  685. href: item.url,
  686. target: "_blank",
  687. })
  688. break
  689. }
  690. case "tip": {
  691. const tip = addElement2(optionGroup, "div", {
  692. class: "bes_tip",
  693. })
  694. addElement2(tip, "a", {
  695. class: "bes_tip_anchor",
  696. textContent: item.title,
  697. })
  698. const tipContent = addElement2(tip, "div", {
  699. class: "bes_tip_content",
  700. innerHTML: item.tipContent,
  701. })
  702. break
  703. }
  704. }
  705. }
  706. }
  707. if (settingsOptions.footer) {
  708. const footer = addElement2(settingsMain, "footer")
  709. footer.innerHTML =
  710. typeof settingsOptions.footer === "string"
  711. ? settingsOptions.footer
  712. : `<p>Made with \u2764\uFE0F by
  713. <a href="https://www.pipecraft.net/" target="_blank">
  714. Pipecraft
  715. </a></p>`
  716. }
  717. }
  718. return settingsMain
  719. }
  720. function addSideMenu() {
  721. if (!getSettingsValue("displaySettingsButtonInSideMenu")) {
  722. return
  723. }
  724. const menu =
  725. $("#browser_extension_side_menu") ||
  726. addElement2(doc.body, "div", {
  727. id: "browser_extension_side_menu",
  728. "data-bes-version": besVersion,
  729. })
  730. const button = $("button[data-bes-version]", menu)
  731. if (button) {
  732. const theVersion = parseInt10(button.dataset.besVersion, 0)
  733. if (theVersion >= besVersion) {
  734. return
  735. }
  736. button.remove()
  737. }
  738. addElement2(menu, "button", {
  739. type: "button",
  740. "data-bes-version": besVersion,
  741. title: "\u8BBE\u7F6E",
  742. onclick() {
  743. setTimeout(showSettings, 1)
  744. },
  745. })
  746. }
  747. function addCommonSettings(settingsTable3) {
  748. let maxGroup = 0
  749. for (const key in settingsTable3) {
  750. if (Object.hasOwn(settingsTable3, key)) {
  751. const item = settingsTable3[key]
  752. const group = item.group || 1
  753. if (group > maxGroup) {
  754. maxGroup = group
  755. }
  756. }
  757. }
  758. settingsTable3.displaySettingsButtonInSideMenu = {
  759. title: "Display Settings Button in Side Menu",
  760. defaultValue: !(
  761. typeof GM === "object" && typeof GM.registerMenuCommand === "function"
  762. ),
  763. group: maxGroup + 1,
  764. }
  765. }
  766. function handleShowSettingsUrl() {
  767. if (location.hash === "#bes-show-settings") {
  768. setTimeout(showSettings, 100)
  769. }
  770. }
  771. async function showSettings() {
  772. const settingsContainer = getSettingsContainer()
  773. const settingsMain = createSettingsElement()
  774. await updateOptions()
  775. settingsContainer.style.display = "block"
  776. addEventListener(document, "click", onDocumentClick, true)
  777. addEventListener(document, "keydown", onDocumentKeyDown, true)
  778. activeExtension(settingsOptions.id)
  779. deactiveExtensionList()
  780. }
  781. var initSettings = async (options) => {
  782. settingsOptions = options
  783. settingsTable = options.settingsTable || {}
  784. addCommonSettings(settingsTable)
  785. addValueChangeListener(storageKey, async () => {
  786. settings = await getSettings()
  787. await updateOptions()
  788. addSideMenu()
  789. if (typeof options.onValueChange === "function") {
  790. options.onValueChange()
  791. }
  792. })
  793. settings = await getSettings()
  794. addStyle2(getSettingsStyle())
  795. runWhenBodyExists(() => {
  796. initExtensionList()
  797. addSideMenu()
  798. })
  799. handleShowSettingsUrl()
  800. }
  801. var enhance_node_name_default =
  802. "#Main .box a.node{color:#1ba784}#Main td:has(.topic_info){display:flex;flex-direction:column-reverse}div.cell:has(.topic_info){border-bottom:5px solid var(--box-border-color)}"
  803. var hide_last_replier_default =
  804. "#Main .topic_info strong:nth-of-type(2),#Main .topic_info .last_replier_text{display:none}#Main .cell:hover .topic_info strong:nth-of-type(2),#Main .cell:hover .topic_info .last_replier_text{display:contents}"
  805. var hide_profile_photo_default =
  806. '#Main td:has(a>img.avatar),#Main td:has(a>img.avatar)+td[width="10"],#Main td[width="48"],#Main td[width="48"]+td[width="10"],#TopicsHot td:has(a>img.avatar),#TopicsHot td:has(a>img.avatar)+td,#my-recent-topics td:has(a>img),#my-recent-topics td:has(a>img)+td,#Main>box>div.cell[id] td:has(img.avatar),#Main>box>div.cell[id] td:has(img.avatar)+td{display:none !important}td>strong>.dark{color:#1ba784 !important}'
  807. var minimalist_default =
  808. '*{box-shadow:unset !important;text-shadow:unset !important}.box,#Main .box,#Top,#Tabs,#Wrapper,#Bottom{background-image:unset !important;border:none !important}.cell,.box,.super.button,.topic_buttons,div[style*=border]{border:unset !important;background-image:unset !important}.count_livid{padding:0 !important;margin-right:0 !important;color:#999 !important;font-family:"Bender" !important;background-color:unset !important}body #Wrapper{background-color:#fff;--topic-link-color: #444444;--topic-link-hover-color: #217dfc;--primary-button-fill-color: #217dfc;--primary-button-text-color: #fff}body #Wrapper.Night{background-color:var(--box-background-color);--topic-link-color: #9caec7;--topic-link-hover-color: #a9bcd6;--primary-button-fill-color: #217dfc;--primary-button-text-color: #fff}a.topic-link:active,a.topic-link:link{color:var(--topic-link-color)}a.topic-link:hover{color:var(--topic-link-hover-color)}img{max-width:100%}body .super.button{background-color:var(--primary-button-fill-color);color:var(--primary-button-text-color);font-weight:400;border:rgba(0,0,0,0);border-radius:4px}body .super.button+.super.button{border-left:1px solid rgba(255,255,255,.2509803922) !important}body .super.button:not(.disable_now):hover,body .super.button:hover:enabled{background-color:var(--primary-button-fill-color) !important;opacity:85%;color:var(--primary-button-text-color) !important;font-weight:400;text-shadow:unset !important}'
  809. var no_ads_default =
  810. ".box:has(>style),div:has(>script),div:has(>.wwads-cn),.box:has(>.sidebar_compliance),div:has(>a>#DigitalOcean){display:none !important}"
  811. var side_nav_default =
  812. '#v2min_sideNav{--background-color: #000;--button-color: #aaa;--button-hover-color: #fff;--button-separator-color: #999;position:fixed;display:flex !important;bottom:0px;right:0px;background-color:var(--background-color);opacity:75%;border-top-left-radius:6px}#v2min_sideNav button{color:var(--button-color);font-size:18px;width:30px;height:30px;background-color:unset;border:none;position:relative}#v2min_sideNav button:hover{color:var(--button-hover-color)}#v2min_sideNav button:disabled{color:#778087;opacity:50%}#v2min_sideNav button::after{content:"";border-left:1px solid var(--button-separator-color);position:absolute;bottom:10px;right:-1px;width:1px;height:10px}#v2min_sideNav button:last-of-type::after{display:none}#v2min_sideNav button.fa-chevron-left,#v2min_sideNav button.fa-chevron-right,#v2min_sideNav button.fa-bell{font-size:14px}'
  813. var sticky_header_default =
  814. '#Top{position:fixed;top:0;width:100%;box-sizing:border-box}#Top .content{max-width:unset !important;width:100% !important}.site-nav .tools{flex:unset}.site-nav a[name=top]{margin-right:auto}#Wrapper::before{content:"";display:block;height:44px}#placeholder{height:38px}#Tabs{position:fixed;top:1px;padding:9px;border:none}#search-container{width:100px}#search-container:has(input:focus){width:300px}body:has(input:focus) #Tabs{display:none}@media only screen and (max-width: 1300px){.site-nav a[name=top]{visibility:hidden}}*{scroll-margin-top:44px}'
  815. function showSideNav() {
  816. if (!document.body) {
  817. return
  818. }
  819. if (!$("#v2min_sideNav")) {
  820. const sideNav = addElement2(document.body, "div", {
  821. id: "v2min_sideNav",
  822. style: "display: none",
  823. })
  824. addElement2(sideNav, "button", {
  825. class: "fa fa-arrow-circle-up",
  826. title: "Back to the top",
  827. onclick() {
  828. window.scrollTo({
  829. top: 0,
  830. behavior: "smooth",
  831. })
  832. },
  833. })
  834. addElement2(sideNav, "button", {
  835. class: "fa fa-comments",
  836. title: "Comments",
  837. disabled:
  838. location.href.includes("/t/") && $("#Main > div:nth-child(4)")
  839. ? void 0
  840. : true,
  841. onclick() {
  842. window.scrollTo({
  843. top:
  844. $("#Main > div:nth-child(4)").offsetTop -
  845. (getSettingsValue("stickyHeader") ? 44 : 0),
  846. behavior: "smooth",
  847. })
  848. },
  849. })
  850. addElement2(sideNav, "button", {
  851. class: "fa fa-edit",
  852. title: "Add comment",
  853. value: "AA",
  854. disabled:
  855. location.href.includes("/t/") && $("#reply_content") ? void 0 : true,
  856. onclick() {
  857. $("#reply_content").focus()
  858. },
  859. })
  860. addElement2(sideNav, "button", {
  861. class: "fa fa-chevron-left",
  862. title: "Go to previous page",
  863. disabled: $('*[title="\u4E0A\u4E00\u9875"]') ? void 0 : true,
  864. onclick() {
  865. $('*[title="\u4E0A\u4E00\u9875"]').click()
  866. },
  867. })
  868. addElement2(sideNav, "button", {
  869. class: "fa fa-chevron-right",
  870. title: "Go to next page",
  871. disabled: $('*[title="\u4E0B\u4E00\u9875"]') ? void 0 : true,
  872. onclick() {
  873. $('*[title="\u4E0B\u4E00\u9875"]').click()
  874. },
  875. })
  876. addElement2(sideNav, "button", {
  877. class: "fa fa-bell",
  878. title: "Notifications",
  879. onclick() {
  880. location.href = "https://www.v2ex.com/notifications"
  881. },
  882. })
  883. addElement2(sideNav, "button", {
  884. class: "fa fa-home",
  885. title: "Home",
  886. onclick() {
  887. location.href = "/"
  888. },
  889. })
  890. addElement2(sideNav, "button", {
  891. class: "fa fa-cog",
  892. title: "Settings",
  893. onclick() {
  894. setTimeout(showSettings, 1)
  895. },
  896. })
  897. }
  898. }
  899. var config = {
  900. matches: ["https://*.v2ex.com/*", "https://v2hot.pipecraft.net/*"],
  901. run_at: "document_start",
  902. }
  903. var settingsTable2 = {
  904. minimalist: {
  905. title: "\u6781\u7B80\u98CE\u683C",
  906. defaultValue: true,
  907. },
  908. stickyHeader: {
  909. title: "\u5BFC\u822A\u680F\u9876\u90E8\u56FA\u5B9A",
  910. defaultValue: true,
  911. },
  912. hideNodeList: {
  913. title: "\u9690\u85CF\u8282\u70B9\u5217\u8868",
  914. defaultValue: true,
  915. },
  916. enhanceNodeName: {
  917. title: "\u589E\u5F3A\u663E\u793A\u8282\u70B9\u540D",
  918. defaultValue: true,
  919. },
  920. showSideNav: {
  921. title: "\u663E\u793A\u5FEB\u6377\u6309\u94AE",
  922. defaultValue: true,
  923. },
  924. bodyBackgroundColor: {
  925. title: "\u53BB\u9664\u9875\u9762\u80CC\u666F\u8272",
  926. defaultValue: false,
  927. },
  928. hidePinnedTopics: {
  929. title: "\u9690\u85CF\u7F6E\u9876\u5E16\u5B50",
  930. defaultValue: false,
  931. },
  932. hideProfilePhoto: {
  933. title: "\u9690\u85CF\u7528\u6237\u5934\u50CF",
  934. defaultValue: false,
  935. },
  936. hideLastReplier: {
  937. title: "\u9690\u85CF\u6700\u540E\u56DE\u590D\u8005",
  938. defaultValue: false,
  939. },
  940. customStyle: {
  941. title: "\u81EA\u5B9A\u4E49\u6837\u5F0F",
  942. defaultValue: false,
  943. },
  944. customStyleValue: {
  945. title: "Enable custom rules for the current site",
  946. defaultValue: "",
  947. placeholder: `/* \u81EA\u5B9A\u4E49\u6837\u5F0F */
  948. body #Wrapper {
  949. background-color: #f0f0f0;
  950. }
  951. body #Wrapper.Night {
  952. background-color: #22303f;
  953. }`,
  954. type: "textarea",
  955. group: 2,
  956. },
  957. customStyleTip: {
  958. title: "Examples",
  959. type: "tip",
  960. tipContent: `<p>\u81EA\u5B9A\u4E49\u6837\u5F0F\u793A\u4F8B</p>
  961. <p>
  962. <pre>
  963. body #Wrapper {
  964. background-color: #f0f0f0;
  965. }
  966. /* \u9ED1\u6697\u6A21\u5F0F */
  967. body #Wrapper.Night {
  968. background-color: #22303f;
  969. }</pre>
  970. </p>`,
  971. group: 2,
  972. },
  973. resetAll: {
  974. title: "\u91CD\u7F6E\u6240\u6709\u8BBE\u7F6E",
  975. type: "action",
  976. async onclick() {
  977. await resetSattingsValues()
  978. },
  979. group: 3,
  980. },
  981. resetToV2ex: {
  982. title: "\u6062\u590D V2EX \u9ED8\u8BA4\u6837\u5F0F",
  983. type: "action",
  984. async onclick() {
  985. await saveSattingsValues({
  986. enhanceNodeName: false,
  987. hideNodeList: false,
  988. stickyHeader: false,
  989. bodyBackgroundColor: false,
  990. minimalist: false,
  991. hidePinnedTopics: false,
  992. hideProfilePhoto: false,
  993. customStyle: false,
  994. showSideNav: false,
  995. })
  996. },
  997. group: 3,
  998. },
  999. }
  1000. function registerMenuCommands() {
  1001. registerMenuCommand("\u2699\uFE0F \u8BBE\u7F6E", showSettings, "o")
  1002. }
  1003. async function addStyles() {
  1004. const styles = []
  1005. styles.push(no_ads_default)
  1006. if (getSettingsValue("stickyHeader")) {
  1007. styles.push(sticky_header_default)
  1008. }
  1009. if (getSettingsValue("minimalist")) {
  1010. styles.push(minimalist_default)
  1011. }
  1012. if (!getSettingsValue("bodyBackgroundColor")) {
  1013. styles.push(`
  1014. body #Wrapper {
  1015. background-color: #f0f0f0;
  1016. }
  1017. body #Wrapper.Night {
  1018. background-color: #22303f;
  1019. }
  1020. `)
  1021. }
  1022. if (getSettingsValue("enhanceNodeName")) {
  1023. styles.push(enhance_node_name_default)
  1024. }
  1025. if (getSettingsValue("hideProfilePhoto")) {
  1026. styles.push(hide_profile_photo_default)
  1027. }
  1028. if (getSettingsValue("hideLastReplier")) {
  1029. for (const element of $$("#Main .topic_info strong:nth-of-type(2)")) {
  1030. if (element.previousSibling.nodeName === "SPAN") continue
  1031. const span = createElement("span", { class: "last_replier_text" })
  1032. span.append(element.previousSibling)
  1033. element.before(span)
  1034. }
  1035. styles.push(hide_last_replier_default)
  1036. }
  1037. if (getSettingsValue("showSideNav")) {
  1038. styles.push(side_nav_default)
  1039. runWhenBodyExists(showSideNav)
  1040. }
  1041. if (getSettingsValue("hidePinnedTopics")) {
  1042. styles.push(`/* Hide pinned topics */
  1043. #Main > div:nth-child(2) > div[style*="corner"] {
  1044. display: none;
  1045. }
  1046. `)
  1047. }
  1048. if (getSettingsValue("hideNodeList")) {
  1049. styles.push(`/* \u53F3\u4FA7\u680F\u4E00\u4E9B\u4E1C\u897F */
  1050. #TopicsHot + div,
  1051. #TopicsHot + div + div,
  1052. #TopicsHot + div + div + div,
  1053. #TopicsHot + div + div + div + div,
  1054. #TopicsHot + div + div + div + div + div,
  1055. #TopicsHot + div + div + div + div + div + div {
  1056. display: none !important;
  1057. }
  1058. /* \u6211\u6536\u85CF\u7684\u8282\u70B9 */
  1059. .box:has(#nodes-sidebar),
  1060. .box:has(#nodes-sidebar) + .sep20 {
  1061. display: none;
  1062. }
  1063. /* \u8282\u70B9\u5BFC\u822A */
  1064. .box:has(a[href="/planes"]) {
  1065. display: none;
  1066. }
  1067. `)
  1068. }
  1069. if (getSettingsValue("hideUnwantedTabs")) {
  1070. styles.push(`/* Some tabs */
  1071. #Tabs > a:nth-child(4),
  1072. #Tabs > a:nth-child(5),
  1073. #Tabs > a:nth-child(6),
  1074. #Tabs > a:nth-child(7),
  1075. #Tabs > a:nth-child(13) {
  1076. display: none;
  1077. }
  1078. #Tabs > a {
  1079. min-width: 3.5em;
  1080. text-align: center;
  1081. }
  1082. `)
  1083. }
  1084. if ($("#v2min_style")) {
  1085. $("#v2min_style").textContent = styles.join("\n")
  1086. } else {
  1087. addElement2("style", {
  1088. id: "v2min_style",
  1089. textContent: styles.join("\n"),
  1090. })
  1091. }
  1092. const customStyleValue = getSettingsValue("customStyleValue") || ""
  1093. if (getSettingsValue("customStyle") && customStyleValue) {
  1094. if ($("#v2min_custom_style")) {
  1095. $("#v2min_custom_style").textContent = customStyleValue
  1096. } else {
  1097. addElement2("style", {
  1098. id: "v2min_custom_style",
  1099. textContent: customStyleValue,
  1100. })
  1101. }
  1102. } else if ($("#v2min_custom_style")) {
  1103. $("#v2min_custom_style").remove()
  1104. }
  1105. if ($("#Tabs")) $("#Tabs").style.display = "block"
  1106. }
  1107. async function main() {
  1108. if (document["v2ex.min"]) {
  1109. return
  1110. }
  1111. document["v2ex.min"] = true
  1112. await initSettings({
  1113. id: "v2ex.min",
  1114. title: "v2ex.min - V2EX Minimalist (\u6781\u7B80\u98CE\u683C)",
  1115. footer: `
  1116. <p>
  1117. <a href="https://github.com/v2hot/v2ex.min/issues" target="_blank">
  1118. Report and Issue...
  1119. </a></p>
  1120. <p>Made with \u2764\uFE0F by
  1121. <a href="https://www.pipecraft.net/" target="_blank">
  1122. Pipecraft
  1123. </a></p>`,
  1124. settingsTable: settingsTable2,
  1125. async onValueChange() {
  1126. await addStyles()
  1127. },
  1128. onViewUpdate(settingsMainView) {
  1129. const group2 = $(`.option_groups:nth-of-type(2)`, settingsMainView)
  1130. if (group2) {
  1131. group2.style.display = getSettingsValue(`customStyle`)
  1132. ? "block"
  1133. : "none"
  1134. }
  1135. },
  1136. })
  1137. registerMenuCommands()
  1138. runWhenHeadExists(addStyles)
  1139. addEventListener(document, "DOMContentLoaded", addStyles)
  1140. }
  1141. main()
  1142. })()

QingJ © 2025

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