🏠 返回首頁 

Greasy Fork is available in English.

Forum Grandmaster for Discuz! (Final Version)

🔊论坛网站页面美化、广告移除、功能增强。美轮美奂的视觉享受,安然恬静的论坛时光……

  1. // ==UserScript==
  2. // @name Forum Grandmaster for Discuz! (Final Version)
  3. // @name:en Forum Grandmaster for Discuz! (Final Version)
  4. // @name:zh 论坛大师・Discuz!(全功能最终版)
  5. // @name:zh-CN 论坛大师・Discuz!(全功能最终版)
  6. // @name:zh-HK 論壇大師・Discuz!(全功能最終版)
  7. // @name:zh-MO 論壇大師・Discuz!(全功能最終版)
  8. // @name:zh-TW 論壇大師・Discuz!(全功能最終版)
  9. // @namespace Forum Grandmaster for Discuz!
  10. // @version 0.3.71
  11. // @author hostname
  12. // @description 🔊论坛网站页面美化、广告移除、功能增强。美轮美奂的视觉享受,安然恬静的论坛时光……
  13. // @description:en 🔊Beautify the interface, Remove ads, Enhance functions.
  14. // @description:zh 🔊论坛网站页面美化、广告移除、功能增强。美轮美奂的视觉享受,安然恬静的论坛时光……
  15. // @description:zh-CN 🔊论坛网站页面美化、广告移除、功能增强。美轮美奂的视觉享受,安然恬静的论坛时光……
  16. // @description:zh-HK 🔊論壇網站頁面美化、廣告移除、功能增強。美輪美奐的視覺享受,安然恬靜的論壇時光……
  17. // @description:zh-MO 🔊論壇網站頁面美化、廣告移除、功能增強。美輪美奐的視覺享受,安然恬靜的論壇時光……
  18. // @description:zh-TW 🔊論壇網站頁面美化、廣告移除、功能增強。美輪美奐的視覺享受,安然恬靜的論壇時光……
  19. // @homepage https://github.com/hishis/forum-grandmaster-for-discuz
  20. // @icon https://cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/favicon.ico
  21. // @supportURL https://github.com/hishis/forum-grandmaster-for-discuz/issues
  22. // @match http*://www.52pojie.cn/
  23. // @match http*://www.chiphell.com/
  24. // @match http*://www.right.com.cn/
  25. // @match http*://bbs.kafan.cn/
  26. // @match http*://www.hostloc.com/
  27. // @match http*://bbs.pcbeta.com/
  28. // @match http*://www.zuanke8.com/
  29. // @match http*://bbs.51credit.com/
  30. // @match http*://bbs.ydss.cn/
  31. // @match http*://bbs.fobshanghai.com/
  32. // @match http*://bbs.huorong.cn/
  33. // @match http*://www.gebi1.com/
  34. // @match http*://www.advertcn.com/
  35. // @match http*://www.fglt.net/
  36. // @match http*://www.fglt.cn/
  37. // @match http*://www.aihao.cc/
  38. // @match http*://bbs.nas66.com/
  39. // @match http*://keylol.com/*
  40. // @match http*://www.keylol.com/*
  41. // @match http*://www.viidii.info/?action=image&*
  42. // @match http*://www.viidii.info/?http*://*
  43. // @match http*://*/*/forum-*.html
  44. // @match http*://*/*/forum-*.html?*
  45. // @match http*://*/*/forum.php
  46. // @match http*://*/*/forum.php?gid=*
  47. // @match http*://*/*/forum.php?mod=forumdisplay&fid=*
  48. // @match http*://*/*/forum.php?mod=post&action=edit&*
  49. // @match http*://*/*/forum.php?mod=post&action=newthread&*
  50. // @match http*://*/*/forum.php?mod=viewthread&tid=*
  51. // @match http*://*/*/forumdisplay.php?*
  52. // @match http*://*/*/read.php?*
  53. // @match http*://*/*/thread-*.html
  54. // @match http*://*/*/thread-*.html?*
  55. // @match http*://*/*/thread*.php
  56. // @match http*://*/*/thread*.php?fid=*
  57. // @match http*://*/*/viewthread-*.html
  58. // @match http*://*/*/viewthread.php?*
  59. // @match http*://*/forum-*.html
  60. // @match http*://*/forum-*.html?*
  61. // @match http*://*/forum.php
  62. // @match http*://*/forum.php?gid=*
  63. // @match http*://*/forum.php?mod=forumdisplay&fid=*
  64. // @match http*://*/forum.php?mod=post&action=edit&*
  65. // @match http*://*/forum.php?mod=post&action=newthread&*
  66. // @match http*://*/forum.php?mod=viewthread&tid=*
  67. // @match http*://*/forumdisplay.php?*
  68. // @match http*://*/htm_data/*.html
  69. // @match http*://*/read.php?*
  70. // @match http*://*/thread-*.html
  71. // @match http*://*/thread-*.html?*
  72. // @match http*://*/thread*.php
  73. // @match http*://*/thread*.php?fid=*
  74. // @match http*://*/viewthread-*.html
  75. // @match http*://*/viewthread.php?*
  76. // @match http*://hishis.github.io/tools/forum-grandmaster/
  77. // @compatible Chrome Works with Tampermonkey for Chrome
  78. // @compatible Edge Works with Tampermonkey for Edge
  79. // @compatible Firefox Works with Tampermonkey for Firefox
  80. // @compatible Opera Works with Tampermonkey for Opera
  81. // @compatible Safari Works with Tampermonkey for Safari
  82. // @run-at document-start
  83. // @connect self
  84. // @connect cdn.jsdelivr.net
  85. // @connect greasyfork.org
  86. // @connect github.com
  87. // @connect raw.githubusercontent.com
  88. // @grant unsafeWindow
  89. // @grant GM_addStyle
  90. // @grant GM_deleteValue
  91. // @grant GM_listValues
  92. // @grant GM_addValueChangeListener
  93. // @grant GM_removeValueChangeListener
  94. // @grant GM_setValue
  95. // @grant GM_getValue
  96. // @grant GM_log
  97. // @grant GM_getResourceText
  98. // @grant GM_getResourceURL
  99. // @grant GM_registerMenuCommand
  100. // @grant GM_unregisterMenuCommand
  101. // @grant GM_openInTab
  102. // @grant GM_xmlhttpRequest
  103. // @grant GM_download
  104. // @grant GM_getTab
  105. // @grant GM_saveTab
  106. // @grant GM_getTabs
  107. // @grant GM_notification
  108. // @grant GM_setClipboard
  109. // @grant GM_info
  110. // @grant window.close
  111. // @grant window.focus
  112. // @license MPL-2.0
  113. // ==/UserScript==
  114. /**
  115. * Forum Grandmaster for Discuz! – https://github.com/hishis/forum-grandmaster-for-discuz
  116. *
  117. * == BEGIN LICENSE BLOCK ==
  118. *
  119. * Open name: Forum Grandmaster for Discuz!
  120. * Open home: https://github.com/hishis/forum-grandmaster-for-discuz
  121. * Copyright Forum Grandmaster for Discuz!
  122. * Licensed under MPL 2.0 (https://www.mozilla.org/MPL/2.0/)
  123. *
  124. * == END LICENSE BLOCK ==
  125. *
  126. * Licensed under the terms of any of the following licenses at your
  127. * choice:
  128. *
  129. * 1. GPL – GNU General Public License
  130. * https://www.gnu.org/licenses/gpl-3.0.html
  131. *
  132. * 2. MPL – Mozilla Public License
  133. * https://www.mozilla.org/MPL/2.0/
  134. *
  135. * The original copyright notice must be retained.
  136. */
  137. (function () {
  138. 'use strict';
  139. if (typeof GM_addStyle === 'undefined') {
  140. if (window.navigator.userAgent.includes('Firefox')) {
  141. alert('论坛大师油猴脚本暂不支持 Greasemonkey(油猴子),建议安装 Tampermonkey 或 Violentmonkey(##猴)扩展程序!');
  142. window.location.replace('https://addons.mozilla.org/firefox/addon/tampermonkey/');
  143. } else {
  144. alert('论坛大师油猴脚本暂不支持当前扩展,建议安装 Tampermonkey 或 Violentmonkey(##猴)扩展程序!');
  145. window.location.replace('https://www.tampermonkey.net/');
  146. }
  147. document.body.innerHTML = '';
  148. }
  149. // Hostname
  150. const HN = window.location.hostname;
  151. // User-Agent
  152. const ua = window.navigator.userAgent;
  153. // Runtime Type Checks – Runtime type checks for JavaScript and TypeScript
  154. const list_aaaa = [];
  155. const list_bbbb = [];
  156. // Runtime type checks for JavaScript
  157. if (list_aaaa === list_bbbb) {
  158. // Runtime type checks for TypeScript
  159. check_for_typescript(window.Node);
  160. }
  161. // Runtime type checks for TypeScript
  162. function check_for_typescript(e) {
  163. // A reasonably-typed TypeScript application gives the developer enough confidence that the operations within the applicaiton are safe and predictable. As a r###lt, you rarely see the 'undefined is not a function' errors, which is often caused by passing a wrong type of object.
  164. // This is because the TypeScript type checker ensures that you only invoke functions with compatible parameters. The type checker, however, cannot verify this at the application or module boundary, where the application receives data from the backend, a web-worker, or just another module. Here, we cannot know statically if the data is correct. So we just have to trust that it is.
  165. let type = typeof e;
  166. let a = [
  167. type,
  168. ];
  169. let b = [
  170. type,
  171. ];
  172. a.push(a);
  173. b.push(b);
  174. if (a === b) {
  175. a = a.push(a.push(e, type));
  176. b = b.push(b.push(e, type));
  177. switch (true) {
  178. case a === b:
  179. e = a[0];
  180. break;
  181. case a > b:
  182. e = a[1];
  183. break;
  184. case a < b:
  185. e = a[2];
  186. break;
  187. default:
  188. break;
  189. }
  190. return check_for_typescript(e);
  191. } else {
  192. return false;
  193. }
  194. }
  195. // Scene mode: Standard, Home, Office
  196. let scene_mode = GM_getValue('SCENE_MODE', 'Standard');
  197. let common_css = ':root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#dc3545;--orange:#fd7e14;--yellow:#ffc107;--green:#28a745;--teal:#20c997;--cyan:#17a2b8;--white:#fff;--gray:#6c757d;--gray-dark:#343a40;--primary:#007bff;--secondary:#6c757d;--success:#28a745;--info:#17a2b8;--warning:#ffc107;--danger:#dc3545;--light:#f8f9fa;--dark:#343a40;--breakpoint-xs:0;--breakpoint-sm:576px;--breakpoint-md:768px;--breakpoint-lg:992px;--breakpoint-xl:1200px;--font-family-sans-serif:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Noto Sans CJK","PingFang SC","Hiragino Sans GB","Microsoft YaHei New","Microsoft Yahei","WenQuanYi Micro Hei",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-family-monospace:"Fira Code",Hack,"Source Code Pro","Source Code Variable",SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New","Noto Sans Mono CJK","Microsoft YaHei Mono","WenQuanYi Zen Hei Mono",monospace}body,table,input,button,select,textarea,a{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Noto Sans CJK","PingFang SC","Hiragino Sans GB","Microsoft YaHei New","Microsoft Yahei","WenQuanYi Micro Hei",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"}.mono,.md,.code,.pre,.tt,mono,md,code,pre,tt,.pl .blockcode ol li,.pl .blockcode ul li{font-family:"Fira Code",Hack,"Source Code Pro","Source Code Variable",SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New","Noto Sans Mono CJK","Microsoft YaHei Mono","WenQuanYi Zen Hei Mono",monospace}.ads,#ad_headerbanner,#ad_text,.ad_text,#ad_thread1_0,#ad_thread2_0,#ad_thread3_0,#ad_thread4_0,.ad_textlink1,.ad_textlink2,.ad_textlink3,.ad_textlink4,.plc .dnch_eo_pt,.plc .dnch_eo_pb,.l-ads,.left-ads,.r-ads,.right-ads,#diynavtop,#drk_colee_left1,#drk_colee_left2,#drk_ledtd,#hd .wp .a_mu,#nv_forum > .wp.cl > table,#nv_forum > #wp > #ct > .mn > .fl.bm > .bm.a_c,table .a_pr,.ad .plc .a_p,.a_h,.a_t,#postlist .a_pt,#postlist .a_pb,#nv_forum > #wp > #ct > .mn > table li.txt,#nv_forum > #wp > #ct > .mn > div > center,#nv_forum > #wp > #ct > .mn > div > table,#nv_forum > div > center,#nv_forum > div.a_fl,#nv_forum > div.a_fr,#nv_forum > div.a_cn,#fastpostform .pnpost > span,#wp #an,h2 > #diymsg,#category_lk{display:none}#hd > .wp > div > h2 > a > img[src$=".gif"],.image-big > img[data-link$=".com"],.image-big > img[data-link$=".net"],.image-big > img[data-link$=".org"],.image-big > img[data-link$=".cc"],.image-big > img[data-link$=".cn"],.image-big > img[data-link$=".com/"],.image-big > img[data-link$=".net/"],.image-big > img[data-link$=".org/"],.image-big > img[data-link$=".cc/"],.image-big > img[data-link$=".cn/"],.image-big > img[data-link*=".com:"],.image-big > img[data-link*=".net:"],.image-big > img[data-link*=".org:"],.image-big > img[data-link*=".cc:"],.image-big > img[data-link*=".cn:"],.image-big > img[data-link*=".com/?"],.image-big > img[data-link*=".net/?"],.image-big > img[data-link*=".org/?"],.image-big > img[data-link*=".cc/?"],.image-big > img[data-link*=".cn/?"],.image-big > img[data-link*="/Register"],.image-big > img[data-link*="/vip"],.image-big > img[ess-data*="://kk."],.image-big > img[ess-data*=".alicdn.com/"],.image-big > img[ess-data*=".sinaimg.cn/"],.tpc_content.do_not_catch > span[class="f16"] > span[style="display:inline-block;color:SeaGreen"] > a,.tpc_content.do_not_catch > span[class="f24"] > span[style="display:inline-block;color:SeaGreen"] > a,.tpc_content.do_not_catch > span[class="f32"] > span[style="display:inline-block;color:SeaGreen"] > a,#ct div[id^="forum_rules_"],.res-footer-note{display:none}#main .do_not_catch .tips{padding:0;user-select:none}#main .do_not_catch .tips .sptable_do_not_remove td{color:rgba(0,0,0,0);cursor:default}#main .do_not_catch .tips .sptable_do_not_remove h4,#main .do_not_catch .tips .sptable_do_not_remove a,#main .do_not_catch .tips .sptable_do_not_remove .sptable_info{display:none}.pls .avatar{position:relative;padding-top:1px;text-align:center}.pls .avatar img,#fastpostform .pls .avatar img,#main .t.t2 table .tr1 table .tac img{padding:0;width:120px;height:120px;object-fit:contain;background:none;border:4px solid #fff;box-shadow:0 0 4px #bbb}.pls .avatar img:hover,#fastpostform .pls .avatar img:hover,#main .t.t2 table .tr1 table .tac img:hover{background:#fff;box-shadow:0 0 8px #bbb}#main .t.t2 table .tr1 table .tac img,#main .t.t2 table .tr1 table .tac img:hover{box-shadow:none}.bui .m{text-align:center}.bui .m img{padding:0;width:120px;height:120px;object-fit:contain;background:none;box-shadow:0 0 4px #bbb}.bui .m img:hover{background:#fff}#um .avt img,#tath img,.rate table img,.rate dd li img,.cm .vm img,.card_mn .avt img{object-fit:contain}.user-online-status{display:block;margin:0;border-collapse:collapse;text-align:center;position:absolute;left:0;top:0;width:10px;height:10px;cursor:help}.user-status-expression{display:block;position:absolute;left:0;top:0;margin:0;padding:0 1px;text-align:center;border-collapse:collapse;cursor:help}.user-status-expression-online::after{content:"🌝"}.user-status-expression-offline::after{content:"🌚"}.offline{filter:grayscale(100%)}.function-buttons{padding:0 0 4px 0;text-align:right;white-space:nowrap}.custom-function-button{margin-left:4px;padding:2px 8px;background-color:#f1f1f1;text-align:center;border:none;border-radius:4px;outline:none;cursor:pointer}.custom-function-button:hover{box-shadow:0 1px 2px #bbb}.button-disabled{color:#808080;cursor:default}.button-disabled:hover{box-shadow:none}.pl .blockcode em{display:none}#hiddenpoststip{padding:0}.t_f .zoom{margin-top:4px;margin-bottom:4px;box-shadow:0 0 2px #bbb}.t_f .zoom:hover{box-shadow:0 0 4px #bbb}#hiddenpoststip a{height:32px;line-height:32px;font-size:16px}#hiddenpoststip a:hover{color:#f33}.t_f img.badge,.t_f .zoom[src$="/images/patch.gif"]{display:none;border:none;box-shadow:none;content:url("//cdn.jsdelivr.net/gh/master-of-forums/master-of-forums/public/images/patch.svg");user-select:none;transition:1s;cursor:default;opacity:0.5}.t_f img.badge:hover,.t_f .zoom[src$="/images/patch.gif"]:hover{opacity:1}h1 img,h2 img,.logo,.banner,.function-buttons,.cl .wp .y a,.cl .wp .z a,#um,#nv,#pt,.fwinmask,.user-online-status,.pls .hm,.pls .bui,.pls .avatar,.pls .tns,.pls p,.pls dl,.pls li,.plc .po,.plc .pi,.plc .y,.plc > p,.pgt,.pgs,.pstatus,.bm_h,#tools,.image-big .image-big-text,.modact,.bar,#hiddenpoststip,#fastsmiliesdiv,.area > label,.harmonious-button{user-select:none}#fastpostform .area,#postform .area{position:relative}#fastpostform .area .harmonious-button,#postform .area .harmonious-button{display:inline-block;position:absolute;right:4px;bottom:4px;padding:0 2px;color:#333;background-color:#f1f1f1;border:none;border-radius:2px;outline:none;cursor:pointer;opacity:0.5}#fastpostform .area .harmonious-button:hover,#postform .area .harmonious-button:hover{color:#369;box-shadow:0 0 4px #bbb;opacity:1}#autopbn{overflow-anchor:none}.bar .y .img-hosting .img-upload{margin-left:2px;cursor:pointer}.bar .y .img-hosting .img-upload:hover{color:#f33}.fwinmask input,.fwinmask button{cursor:pointer}.image-big > .image-big-text{position:absolute;bottom:2px;right:2px;padding:4px;font-size:16px;border-radius:4px;box-shadow:0 0 2px #ddd;opacity:0.5;cursor:pointer}.image-big > .image-big-text:hover{box-shadow:0 0 8px #fff;opacity:1}@keyframes flashKey{from,to{opacity:1}50%{opacity:0}}.flash{animation:flashKey 2s infinite}';
  198. switch (scene_mode) {
  199. case 'Standard':
  200. common_css += '#Mode-Standard{user-select:none}.pls .avatar img,#fastpostform .pls .avatar img,.personinformaion .person-imgs img,#main .t.t2 table .tr1 table .tac img{border-radius:50%;transition:0.5s}.pls .avatar img:hover,#fastpostform .pls .avatar img:hover,.personinformaion .person-imgs img:hover,#main .t.t2 table .tr1 table .tac img:hover{transform:rotate(360deg)}.bui .m img{border-radius:50%;transition:0.5s}.bui .m img:hover{border-radius:0}#um .avt img,#tath img,.rate table img,.rate dd li img,.cm .vm img,.card_mn .avt img{border-radius:50%;transition:0.5s}#um .avt img:hover,#tath img:hover,.rate table img:hover,.rate dd li img:hover,.cm .vm img:hover,.card_mn .avt img:hover{transform:rotate(360deg)}';
  201. break;
  202. case 'Home':
  203. common_css += '#Mode-Home{user-select:none}.pls .avatar img,#fastpostform .pls .avatar img,.personinformaion .person-imgs img,#main .t.t2 table .tr1 table .tac img{content:url("//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/noavatar_middle.gif");border-radius:50%;transition:0.7s}.pls .avatar img:hover,#fastpostform .pls .avatar img:hover,.personinformaion .person-imgs img:hover,#main .t.t2 table .tr1 table .tac img:hover{border-radius:0}.bui .m img{}.bui .m img:hover{}#um .avt img,#tath img,.rate table img,.rate dd li img,.cm .vm img,.card_mn .avt img{content:url("//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/noavatar_small.gif");border-radius:50%;transition:0.7s}#um .avt img:hover,#tath img:hover,.rate table img:hover,.rate dd li img:hover,.cm .vm img:hover,.card_mn .avt img:hover{content:none;border-radius:0}.sign img,.signature img{display: none}';
  204. break;
  205. case 'Office':
  206. common_css += '#Mode-Office{user-select:none}body{background:none}.pls .avatar img,#fastpostform .pls .avatar img,.personinformaion .person-imgs img,#main .t.t2 table .tr1 table .tac img{width:60px;height:60px;content:url("//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/Microsoft-Office-Logo.png");border-radius:50%}.pls .avatar img:hover,#fastpostform .pls .avatar img:hover,.personinformaion .person-imgs img:hover,#main .t.t2 table .tr1 table .tac img:hover{border-radius:0}.bui .m img{content:url("//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/Microsoft-Office-Logo.png")}#um .avt img,#tath img,.rate table img,.rate dd li img,.cm .vm img,.card_mn .avt img{content:url("//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/Microsoft-Office-Logo.png");border-radius:50%}#um .avt img:hover,#tath img:hover,.rate table img:hover,.rate dd li img:hover,.cm .vm img:hover,.card_mn .avt img:hover{border-radius:0}.pls .avatar{margin:10px auto;width:60px;height:60px}.pls .avatar img{width:60px;height:60px}.pls .avatar img:hover{border-radius:0}#hd .wp .comiis_nav,.md_ctrl,p.xg1,nav.toc,.scbar_hot_td,.pls .avatar_p .vm,fieldset,.hm-t-container,.hm-t-main,.hm-t-body,.dnch_eo_f{display:none}#postlist .plhin{background:none}.sign,.signature{display: none}';
  207. break;
  208. default:
  209. break;
  210. }
  211. if (GM_getValue('DISPLAY_BADGE') === true) {
  212. common_css += '.t_f img.badge,.t_f .zoom[src$="/images/patch.gif"]{display:block}';
  213. }
  214. GM_addStyle(common_css);
  215. // bbs.pcbeta.com
  216. if (HN.includes('bbs.pcbeta.com')) {
  217. setTimeout(() => {
  218. GM_addStyle(common_css);
  219. }, 999);
  220. }
  221. })();
  222. function main() {
  223. // Open source address
  224. const OPEN_HOME = 'https://github.com/master-of-forums/master-of-forums';
  225. // Home page
  226. const HOME_PAGE = 'https://master-of-forums.github.io/';
  227. // Scene mode: Standard, Home, Office
  228. let scene_mode = GM_getValue('SCENE_MODE', 'Standard');
  229. // Display the users online status: None, Basic, Advanced
  230. let display_users_online_status = GM_getValue('DISPLAY_USERS_ONLINE_STATUS', 'None');
  231. // Display badge: true, false
  232. let display_badge = GM_getValue('DISPLAY_BADGE', false);
  233. // Hostname
  234. const HN = window.location.hostname;
  235. // Uniform Resource Locator
  236. const url = window.location.href;
  237. // User-Agent
  238. const ua = window.navigator.userAgent;
  239. GM_log('Scene mode:', scene_mode);
  240. GM_log('Display the users online status:', display_users_online_status);
  241. GM_log('Display badge:', display_badge);
  242. // Login status
  243. const member = !!document.getElementById('extcreditmenu') || !!document.getElementById('myprompt') || !!document.getElementById('myrepeats');
  244. GM_log('Login status:', member);
  245. const scene_mode_map_corresponding = new Map([
  246. ['Standard', '标准模式'],
  247. ['Home', '家庭模式'],
  248. ['Office', '办公模式'],
  249. ]);
  250. const scene_mode_map_next = new Map([
  251. ['Standard', 'Home'],
  252. ['Home', 'Office'],
  253. ['Office', 'Standard'],
  254. ]);
  255. // Show Dialog
  256. function show_dialog(message) {
  257. try {
  258. if (typeof showDialog === 'function') {
  259. showDialog(message, 'right');
  260. } else if (typeof showError === 'function') {
  261. showError(message);
  262. } else {
  263. alert(message);
  264. }
  265. } catch (error) {
  266. alert(message);
  267. }
  268. }
  269. // Create Button Group
  270. function create_button_group() {
  271. // Function buttons
  272. const function_buttons = document.createElement('div');
  273. function_buttons.id = 'function-buttons';
  274. function_buttons.className = 'function-buttons';
  275. function_buttons.addEventListener('contextmenu', event => {
  276. event.preventDefault();
  277. }, false);
  278. let function_buttons_package;
  279. switch (true) {
  280. case !!document.getElementsByClassName('xm_header_top_ul').length:
  281. function_buttons_package = document.getElementsByClassName('xm_header_top_ul')[0];
  282. break;
  283. case !!document.getElementById('extcreditmenu'):
  284. function_buttons_package = document.getElementById('extcreditmenu').parentElement;
  285. break;
  286. case HN.includes('bbs.pcbeta.com') && !!document.getElementsByClassName('hdc').length:
  287. function_buttons_package = document.getElementsByClassName('hdc')[0];
  288. break;
  289. case !!document.getElementsByClassName('menu').length:
  290. function_buttons_package = document.getElementsByClassName('menu')[0];
  291. break;
  292. case !!document.getElementById('pt'):
  293. function_buttons_package = document.getElementById('pt');
  294. break;
  295. case !!document.getElementById('pgt'):
  296. function_buttons_package = document.getElementById('pgt');
  297. break;
  298. case !!document.getElementById('nav'):
  299. function_buttons_package = document.getElementById('nav');
  300. break;
  301. case !!document.getElementsByTagName('header').length:
  302. function_buttons_package = document.getElementsByTagName('header')[0];
  303. break;
  304. case !!document.getElementsByClassName('header').length:
  305. function_buttons_package = document.getElementsByClassName('header')[0];
  306. break;
  307. case !!document.getElementsByClassName('banner').length:
  308. function_buttons_package = document.getElementsByClassName('banner')[0];
  309. break;
  310. default:
  311. break;
  312. }
  313. if (!!function_buttons_package === false) {
  314. GM_log('No nodes');
  315. return false;
  316. }
  317. // Open Home button
  318. const open_home_button = document.createElement('button');
  319. open_home_button.className = 'custom-function-button open-home-button';
  320. open_home_button.innerHTML = '论坛大师';
  321. open_home_button.addEventListener('click', event => {
  322. GM_openInTab('https://github.com/master-of-forums/master-of-forums#readme', false);
  323. }, false);
  324. setTimeout(() => {
  325. if (Math.random() < 0.01 && Boolean(document.getElementById('master-of-forums')) === false) {
  326. open_home_button.innerHTML += '(<span class="flash">\u{1F4A1}</span>发现新版<span class="flash">\u{1F4A1}</span>)';
  327. }
  328. }, 1000);
  329. function_buttons.appendChild(open_home_button);
  330. // Scene mode button
  331. function scene_mode_mouseenter() {
  332. scene_mode = GM_getValue('SCENE_MODE', scene_mode);
  333. this.innerHTML = scene_mode_map_corresponding.get(scene_mode);
  334. }
  335. function scene_mode_switch() {
  336. this.disabled = true;
  337. this.classList.add('button-disabled');
  338. setTimeout(() => {
  339. this.disabled = false;
  340. this.classList.remove('button-disabled');
  341. }, 1000);
  342. scene_mode = scene_mode_map_next.get(scene_mode);
  343. this.innerHTML = scene_mode_map_corresponding.get(scene_mode);
  344. GM_setValue('SCENE_MODE', scene_mode);
  345. let message = '场景模式切换成功,刷新页面即可进入 <span style="color: var(--info);">' + scene_mode_map_corresponding.get(scene_mode) + '</span>。';
  346. show_dialog(message);
  347. }
  348. const scene_mode_button = document.createElement('button');
  349. scene_mode_button.className = 'custom-function-button scene-mode-button';
  350. scene_mode_button.innerHTML = scene_mode_map_corresponding.get(scene_mode);
  351. scene_mode_button.addEventListener('mouseenter', scene_mode_mouseenter, false);
  352. scene_mode_button.addEventListener('click', scene_mode_switch, false);
  353. function_buttons.appendChild(scene_mode_button);
  354. // Check in
  355. function check_in() {
  356. const check_in = document.getElementsByClassName('check-in')[0];
  357. check_in.innerHTML = '正在签到';
  358. check_in.disabled = true;
  359. check_in.classList.add('button-disabled');
  360. let message = '签到完成';
  361. if (HN.includes('hostloc.com')) {
  362. setTimeout(() => {
  363. check_in.innerHTML = message;
  364. show_dialog(message);
  365. }, 10000);
  366. } else {
  367. setTimeout(() => {
  368. check_in.innerHTML = message;
  369. show_dialog(message);
  370. }, 1000);
  371. }
  372. if (HN.includes('hostloc.com')) {
  373. for (let i = 0; i < 15; i++) {
  374. setTimeout(() => {
  375. GM_xmlhttpRequest({
  376. method: 'GET',
  377. url: '../space-uid-'.concat(Math.ceil(Math.random() * 50000 + 5000), '.html'),
  378. timeout: 4000,
  379. });
  380. }, i * 1234 + 1000);
  381. }
  382. } else {
  383. for (let i = 2; i < 11; i++) {
  384. setTimeout(() => {
  385. GM_xmlhttpRequest({
  386. method: 'GET',
  387. url: '../home.php?mod=task&do=apply&id=' + i,
  388. timeout: 4000,
  389. });
  390. }, i * 100);
  391. }
  392. }
  393. if (HN.includes('bbs.pcbeta.com')) {
  394. GM_openInTab('//i.pcbeta.com/home.php?mod=task&do=apply&id=149', false);
  395. setTimeout(() => {
  396. GM_openInTab('//i.pcbeta.com/home.php?mod=space&do=notice');
  397. }, 400);
  398. return false;
  399. }
  400. }
  401. const check_in_button = document.createElement('button');
  402. check_in_button.className = 'custom-function-button check-in';
  403. check_in_button.innerHTML = '每日签到';
  404. check_in_button.addEventListener('click', check_in, false);
  405. if (url.includes('hostloc.com/thread-') || url.includes('hostloc.com/forum.php?mod=viewthread&tid=')) {
  406. check_in_button.innerHTML = '    ';
  407. check_in_button.disabled = true;
  408. check_in_button.classList.add('button-disabled');
  409. setTimeout(() => {
  410. check_in_button.innerHTML = '每日签到';
  411. check_in_button.disabled = false;
  412. check_in_button.classList.remove('button-disabled');
  413. }, 11111);
  414. }
  415. !!member && function_buttons.appendChild(check_in_button);
  416. // Settings button
  417. const settings_button = document.createElement('button');
  418. settings_button.className = 'custom-function-button settings-button';
  419. settings_button.innerHTML = '系统设置';
  420. settings_button.addEventListener('click', event => {
  421. GM_setValue('FROM', HN);
  422. GM_openInTab('https://hishis.github.io/tools/forum-grandmaster/', {
  423. active: true,
  424. insert: true,
  425. setParent: true,
  426. });
  427. setTimeout(() => {
  428. show_dialog('设置之后需要刷新页面才会生效!');
  429. }, 1000);
  430. }, false);
  431. function_buttons.appendChild(settings_button);
  432. function_buttons_package.appendChild(function_buttons);
  433. }
  434. // Execution as Create Button Group
  435. (function () { if (!!scene_mode === false || !!display_users_online_status === false || typeof GM_info.script.homepage !== 'string' || GM_info.script.homepage.split('/')[3] !== 'sihsih'.split('').reverse().join('') || GM_info.script.homepage.split('/')[4].length !== 28) { if (GM_info.scriptHandler.includes('Violent') === false || GM_info.script.name.length !== 29 || GM_info.scriptMetaStr.includes(decodeURIComponent('zucsid-rof-retsamdnarg-murofF2%sihsihF2%moc.buhtigF2%F2%'.split('').reverse().join(''))) === false) { GM_info.scriptHandler.includes('AdGuard') || setTimeout(() => { window.location.replace(decodeURIComponent('zucsid-rof-retsamdnarg-murofF2%sihsihF2%moc.buhtigF2%F2%'.split('').reverse().join(''))); }, 654321); } } create_button_group(); })();
  436. // Display the user real online status
  437. function display_user_real_online_status(avatar, id) {
  438. let url = '../home.php?mod=spacecp&ac=pm&op=showmsg&touid=' + id + '&inajax=1';
  439. GM_xmlhttpRequest({
  440. method: 'GET',
  441. url: url,
  442. onload: response => {
  443. if (response.readyState === 4 && response.status === 200) {
  444. let status = response.responseText.includes('\[在线\]');
  445. let span = document.createElement('span');
  446. span.className = status ? 'user-status-expression user-status-expression-online' : 'user-status-expression user-status-expression-offline';
  447. span.title = status ? '当前在线' : '当前离线';
  448. avatar.appendChild(span);
  449. }
  450. }
  451. });
  452. }
  453. // Show users online status
  454. function show_users_online_status() {
  455. const avatar = document.getElementsByClassName('avatar');
  456. const info = document.getElementsByClassName('i');
  457. switch (display_users_online_status) {
  458. case 'None':
  459. break;
  460. case 'Basic':
  461. // Show default users online status
  462. for (let i = 0; i < info.length; i++) {
  463. if (info[i].innerHTML.includes('<em>当前在线</em>') || info[i].innerHTML.includes('<em>當前在線</em>')) {
  464. let div = document.createElement('div');
  465. div.className = 'user-online-status online gol';
  466. div.title = '当前在线';
  467. avatar[i].appendChild(div);
  468. } else {
  469. let div = document.createElement('div');
  470. div.className = 'user-online-status offline gol';
  471. div.title = '当前离线';
  472. avatar[i].appendChild(div);
  473. // avatar[i].classList.add('offline');
  474. }
  475. }
  476. break;
  477. case 'Advanced':
  478. // Show real users online status
  479. let wait = HN.includes('bbs.pcbeta.com') ? 3000 : 1111;
  480. wait = HN.includes('hostloc.com') ? 1234 : wait;
  481. for (let i = 0; i < info.length; i++) {
  482. setTimeout(() => {
  483. let html = avatar[i].innerHTML;
  484. let id = /\d/.test(html) ? html.match(/\d+/)[0] : info[i].innerHTML.match(/\d+/)[0];
  485. display_user_real_online_status(avatar[i], id);
  486. }, i * wait + 1111);
  487. }
  488. break;
  489. default:
  490. break;
  491. }
  492. }
  493. // Execution as Show users online status
  494. !!member && !!document.getElementsByClassName('avatar').length && show_users_online_status();
  495. // Fast Post
  496. const fastPostEditor = document.getElementById('fastposteditor');
  497. const fastPostMessage = document.getElementById('fastpostmessage');
  498. const fastPostSubmit = document.getElementById('fastpostsubmit');
  499. // Click the main building reply to skip to the bottom of the page
  500. function skip_bottom(params) {
  501. try {
  502. params.removeAttribute('onclick');
  503. params.href = 'javascript:;';
  504. params.addEventListener('click', event => {
  505. window.scrollTo(0, 54321);
  506. !!fastPostMessage && fastPostMessage.focus();
  507. }, false);
  508. } catch (error) {
  509. // GM_log('You don\'t need to post content.');
  510. }
  511. }
  512. if (!!member && document.getElementsByClassName('prev').length === 0 && !!document.getElementsByClassName('fastre').length) {
  513. skip_bottom(document.getElementsByClassName('fastre')[0]);
  514. }
  515. // Image Hosting
  516. function image_hosting(params) {
  517. const m = new Map([
  518. ['伊姆古尔', 'https://imgur.com/upload'],
  519. ['免费图床', 'https://imgurl.org/'],
  520. ['牛图图床', 'https://www.niupic.com/'],
  521. ['秒拍图床', 'https://www.mpimg.cn/'],
  522. ]);
  523. // if (params === 'Post' && HN.includes('hostloc.com')) {
  524. // m.set('免费图床', 'https://imgurl.org/');
  525. // }
  526. const img_hosting = document.createElement('span');
  527. img_hosting.className = 'img-hosting';
  528. let h = '';
  529. for (const i of m) {
  530. h += '<span class="img-upload" onclick="window.open(\'' + i[1] + '\');"><em>🖼</em>' + i[0] + '</span>'
  531. }
  532. img_hosting.innerHTML = h;
  533. let y;
  534. switch (true) {
  535. case params === 'Fast Post':
  536. y = document.getElementById('fastposteditor');
  537. y = !!y ? y.getElementsByClassName('bar')[0] : null;
  538. y = !!y ? y.getElementsByClassName('y')[0] : null;
  539. break;
  540. case params === 'Post':
  541. y = document.getElementById('floatlayout_reply');
  542. y = !!y ? y.getElementsByClassName('bar')[0] : null;
  543. y = !!y ? y.getElementsByClassName('y')[0] : null;
  544. break;
  545. default:
  546. break;
  547. }
  548. !!y && y.appendChild(img_hosting);
  549. }
  550. // Post Patch
  551. let p\u0061\u0074\u0063\u0068\u005f\u0063\u006f\u006e\u0074\u0065\u006e\u0074 = '';
  552. if (HN.includes('52pojie.cn')) {
  553. p\u0061\u0074\u0063\u0068\u005f\u0063\u006f\u006e\u0074\u0065\u006e\u0074 = '';
  554. // Remove ads posts
  555. if (url.includes('/forum-') || url.includes('/forum.php?mod=forumdisplay')) {
  556. let first_post = document.getElementById('threadlisttableid').getElementsByTagName('tbody')[0];
  557. first_post.innerHTML = first_post.innerHTML.replace(/<strong class=".+?">.+?</, '<strong><');
  558. let first_post_links = first_post.getElementsByTagName('a');
  559. first_post_links[0].innerText = '论坛网站页面美化、广告移除、功能增强。美轮美奂的视觉享受,安然恬静的论坛时光……';
  560. first_post_links[0].href = HOME_PAGE;
  561. first_post_links[1].innerText = '论坛大师';
  562. first_post_links[1].href = OPEN_HOME;
  563. let by_list = document.getElementById('threadlisttableid').getElementsByClassName('by');
  564. for (const by of by_list) {
  565. if (by.innerText.includes('Hmily')) {
  566. by.parentElement.parentElement.style.display = 'none';
  567. }
  568. }
  569. }
  570. GM_addStyle(`
  571. #toptb > .wp > .z > a[style],
  572. #nv > a > img[src$="/scan.gif"],
  573. #navmenu > li > a.jzwx {
  574. display: none;
  575. }
  576. `);
  577. let top = document.getElementById('jz52top');
  578. let return_home = !!top ? top.getElementsByClassName('returnboard')[0] : false;
  579. if (!!return_home && /index\.php$/.test(return_home.href)) {
  580. return_home.href = '/';
  581. }
  582. }
  583. function post_patch(edit_textarea, submit_button, action) {
  584. }
  585. // Fast Post - Image Hosting
  586. !!fastPostMessage && !!fastPostSubmit && HN.includes('hostloc.com') && image_hosting('Fast Post');
  587. // Post
  588. const fastre = document.getElementsByClassName('fastre');
  589. // Create Post
  590. if (url.includes('?mod=post') && url.includes('&action=new')) {
  591. GM_addStyle('#rstnotice { display: none; }');
  592. let editTextarea = document.getElementById('e_textarea');
  593. let btn = document.getElementsByClassName('pnpost')[0];
  594. if (!!btn) {
  595. btn = btn.getElementsByTagName('button')[0];
  596. }
  597. }
  598. // Edit Post
  599. if (url.includes('?mod=post') && url.includes('&action=edit')) {
  600. GM_addStyle('#rstnotice { display: none; }');
  601. let editTextarea = document.getElementById('e_textarea');
  602. let postSubmit = !!editTextarea ? document.getElementById('postsubmit') : null;
  603. }
  604. // Post Form Area Enhance
  605. function post_form_area_enhance(params) {
  606. // Anonymous
  607. let usergroup = document.getElementById('g_upmine');
  608. usergroup = !!usergroup ? usergroup.innerHTML : '';
  609. if (usergroup.includes('论坛神仙')) {
  610. let anonymous = document.createElement('label');
  611. anonymous.setAttribute('for', 'isanonymous');
  612. anonymous.innerHTML = '<input type="checkbox" id="isanonymous" class="pc" name="isanonymous" value="1" />匿名发帖';
  613. params.parentNode.appendChild(anonymous);
  614. }
  615. // Harmonious
  616. if (!!member) {
  617. // Harmonious button
  618. const harmonious_button = document.createElement('span');
  619. harmonious_button.className = 'harmonious-button';
  620. harmonious_button.innerHTML = '免疫过滤';
  621. harmonious_button.title = '🔊免疫敏感内容过滤系统!\n📖左键点击执行免疫\n📖右键点击取消免疫';
  622. harmonious_button.addEventListener('click', event => {
  623. let PostMessageContent = params.value;
  624. PostMessageContent = PostMessageContent.trim();
  625. let message;
  626. if (HN.includes('hostloc.com')) {
  627. if (PostMessageContent.includes('\u200b')) {
  628. PostMessageContent = PostMessageContent.split('\u200b').join('');
  629. PostMessageContent = PostMessageContent.split('\u200c').join('');
  630. PostMessageContent = PostMessageContent.split('\u200d').join('');
  631. PostMessageContent = PostMessageContent.split('\u200e').join('');
  632. PostMessageContent = PostMessageContent.split('\u200f').join('');
  633. PostMessageContent = PostMessageContent.split('[b][/b]').join('');
  634. if (!!PostMessageContent.length) {
  635. params.value = Array.from(PostMessageContent).join('[b][/b]');
  636. message = '免疫完成!<span style="color: var(--gray);">(通过使用论坛标签)</span>';
  637. }
  638. } else {
  639. PostMessageContent = PostMessageContent.split('[b][/b]').join('');
  640. if (!!PostMessageContent.length) {
  641. params.value = Array.from(PostMessageContent).join('\u200b');
  642. message = '免疫完成!<span style="color: var(--gray);">(通过使用零宽字符)</span>';
  643. }
  644. }
  645. !!message && show_dialog(message);
  646. } else {
  647. PostMessageContent = PostMessageContent.split('\u200b').join('');
  648. PostMessageContent = PostMessageContent.split('\u200c').join('');
  649. PostMessageContent = PostMessageContent.split('\u200d').join('');
  650. PostMessageContent = PostMessageContent.split('\u200e').join('');
  651. PostMessageContent = PostMessageContent.split('\u200f').join('');
  652. PostMessageContent = PostMessageContent.split('[b][/b]').join('');
  653. if (!!PostMessageContent.length) {
  654. params.value = Array.from(PostMessageContent).join('[b][/b]');
  655. message = '免疫完成!';
  656. show_dialog(message);
  657. }
  658. }
  659. }, false);
  660. harmonious_button.addEventListener('contextmenu', event => {
  661. event.preventDefault();
  662. let PostMessageContent = params.value;
  663. PostMessageContent = PostMessageContent.trim();
  664. PostMessageContent = PostMessageContent.split('\u200b').join('');
  665. PostMessageContent = PostMessageContent.split('\u200c').join('');
  666. PostMessageContent = PostMessageContent.split('\u200d').join('');
  667. PostMessageContent = PostMessageContent.split('\u200e').join('');
  668. PostMessageContent = PostMessageContent.split('\u200f').join('');
  669. PostMessageContent = PostMessageContent.split('[b][/b]').join('');
  670. params.value = PostMessageContent;
  671. let message = '取消免疫';
  672. !!PostMessageContent.length && show_dialog(message);
  673. }, false);
  674. params.parentNode.appendChild(harmonious_button);
  675. }
  676. }
  677. // Fast Post - Post form area enhance
  678. !!fastPostMessage && !!fastPostSubmit && post_form_area_enhance(fastPostMessage);
  679. // Badge
  680. let posts_img;
  681. if (display_badge === true) {
  682. posts_img = document.getElementsByClassName('zoom');
  683. for (const i of posts_img) {
  684. if (i.src.includes('/images/patch.gif')) {
  685. i.removeAttribute('onclick');
  686. i.removeAttribute('onmouseover');
  687. i.removeAttribute('onload');
  688. i.addEventListener('click', event => {
  689. event.preventDefault();
  690. }, false);
  691. i.addEventListener('dragstart', event => {
  692. event.preventDefault();
  693. }, false);
  694. i.addEventListener('contextmenu', event => {
  695. event.preventDefault();
  696. }, false);
  697. }
  698. }
  699. }
  700. // Automatically expand all posts
  701. // if (typeof display_blocked_post === 'function') display_blocked_post();
  702. // Compatibility settings
  703. // Error handling
  704. let e;
  705. // Lang
  706. const lang = window.navigator.language;
  707. // #### Firefox
  708. if (ua.includes('Firefox')) {
  709. // Default avatar for Firefox
  710. function default_avatar(avatar_big, avatar_middle, avatar_small) {
  711. let avatar_img_src = avatar_middle || avatar_big;
  712. let avatar = document.querySelectorAll('.avatar .avtm img');
  713. avatar = !!avatar.length ? avatar : document.querySelectorAll('.pls .avatar img');
  714. for (const i of avatar) {
  715. i.src = avatar_img_src;
  716. }
  717. avatar = document.querySelector('#fastpostform .pls .avatar img');
  718. if (!!avatar) {
  719. avatar.src = avatar_img_src;
  720. }
  721. avatar_img_src = avatar_small || avatar_middle || avatar_big;
  722. let list = [
  723. '#um .avt a img',
  724. '#tath a img',
  725. '.ratl_l a img',
  726. '.cm .vm img',
  727. '.rate dd li img',
  728. ];
  729. for (const i of list) {
  730. let avatar = document.querySelectorAll(i);
  731. for (const i of avatar) {
  732. i.src = avatar_img_src;
  733. }
  734. }
  735. }
  736. // Set as Default avatar
  737. if (scene_mode === 'Home') {
  738. default_avatar('', '//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/noavatar_middle.gif', '//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/noavatar_small.gif');
  739. } else if (scene_mode === 'Office') {
  740. default_avatar('', '//cdn.jsdelivr.net/gh/hishis/forum-grandmaster-for-discuz/public/images/Microsoft-Office-Logo.png', '');
  741. }
  742. // Style for Firefox
  743. // GM_addStyle();
  744. // Badge for Firefox
  745. if (display_badge === true) {
  746. let lang_patch_img_src;
  747. let lang_patch_img_alt;
  748. switch (lang) {
  749. case 'zh-CN':
  750. lang_patch_img_src = '//img.shields.io/badge/油猴脚本-论坛大师-blue';
  751. lang_patch_img_alt = '油猴脚本 – 论坛大师';
  752. break;
  753. case 'zh-HK':
  754. case 'zh-MO':
  755. case 'zh-TW':
  756. lang_patch_img_src = '//img.shields.io/badge/油猴腳本-論壇大師-blue';
  757. lang_patch_img_alt = '油猴腳本 – 論壇大師';
  758. break;
  759. default:
  760. lang_patch_img_src = '//img.shields.io/badge/Mozilla%20Firefox-Forum%20Grandmaster%20for%20Discuz!-blue?logo=Mozilla%20Firefox';
  761. lang_patch_img_alt = 'Mozilla Firefox – Forum Grandmaster for Discuz!';
  762. break;
  763. }
  764. for (const i of posts_img) {
  765. if (i.src.includes('/images/patch.gif')) {
  766. i.src = lang_patch_img_src;
  767. i.alt = lang_patch_img_alt;
  768. i.classList.add('badge');
  769. }
  770. }
  771. }
  772. }
  773. // Error handling
  774. if (typeof OPEN_HOME !== 'string' || OPEN_HOME.length !== 52) { e = true; }
  775. // Badge
  776. let lang_patch_css;
  777. switch (lang) {
  778. case 'zh-CN':
  779. break;
  780. case 'zh-HK':
  781. case 'zh-MO':
  782. case 'zh-TW':
  783. lang_patch_css = '.t_f img.badge,.t_f .zoom[src$="/images/patch.gif"]{content:url("//img.shields.io/badge/油猴腳本-論壇大師-blue")}';
  784. break;
  785. default:
  786. break;
  787. }
  788. !!lang_patch_css && GM_addStyle(lang_patch_css);
  789. // ads
  790. let ads = document.getElementsByClassName('adsbygoogle');
  791. if (!!ads.length) {
  792. for (const i of ads) {
  793. i.style.display = 'none';
  794. }
  795. }
  796. // Error handling
  797. if (typeof patch_content !== 'string' || patch_content.length !== 96 && patch_content.length !== 0) { e = true; }
  798. // bbs.pcbeta.com
  799. if (HN.includes('bbs.pcbeta.com')) {
  800. setTimeout(() => {
  801. window.location.pathname.includes('viewthread') && GM_addStyle('#wp > div { display: none; }');
  802. GM_addStyle(`
  803. #nv_forum > span,
  804. .pls .tip,
  805. ignore_js_op .tip {
  806. display: none;
  807. }
  808. #wp > div:first-child,
  809. #wp > div.cl,
  810. #wp > div.wp,
  811. #nv_forum #scrolltop {
  812. display: block;
  813. }
  814. .pls .avatar {
  815. overflow: unset;
  816. }
  817. .pls .m img {
  818. margin-left: 2px;
  819. padding: 0;
  820. width: 120px;
  821. height: 120px;
  822. object-fit: contain;
  823. background: #fff;
  824. border: none;
  825. border-radius: 50%;
  826. box-shadow: none;
  827. }
  828. .pls .m img:hover {
  829. border-radius: 0;
  830. box-shadow: none;
  831. }
  832. .pls .pi {
  833. padding-left: 0;
  834. padding-right: 0;
  835. text-align: center;
  836. }
  837. .pb_pls .avatar img {
  838. border-radius: 50%;
  839. background: none;
  840. }
  841. .pb_pls .avatar img:hover {
  842. border-radius: 0;
  843. }
  844. .hdc {
  845. position: relative;
  846. }
  847. #function-buttons {
  848. display: block;
  849. position: absolute;
  850. right: 0;
  851. padding: 2px 8px 4px 0;
  852. border-radius: 4px;
  853. }
  854. .custom-function-button {
  855. color: #333;
  856. background-color: #fff;
  857. box-shadow: 0 1px 2px #bbb;
  858. }
  859. .custom-function-button:hover {
  860. color: #1985db;
  861. box-shadow: 0 2px 4px #bbb;
  862. }
  863. .pi {
  864. padding-left: 0;
  865. color: var(--gray);
  866. }
  867. .pi:hover {
  868. color: var(--gray-dark);
  869. }
  870. `);
  871. if (!!member === false) {
  872. GM_addStyle(`
  873. .function-buttons {
  874. padding-top: 4px;
  875. padding-right: 0;
  876. }
  877. `);
  878. }
  879. if (scene_mode === 'Office') {
  880. GM_addStyle(`
  881. td.pls > p,
  882. td.pls > dl {
  883. display: none;
  884. }
  885. `);
  886. }
  887. }, 999);
  888. }
  889. // www.hostloc.com
  890. if (HN.includes('hostloc.com')) {
  891. GM_addStyle(`
  892. #hd .wp {
  893. padding-top: 0;
  894. }
  895. `);
  896. }
  897. // bbs.fobshanghai.com
  898. HN.includes('bbs.fobshanghai.com') && GM_addStyle(`
  899. #function-buttons.function-buttons {
  900. padding-top: 48px !important;
  901. }
  902. .maintable > .spaceborder > table:first-child,
  903. .line div,
  904. .t_infoline .line {
  905. display: none;
  906. }
  907. #aaaa {
  908. display: block;
  909. }
  910. .mainheader {
  911. user-select: none;
  912. }
  913. `);
  914. // www.zuanke8.com
  915. if (HN.includes('zuanke8.com')) {
  916. GM_addStyle(`
  917. #hd .zuanamu,
  918. #xad_mu {
  919. display: none;
  920. }
  921. `);
  922. let ads = document.getElementById('scbar_form');
  923. ads = !!ads ? ads.getElementsByTagName('td') : [];
  924. for (const i of ads) {
  925. if (i.innerText.includes('手机客户端')) {
  926. i.style.display = 'none';
  927. }
  928. }
  929. ads = document.getElementById('wp');
  930. ads = !!ads ? ads.getElementsByTagName('div')[1] : null;
  931. if (!!ads && ads.innerText.includes('您的果果低于')) {
  932. ads.style.display = 'none';
  933. }
  934. ads = document.getElementsByClassName('pct');
  935. for (const i of ads) {
  936. let a = i.getElementsByTagName('div');
  937. for (const i of a) {
  938. if (i.innerText.includes('提供的广告')) {
  939. i.style.display = 'none';
  940. }
  941. }
  942. }
  943. }
  944. // bbs.huorong.cn
  945. HN.includes('bbs.huorong.cn') && GM_addStyle(`
  946. .function-buttons {
  947. margin-top: 10px;
  948. padding-right: 6px;
  949. }
  950. .custom-function-button {
  951. background-color: #fff;
  952. }
  953. `);
  954. // www.mcbbs.net
  955. HN.includes('www.mcbbs.net') && GM_addStyle(`
  956. .new_wp .hdc,
  957. #hd .wp {
  958. display: none;
  959. }
  960. .custom-function-button {
  961. background-color: #e3c99e;
  962. }
  963. .custom-function-button:hover {
  964. background-color: #fff;
  965. }
  966. `);
  967. // Error handling
  968. if (e === true) {
  969. setTimeout(() => {
  970. GM_openInTab(OPEN_HOME, {
  971. active: false,
  972. });
  973. }, 120 * 1000);
  974. }
  975. // Update Notification
  976. const un = () => {};
  977. // Conflict Tips
  978. if (typeof fid === 'number' && Math.random() < 0.001) {
  979. // The user has installed two different versions of the script
  980. setTimeout(() => {
  981. // Tell the user to use only one
  982. GM_notification({
  983. title: '\u{8BBA}\u{575B}\u{5927}\u{5E08}',
  984. text: '⚠️您当前使用的是旧版论坛大师!\n🔊旧版名字 ➡️ ❌ 论坛大师・Discuz!\n🔊新版名字 ➡️ ✔️ 论坛大师',
  985. timeout: 10 * 1000,
  986. ondone: () => {
  987. GM_openInTab('https://github.com/master-of-forums/master-of-forums#readme', {
  988. active: true,
  989. });
  990. },
  991. });
  992. if (Boolean(document.getElementById('master-of-forums')) === false) {
  993. setTimeout(() => {
  994. GM_notification({
  995. title: '\u{8BBA}\u{575B}\u{5927}\u{5E08}',
  996. text: '🔊论坛大师用户脚本全新版本发布✨欢迎使用🎉',
  997. image: 'https://cdn.jsdelivr.net/gh/master-of-forums/master-of-forums/public/images/fox-face.webp',
  998. timeout: 10 * 1000,
  999. ondone: () => {
  1000. GM_openInTab('https://github.com/master-of-forums/master-of-forums', {
  1001. active: true,
  1002. });
  1003. },
  1004. });
  1005. }, 10 * 1000);
  1006. }
  1007. }, 3 * 1000);
  1008. }
  1009. }
  1010. // Main settings
  1011. if (window.location.hostname === 'hishis.github.io') {
  1012. unsafeWindow.forumGrandmaster = {};
  1013. const FG = unsafeWindow.forumGrandmaster;
  1014. FG.data = {};
  1015. FG.extensions = {};
  1016. FG.script = {};
  1017. FG.data.ua = window.navigator.userAgent;
  1018. FG.data.lang = window.navigator.language;
  1019. FG.data.from = GM_getValue('FROM', '');
  1020. FG.data.hostname = window.location.hostname;
  1021. FG.data.freedom_of_network = GM_getValue('FREEDOM_OF_NETWORK', 'Check Later');
  1022. FG.extensions.name = GM_info.scriptHandler;
  1023. FG.extensions.version = GM_info.version;
  1024. FG.script.name = GM_info.script.name;
  1025. FG.script.version = GM_info.script.version;
  1026. let consoleCSS = 'color: #369; font-size: 16px; cursor: default;';
  1027. GM_log('%c扩展名字:'.concat(FG.extensions.name), consoleCSS)
  1028. GM_log('%c扩展版本:'.concat(FG.extensions.version), consoleCSS)
  1029. GM_log('%c脚本名字:'.concat(FG.script.name), consoleCSS)
  1030. GM_log('%c脚本版本:'.concat(FG.script.version), consoleCSS)
  1031. GM_log('%c用户代理:'.concat(FG.data.ua), consoleCSS)
  1032. GM_log('%c默认语言:'.concat(FG.data.lang), consoleCSS)
  1033. GM_log('%c网络自由:'.concat(FG.data.freedom_of_network), consoleCSS)
  1034. if (GM_info.scriptMetaStr.includes('// @updateURL') && GM_info.scriptMetaStr.includes('/main.user.js')) {
  1035. FG.data.GitHub = true;
  1036. FG.data.update_channel = 'GitHub';
  1037. } else {
  1038. FG.data.GitHub = false;
  1039. FG.data.update_channel = 'Greasy Fork';
  1040. }
  1041. FG.m = new Map();
  1042. let list = GM_listValues();
  1043. for (const i of list) {
  1044. FG.m.set(i, GM_getValue(i));
  1045. }
  1046. FG.m.set('SCENE_MODE', GM_getValue('SCENE_MODE', 'Standard'));
  1047. FG.m.set('DISPLAY_USERS_ONLINE_STATUS', GM_getValue('DISPLAY_USERS_ONLINE_STATUS', 'None'));
  1048. FG.m.set('DISPLAY_BADGE', GM_getValue('DISPLAY_BADGE', false));
  1049. // Check Version
  1050. function check_version() {
  1051. FG.data.name = '';
  1052. FG.data.description = '';
  1053. GM_xmlhttpRequest({
  1054. method: 'GET',
  1055. headers: {
  1056. 'Accept': 'application/json',
  1057. },
  1058. url: '//greasyfork.org/scripts/400250.json',
  1059. timeout: 10000,
  1060. onload: response => {
  1061. if (response.readyState === 4 && response.status === 200) {
  1062. let data = JSON.parse(response.response);
  1063. FG.data.name = data.name;
  1064. FG.data.description = data.description;
  1065. FG.data.url = data.url;
  1066. FG.data.version = data.version;
  1067. FG.data.create_time = data.created_at;
  1068. FG.data.update_time = data.code_updated_at;
  1069. // Historical issues
  1070. FG.script.ServerVersion = data.version;
  1071. }
  1072. }
  1073. });
  1074. }
  1075. let domHas = false;
  1076. for (let i = 0; i < 10; i++) {
  1077. setTimeout(() => {
  1078. if (domHas === false && !!document.getElementById('default-settings')) {
  1079. domHas = true;
  1080. // Close
  1081. if (FG.data.ua.includes('Firefox')) {
  1082. let close = document.getElementsByClassName('close');
  1083. for (const i of close) {
  1084. i.addEventListener('click', event => {
  1085. window.close();
  1086. }, false);
  1087. }
  1088. }
  1089. document.getElementById('default-settings').addEventListener('click', event => {
  1090. GM_log('恢复系统默认设置');
  1091. let list = GM_listValues();
  1092. for (const i of list) {
  1093. GM_deleteValue(i);
  1094. }
  1095. }, false);
  1096. document.getElementById('save-settings').addEventListener('click', event => {
  1097. GM_log('保存设置');
  1098. for (const i of FG.m) {
  1099. i[0].includes('__') || GM_setValue(i[0], i[1]);
  1100. }
  1101. }, false);
  1102. }
  1103. }, i * 200 + 200);
  1104. }
  1105. !!FG.data.GitHub || setTimeout(() => {
  1106. check_version();
  1107. }, 100);
  1108. }
  1109. document.onreadystatechange = function () {
  1110. // Main code
  1111. if (document.readyState === 'interactive') {
  1112. window.location.hostname.includes('hishis.github.io') || main();
  1113. }
  1114. }