論壇大師・Discuz!修改版

論壇大師(繁體中文)・Discuz! 界面美化、移除廣告、功能增強……

  1. // ==UserScript==
  2. // @name Forum Master・Discuz! Revision
  3. // @name:en Forum Master・Discuz! Revision
  4. // @name:zh-CN 论坛大师・Discuz!修改版
  5. // @name:zh-TW 論壇大師・Discuz!修改版
  6. // @namespace Forum Master・Discuz!-mxdh
  7. // @version 0.9.2
  8. // @icon https://www.discuz.net/favicon.ico
  9. // @description Forum Master - Discuz! Beautify the interface, Remove ads, Enhance functions.
  10. // @description:en Forum Master - Discuz! Beautify the interface, Remove ads, Enhance functions.
  11. // @description:zh-CN 论坛大师(简体中文)・Discuz! 界面美化、移除广告、功能增强……
  12. // @description:zh-TW 論壇大師(繁體中文)・Discuz! 界面美化、移除廣告、功能增強……
  13. // @author hostname,mxdh
  14. // @match https://www.52pojie.cn/thread-*.html
  15. // @match https://www.52pojie.cn/forum.php?mod=viewthread&tid=*
  16. // @match https://www.right.com.cn/forum/thread-*.html
  17. // @match https://www.right.com.cn/forum/forum.php?mod=viewthread&tid=*
  18. // @match https://bbs.kafan.cn/thread-*.html
  19. // @match https://bbs.kafan.cn/forum.php?mod=viewthread&tid=*
  20. // @match https://hostloc.com/thread-*.html
  21. // @match https://hostloc.com/forum.php?mod=viewthread&tid=*
  22. // @match https://www.hostloc.com/thread-*.html
  23. // @match https://www.hostloc.com/forum.php?mod=viewthread&tid=*
  24. // @match http://bbs.pcbeta.com/thread-*.html
  25. // @match http://bbs.pcbeta.com/forum.php?mod=viewthread&tid=*
  26. // @match http://bbs.pcbeta.com/viewthread-*.html
  27. // @match https://bbs.pcbeta.com/thread-*.html
  28. // @match https://bbs.pcbeta.com/forum.php?mod=viewthread&tid=*
  29. // @match https://bbs.pcbeta.com/viewthread-*.html
  30. // @match https://bbs.pcbeta.com/forum.php?mod=viewthread&tid=*
  31. // @match http://bbs.huorong.cn/thread-*.html
  32. // @match http://bbs.huorong.cn/forum.php?mod=viewthread&tid=*
  33. // @match https://bbs.huorong.cn/thread-*.html
  34. // @match https://bbs.huorong.cn/forum.php?mod=viewthread&tid=*
  35. // @match https://iya.app/thread-*.html
  36. // @match https://iya.app/forum.php?mod=viewthread&tid=*
  37. // @match https://www.dospy.wang/thread-*.html
  38. // @match https://www.dospy.wang/forum.php?mod=viewthread&tid=*
  39. // @match http://www.aihao.cc/thread-*.html
  40. // @match http://www.aihao.cc/forum.php?mod=viewthread&tid=*
  41. // @match https://www.aihao.cc/thread-*.html
  42. // @match https://www.aihao.cc/forum.php?mod=viewthread&tid=*
  43. // @grant GM_addStyle
  44. // @grant GM_getValue
  45. // @grant GM_log
  46. // @grant GM_setValue
  47. // @grant GM_xmlhttpRequest
  48. // @supportURL https://github.com/mxdh/Forum-Master-Discuz-
  49. // @license GPL-3.0
  50. // ==/UserScript==
  51.  
  52. (function () {
  53. 'use strict';
  54.  
  55. //This is the original author's statement:
  56. /**
  57. * Forum Master・Discuz! - https://gf.qytechs.cn/scripts/400250
  58. *
  59. * == BEGIN LICENSE ==
  60. *
  61. * Open name: Forum Master・Discuz!
  62. * Open home: https://gf.qytechs.cn/scripts/400250
  63. *
  64. * Licensed under the terms of any of the following licenses at your
  65. * choice:
  66. *
  67. * 1. GPL - GNU General Public License
  68. * https://www.gnu.org/licenses/gpl-3.0.html
  69. *
  70. * 2. MPL - Mozilla Public License
  71. * https://www.mozilla.org/MPL/2.0/
  72. *
  73. * Copyright statement is prohibited from modification and must be retained.
  74. *
  75. * == END LICENSE ==
  76. */
  77.  
  78. // Global Settings · Start
  79. const GLOBAL_CONFIG = {
  80. // Clean posts' format: true/false
  81. // 清除帖子格式: true/false
  82. // 清除帖子格式: true/false
  83. clean_post: false,
  84.  
  85. // Display the users' online status: 'None', 'Standard', 'Advanced'
  86. // 显示用户的在线状态: 'None', 'Standard', 'Advanced'
  87. // 顯示用戶的在線狀態: 'None', 'Standard', 'Advanced'
  88. detection_mode: 'Advanced',
  89.  
  90. // Text Beautification: true/false
  91. // 文本美化: true/false
  92. // 文字美化: true/false
  93. text_beautification: false,
  94.  
  95. // Code Beautification: true/false
  96. // 代码美化:true/false
  97. // 程式碼美化:true/false
  98. code_beautification: true,
  99.  
  100. // Scene Mode: 'Standard', 'Family', 'Office'
  101. // 场景模式: 'Standard', 'Family', 'Office'
  102. // 場景模式: 'Standard', 'Family', 'Office'
  103. scene_mode: 'Standard',
  104.  
  105. // Automatically refresh after modifying settings on webpage: true/false,
  106. // 在网页上修改设置后自动刷新: true/false,
  107. // 在網頁上修改設置後自動刷新: true/false,
  108. auto_reload: true,
  109.  
  110. // Display Eomji: true/false
  111. // 显示Emoji: true/false
  112. // 顯示Emoji: true/false
  113. display_emoji: true,
  114. }
  115. // Global Settings · End
  116.  
  117. // Below is the core code
  118.  
  119. // Host Name
  120. const hn = window.location.hostname;
  121.  
  122. function get_site_pos() {
  123. if (!!~hn.indexOf('.com.cn')) return -3;
  124. return -2;
  125. }
  126.  
  127. const site_pos = get_site_pos();
  128. const site = hn.split('.').slice(site_pos, site_pos + 1).join().toUpperCase();
  129.  
  130. GM_log("Site name:", site);
  131.  
  132. // Scene mode: Standard, Family, Office
  133. var scene_mode = GM_getValue(site + '_SCENE_MODE') || GLOBAL_CONFIG.scene_mode;
  134.  
  135. // Display the users online status
  136. var detection_mode = GM_getValue(site + '_DETECTION_MODE') || GLOBAL_CONFIG.detection_mode;
  137.  
  138. // Clean posts' format
  139. var clean_post = GM_getValue(site + '_CLEAN_POST') || GLOBAL_CONFIG.clean_post;
  140.  
  141. // Test code
  142. const ua = window.navigator.userAgent;
  143. GM_log('User-Agent:', ua);
  144. GM_log('');
  145.  
  146. GM_log('Scene mode:', scene_mode);
  147. GM_log(typeof scene_mode);
  148. GM_log('Detection mode:', detection_mode);
  149. GM_log(typeof detection_mode);
  150. GM_log('');
  151.  
  152. const clean_post_dic = {
  153. false: '关闭',
  154. true: '开启'
  155. }
  156.  
  157. const clean_post_cutover_dic = {
  158. false: true,
  159. true: false
  160. }
  161.  
  162. const detection_mode_dic = {
  163. None: '关闭',
  164. Standard: '普通',
  165. Advanced: '高级'
  166. }
  167.  
  168. const detection_mode_cutover_dic = {
  169. None: 'Standard',
  170. Standard: 'Advanced',
  171. Advanced: 'None'
  172. }
  173.  
  174. const scene_mode_dic = {
  175. Standard: '标准模式',
  176. Family: '家庭模式',
  177. Office: '办公模式'
  178. }
  179.  
  180. const scene_mode_cutover_dic = {
  181. Standard: 'Family',
  182. Family: 'Office',
  183. Office: 'Standard'
  184. }
  185.  
  186. // Cascading Style Sheets・Global
  187. GM_addStyle(`
  188. :root {
  189. --blue: #007bff;
  190. --indigo: #6610f2;
  191. --purple: #6f42c1;
  192. --pink: #e83e8c;
  193. --red: #dc3545;
  194. --orange: #fd7e14;
  195. --yellow: #ffc107;
  196. --green: #28a745;
  197. --teal: #20c997;
  198. --cyan: #17a2b8;
  199. --white: #fff;
  200. --gray: #6c757d;
  201. --gray-dark: #343a40;
  202. --primary: #007bff;
  203. --secondary: #6c757d;
  204. --success: #28a745;
  205. --info: #17a2b8;
  206. --warning: #ffc107;
  207. --danger: #dc3545;
  208. --light: #f8f9fa;
  209. --dark: #343a40;
  210. --breakpoint-xs: 0;
  211. --breakpoint-sm: 576px;
  212. --breakpoint-md: 768px;
  213. --breakpoint-lg: 992px;
  214. --breakpoint-xl: 1200px;
  215. --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";
  216. --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;
  217. }
  218.  
  219. .ads,
  220. .plc .dnch_eo_pt,
  221. .plc .dnch_eo_pb,
  222. #diynavtop,
  223. #drk_colee_left1,
  224. #drk_colee_left2,
  225. #drk_ledtd,
  226. #hd .wp .a_mu,
  227. table .a_pr,
  228. .ad .plc .a_p,
  229. .a_h,
  230. .a_t,
  231. .a_pt,
  232. .a_pb {
  233. display: none;
  234. }
  235.  
  236. .pls .avatar {
  237. padding-top: 1px;
  238. position: relative;
  239. text-align: center;
  240. object-fit: contain;
  241. }
  242.  
  243. .pls .avatar img {
  244. width: 120px;
  245. height: 120px;
  246. object-fit: contain;
  247. background: none;
  248. border-radius: 50%;
  249. padding: 0;
  250. border: 2px solid #fff;
  251. box-shadow: 0 0 10px #00BFFF;
  252. }
  253.  
  254. .pls .m img {
  255. width: 120px;
  256. height: 120px;
  257. object-fit: contain;
  258. border-radius: 50%;
  259. background: none;
  260. }
  261.  
  262. .pls .m img:hover {
  263. background: #fff;
  264. object-fit: contain;
  265. background: #fff;
  266. border-radius: 0;
  267. }
  268.  
  269. .avt img,
  270. #tath img,
  271. .rate table img,
  272. .cm .vm img,
  273. .card_mn .avt img {
  274. border: 2px solid #fff;
  275. border-radius: 50%;
  276. box-shadow: 0 0 2px #bbb;
  277. }
  278.  
  279. .avt img:hover,
  280. #tath img:hover,
  281. .rate table img:hover,
  282. .cm .vm img:hover,
  283. .card_mn .avt img:hover {
  284. border-radius: 0;
  285. box-shadow: none;
  286. }
  287.  
  288. .pls .avatar img,
  289. .avtm img,
  290. .avt img,
  291. #tath img,
  292. .rate table img,
  293. .cm .vm img,
  294. .card_mn .avt img,
  295. .pls .m img {
  296. -webkit-transition: 0.5s;
  297. -moz-transition: 0.5s;
  298. -ms-transition: 0.5s;
  299. -o-transition: 0.5s;
  300. transition: 0.5s;
  301. }
  302.  
  303. .pls .avatar img:hover,
  304. .avt img:hover,
  305. #tath img:hover,
  306. .rate table img:hover,
  307. .cm .vm img:hover,
  308. .card_mn .avt img:hover {
  309. -webkit-transform: rotate(360deg);
  310. -moz-transform: rotate(360deg);
  311. -ms-transform: rotate(360deg);
  312. -o-transform: rotate(360deg);
  313. transform: rotate(360deg);
  314. }
  315.  
  316. .user-online-status {
  317. display: block;
  318. margin: 0;
  319. border-collapse: collapse;
  320. text-align: center;
  321. position: absolute;
  322. left: 0;
  323. top: 0;
  324. width: 10px;
  325. height: 10px;
  326. cursor: help;
  327. }
  328.  
  329. .user-status-expression {
  330. display: block;
  331. position: absolute;
  332. left: 0;
  333. top: 0;
  334. margin: 0;
  335. padding: 0;
  336. text-align: center;
  337. border-collapse: collapse;
  338. cursor: help;
  339. }
  340.  
  341. .user-status-expression-online::after {
  342. content: '🌝';
  343. }
  344.  
  345. .user-status-expression-offline::after {
  346. content: '🌚';
  347. }
  348.  
  349. .offline {
  350. -webkit-filter: grayscale(100%);
  351. -moz-filter: grayscale(100%);
  352. -ms-filter: grayscale(100%);
  353. -o-filter: grayscale(100%);
  354. filter: grayscale(100%);
  355. }
  356.  
  357. #hd .wp,
  358. #um {
  359. padding-top: 0;
  360. }
  361.  
  362. .function-buttons {
  363. padding: 0 0 4px 0;
  364. text-align: right;
  365. white-space: nowrap;
  366. -webkit-user-select: none;
  367. -moz-user-select: none;
  368. -ms-user-select: none;
  369. user-select: none;
  370. }
  371.  
  372. .custom-function-button {
  373. margin: 4px 4px;
  374. padding: 2px 8px;
  375. background-color: #FFFFFF;
  376. text-align: center;
  377. border:#DCDCDC solid 1px;
  378. border-radius: 4px;
  379. outline: none;
  380. cursor: pointer;
  381. font-weight: bold;
  382. }
  383.  
  384. .custom-function-button:hover {
  385. box-shadow: 0 1px 2px #bbb;
  386. border-top: #00BFFF solid 1px;
  387. background-color: #F0FFFF;
  388. }
  389.  
  390. .button-disabled {
  391. color: #808080;
  392. cursor: default;
  393. }
  394.  
  395. .button-disabled:hover {
  396. box-shadow: none;
  397. }
  398. `);
  399.  
  400. if (GLOBAL_CONFIG.text_beautification) {
  401. GM_addStyle(`
  402. body, table, input, button, select, textarea, a {
  403. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei New", "Microsoft Yahei", "WenQuanYi Micro Hei", "Noto Sans CJK", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  404. }
  405. `)
  406. }
  407.  
  408. if (GLOBAL_CONFIG.code_beautification) {
  409. GM_addStyle(`
  410. .mono, .md, .code, .pre, .tt, mono, md, code, pre, tt,
  411. .blockcode ol li {
  412. font-family: "Fira Code", Hack, "Source Code Pro", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", "Microsoft YaHei Mono", "WenQuanYi Zen Hei Mono", "Noto Sans Mono CJK", monospace !important;
  413. }
  414. `)
  415. }
  416.  
  417. if (clean_post) {
  418. GM_addStyle(`
  419. .t_f font{
  420. font-size:inherit !important;
  421. color:inherit !important;
  422. background-color:inherit !important;
  423. font-family:inherit !important;
  424. }
  425. .t_f u{
  426. text-decoration:inherit !important;
  427. }
  428. .t_f strong{
  429. font-weight:inherit !important;
  430. }
  431. .t_f i{
  432. font-style:inherit !important;
  433. }
  434. .plhin {
  435. background: none !important;
  436. }
  437. `)
  438. }
  439.  
  440. // Login status
  441. const member = !!document.getElementById('extcreditmenu') || !!document.getElementById('myprompt') || !!document.getElementById('myrepeats');
  442.  
  443. GM_log('Login status:', member);
  444. GM_log('');
  445.  
  446. // Default avatar
  447. function default_avatar() {
  448. // https://herder.cdn.bcebos.com/uc_server/images/noavatar_big.gif
  449. // https://herder.cdn.bcebos.com/uc_server/images/noavatar_middle.gif
  450. // https://herder.cdn.bcebos.com/uc_server/images/noavatar_small.gif
  451. if (site === '52POJIE') {
  452. GM_addStyle(`
  453. .pls .avatar img,
  454. .avtm img {
  455. content: url('//avatar.52pojie.cn/images/noavatar_middle.gif');
  456. }
  457.  
  458. #um .avt img,
  459. #tath img,
  460. .rate table img,
  461. .cm .vm img,
  462. .card_mn .avt img {
  463. content: url('//avatar.52pojie.cn/images/noavatar_small.gif');
  464. }
  465. `);
  466. } else {
  467. GM_addStyle(`
  468. .pls .avatar img,
  469. .avtm img {
  470. content: url('//herder.cdn.bcebos.com/uc_server/images/noavatar_middle.gif');
  471. }
  472.  
  473. #um .avt img,
  474. #tath img,
  475. .rate table img,
  476. .cm .vm img,
  477. .card_mn .avt img {
  478. content: url('//herder.cdn.bcebos.com/uc_server/images/noavatar_small.gif');
  479. }
  480. `);
  481. }
  482. }
  483.  
  484. // Default avatar for Family attach
  485. function default_avatar_for_family_attach() {
  486. GM_addStyle(`
  487. .pls .avatar img:hover,
  488. .avtm img:hover,
  489. .avt img:hover,
  490. #tath img:hover,
  491. .rate table img:hover,
  492. .cm .vm img:hover,
  493. .card_mn .avt img:hover,
  494. .pls .m img {
  495. content: none;
  496. }
  497. `);
  498. }
  499.  
  500. // Simplified avatar
  501. function simplified_avatar() {
  502. GM_addStyle(`
  503. .pls .avatar {
  504. margin: 10px auto;
  505. width: 60px;
  506. height: 60px;
  507. }
  508.  
  509. .pls .avatar img {
  510. width: 60px;
  511. height: 60px;
  512. }
  513.  
  514. .pls .avatar img:hover {
  515. border-radius: 0;
  516. }
  517.  
  518. .md_ctrl,
  519. p.xg1,
  520. nav.toc,
  521. .scbar_hot_td,
  522. .pls .avatar_p .vm,
  523. img.authicn.vm,
  524. fieldset {
  525. display: none;
  526. }
  527.  
  528. .plhin {
  529. background: none !important;
  530. }
  531. `);
  532. }
  533.  
  534. // Hidden Signature
  535. function hidden_signature() {
  536. GM_addStyle(`
  537. .sign,
  538. .signature {
  539. display: none;
  540. }
  541. `);
  542. }
  543.  
  544.  
  545. // Show Dialog
  546. function show_dialog(message) {
  547. try {
  548. if (typeof showDialog === 'function') {
  549. showDialog(message, 'right');
  550. } else if (typeof showError === 'function') {
  551. showError(message);
  552. } else {
  553. alert(message);
  554. }
  555. } catch (error) {
  556. alert(message);
  557. }
  558. }
  559.  
  560. // Scene mode
  561. switch (scene_mode) {
  562. case 'Standard':
  563. break;
  564.  
  565. case 'Family':
  566. // Set as Default avatar
  567. default_avatar();
  568. // Set as Default avatar for Family attach
  569. default_avatar_for_family_attach();
  570. break;
  571.  
  572. case 'Office':
  573. // Set as Default avatar
  574. default_avatar();
  575. // Set as Simplified avatar
  576. simplified_avatar();
  577. // Set as Hidden Signature
  578. hidden_signature();
  579. break;
  580.  
  581. default:
  582. break;
  583. }
  584.  
  585. // Display the user real online status
  586. function display_user_real_online_status(avatar, id) {
  587. let request = new XMLHttpRequest();
  588. let url = './home.php?mod=spacecp&ac=pm&op=showmsg&touid=' + id + '&inajax=1';
  589. request.open('GET', url);
  590. request.send();
  591. request.addEventListener('readystatechange', function () {
  592. if (this.readyState === 4 && this.status === 200) {
  593. let status = !!~this.response.indexOf('[在线]');
  594. let span = document.createElement('span');
  595. span.className = status ? 'user-status-expression user-status-expression-online' : 'user-status-expression user-status-expression-offline';
  596. span.title = status ? '当前在线' : '当前离线';
  597. avatar.appendChild(span);
  598. }
  599. }, false);
  600. }
  601.  
  602. // Show users online status
  603. function show_users_online_status() {
  604. const avatar = document.getElementsByClassName('avatar');
  605. const info = document.getElementsByClassName('i');
  606. const wait = site === 'PCBETA' ? 3000 : 1111;
  607.  
  608. switch (detection_mode) {
  609. case 'None':
  610. break;
  611.  
  612. case 'Standard':
  613. // Show default users online status
  614. for (let i = 0; i < info.length; i++) {
  615. if (!!~info[i].innerHTML.indexOf('<em>当前在线</em>')) {
  616. let div = document.createElement('div');
  617. div.className = 'user-online-status online gol';
  618. div.title = '当前在线';
  619. avatar[i].appendChild(div);
  620. } else {
  621. let div = document.createElement('div');
  622. div.className = 'user-online-status offline gol';
  623. div.title = '当前离线';
  624. avatar[i].appendChild(div);
  625.  
  626. // avatar[i].classList.add('offline');
  627. }
  628. }
  629. break;
  630.  
  631. case 'Advanced':
  632. // Show real users online status
  633. for (let i = 0; i < info.length; i++) {
  634. setTimeout(() => {
  635. let html = avatar[i].innerHTML;
  636. let id = /\d/.test(html) ? html.match(/\d+/)[0] : info[i].innerHTML.match(/\d+/)[0];
  637. display_user_real_online_status(avatar[i], id);
  638. }, i * wait + 1000);
  639. }
  640. break;
  641.  
  642. default:
  643. break;
  644. }
  645. }
  646.  
  647. // Execution as Show users online status
  648. if (member) {
  649. show_users_online_status();
  650. } else if (site === 'PCBETA' || site === 'DOSPY') {
  651. detection_mode = 'Standard';
  652. show_users_online_status();
  653. }
  654.  
  655. var display_check_in_button = true;
  656.  
  657. if (site === 'KAFAN') {
  658. // Auto Check-in
  659. if (member) {
  660. const status_images = document.getElementsByClassName('qq_bind');
  661. if (!!status_images.length) {
  662. !!status_images[0].src.slice(-6, -4) === 'dk' && document.getElementById('pper_a').click();
  663. }
  664. }
  665. display_check_in_button = false;
  666. }
  667.  
  668. if (site === 'HUORONG' || site === 'DOSPY') display_check_in_button = false;
  669.  
  670. // Create Button Group
  671. function create_button_group() {
  672. // Function buttons
  673. const function_buttons = document.createElement('div');
  674. function_buttons.id = 'function-buttons';
  675. function_buttons.className = 'function-buttons';
  676. let function_buttons_package;
  677. switch (true) {
  678. case !!document.getElementsByClassName('xm_header_top_ul').length:
  679. function_buttons_package = document.getElementsByClassName('xm_header_top_ul')[0];
  680. break;
  681.  
  682. case !!document.getElementById('extcreditmenu'):
  683. function_buttons_package = document.getElementById('extcreditmenu').parentElement;
  684. break;
  685.  
  686. case site === 'PCBETA' && !!document.getElementsByClassName('hdc').length:
  687. function_buttons_package = document.getElementsByClassName('hdc')[0];
  688. break;
  689.  
  690. case !!document.getElementsByClassName('menu').length:
  691. function_buttons_package = document.getElementsByClassName('menu')[0];
  692. break;
  693.  
  694. case !!document.getElementById('pt'):
  695. function_buttons_package = document.getElementById('pt');
  696. break;
  697.  
  698. default:
  699. break;
  700. }
  701.  
  702. if (!!function_buttons_package === false) {
  703. GM_log('No nodes');
  704. return false;
  705. }
  706.  
  707. // Scene mode button
  708. function scene_mode_mouseenter() {
  709. scene_mode = GM_getValue(site + '_SCENE_MODE') || scene_mode;
  710. this.innerHTML = scene_mode_dic[scene_mode];
  711. }
  712. function scene_mode_switch() {
  713. this.disabled = true;
  714. this.classList.add('button-disabled');
  715. scene_mode = scene_mode_cutover_dic[scene_mode];
  716. this.innerHTML = scene_mode_dic[scene_mode];
  717. GM_setValue(site + '_SCENE_MODE', scene_mode);
  718. if (GLOBAL_CONFIG.auto_reload) {
  719. window.location.reload();
  720. return;
  721. }
  722. let message = '场景模式切换成功,刷新页面即可进入 <span style="color: var(--info);">' + scene_mode_dic[scene_mode] + '</span>。';
  723. show_dialog(message);
  724. this.disabled = false;
  725. this.classList.remove('button-disabled');
  726. }
  727. const scene_mode_button = document.createElement('button');
  728. scene_mode_button.className = 'custom-function-button scene-mode-button';
  729. scene_mode_button.innerHTML = scene_mode_dic[scene_mode];
  730. scene_mode_button.addEventListener('mouseenter', scene_mode_mouseenter, false);
  731. scene_mode_button.addEventListener('click', scene_mode_switch, false);
  732. function_buttons.appendChild(scene_mode_button);
  733.  
  734. // Detection mode button
  735. function detection_mode_mouseenter() {
  736. detection_mode = GM_getValue(site + '_DETECTION_MODE') || detection_mode;
  737. this.innerHTML = '探测模式:' + detection_mode_dic[detection_mode];
  738. }
  739. function detection_mode_switch() {
  740. this.disabled = true;
  741. this.classList.add('button-disabled');
  742. detection_mode = detection_mode_cutover_dic[detection_mode];
  743. this.innerHTML = '探测模式:' + detection_mode_dic[detection_mode];
  744. GM_setValue(site + '_DETECTION_MODE', detection_mode);
  745. if (GLOBAL_CONFIG.auto_reload) {
  746. window.location.reload();
  747. return;
  748. }
  749. let message = '探测模式切换成功,刷新页面即可进入 <span style="color: var(--info);">' + detection_mode_dic[detection_mode] + '</span>。';
  750. show_dialog(message);
  751. this.classList.remove('button-disabled');
  752. }
  753. if (member) {
  754. const detection_mode_button = document.createElement('button');
  755. detection_mode_button.className = 'custom-function-button detection-mode-button';
  756. detection_mode_button.innerHTML = '探测模式:' + detection_mode_dic[detection_mode];
  757. detection_mode_button.addEventListener('mouseenter', detection_mode_mouseenter, false);
  758. detection_mode_button.addEventListener('click', detection_mode_switch, false);
  759. function_buttons.appendChild(detection_mode_button);
  760. }
  761.  
  762. // Clean post button
  763. function clean_post_mouseenter() {
  764. clean_post = GM_getValue(site + '_CLEAN_POST') || clean_post;
  765. this.innerHTML = '清除格式:' + clean_post_dic[clean_post];
  766. }
  767. function clean_post_switch() {
  768. this.disabled = true;
  769. this.classList.add('button-disabled');
  770. clean_post = clean_post_cutover_dic[clean_post];
  771. this.innerHTML = '清除格式:' + clean_post_dic[clean_post];
  772. GM_setValue(site + '_CLEAN_POST', clean_post);
  773. if (GLOBAL_CONFIG.auto_reload) {
  774. window.location.reload();
  775. return;
  776. }
  777. let message = '清除格式模式切换成功,刷新页面即可进入 <span style="color: var(--info);">' + clean_post_dic[clean_post] + '</span>。';
  778. show_dialog(message);
  779. this.classList.remove('button-disabled');
  780. }
  781. if (member) {
  782. const clean_post_button = document.createElement('button');
  783. clean_post_button.className = 'custom-function-button detection-mode-button';
  784. clean_post_button.innerHTML = '清除格式:' + clean_post_dic[clean_post];
  785. clean_post_button.addEventListener('mouseenter', clean_post_mouseenter, false);
  786. clean_post_button.addEventListener('click', clean_post_switch, false);
  787. function_buttons.appendChild(clean_post_button);
  788. }
  789.  
  790. // Check in
  791. if (member && display_check_in_button) {
  792. function check_in() {
  793. const check_in = document.getElementsByClassName('check-in')[0];
  794. check_in.innerHTML = '正在签到';
  795. check_in.disabled = true;
  796. check_in.classList.add('button-disabled');
  797. setTimeout(() => {
  798. let message = '签到完成';
  799. check_in.innerHTML = message;
  800. show_dialog(message)
  801. }, 1234);
  802.  
  803. if (site === 'PCBETA') {
  804. window.open('//i.pcbeta.com/home.php?mod=task&do=apply&id=149');
  805. return false;
  806. }
  807.  
  808. for (let i = 0; i < 10; i++) {
  809. setTimeout(() => {
  810. let request = new XMLHttpRequest();
  811. let space = './home.php?mod=task&do=apply&id='.concat(i);
  812. request.open('get', space);
  813. request.send();
  814. }, i * 100);
  815. }
  816.  
  817. if (site === 'HOSTLOC') {
  818. for (let i = 0; i < 20; i++) {
  819. setTimeout(() => {
  820. let request = new XMLHttpRequest();
  821. let space = '//www.hostloc.com/space-uid-'.concat(Math.ceil(Math.random() * 47000 + 100), '.html');
  822. request.open('get', space);
  823. request.send();
  824. }, i * 100 + 1000);
  825. }
  826. }
  827. }
  828. const check_in_button = document.createElement('button');
  829. check_in_button.className = 'custom-function-button check-in';
  830. check_in_button.innerHTML = '每日签到';
  831. check_in_button.addEventListener('click', check_in, false);
  832. function_buttons.appendChild(check_in_button);
  833. }
  834.  
  835. function_buttons_package.appendChild(function_buttons);
  836. }
  837.  
  838. // Execution as Create Button Group
  839. create_button_group();
  840.  
  841. // Click the main building reply to skip to the bottom of the page
  842. function skip_bottom(params) {
  843. try {
  844. params.removeAttribute('onclick');
  845. params.addEventListener('click', function (event) {
  846. params.href = 'javascript:;';
  847. window.scrollTo(0, 54321);
  848. let fastPostMessage = document.getElementById('fastpostmessage');
  849. !!fastPostMessage && fastPostMessage.focus();
  850. }, false);
  851. } catch (error) {
  852. GM_log('You don\'t have permission to post content.');
  853. }
  854. }
  855. if (document.getElementsByClassName('prev').length === 0) {
  856. const locked = member && document.getElementsByClassName('locked');
  857. if (typeof locked === 'object' && !!locked.length) {
  858. for (let i = 0; i < locked.length; i++) {
  859. skip_bottom(locked[i].getElementsByTagName('a')[0]);
  860. }
  861. }
  862. const fastre = member && document.getElementsByClassName('fastre')[0];
  863. !!fastre && skip_bottom(fastre);
  864. }
  865.  
  866.  
  867. function get_attach_content() {
  868. switch (site) {
  869. case 'KAFAN':
  870. return '';
  871. case 'HOSTLOC':
  872. return '󠀠'.repeat(10);
  873. default:
  874. return '\n\n[img]' + window.location.protocol + '//herder.cdn.bcebos.com/images/dot.gif[/img]';
  875. }
  876. }
  877.  
  878. const attachContent = get_attach_content();
  879.  
  880. const fastPostMessage = document.getElementById('fastpostmessage');
  881.  
  882. function editor_content() {
  883. let fastPostMessageContent = fastPostMessage.value;
  884. if (fastPostMessageContent && fastPostMessageContent.length < 20) {
  885. fastPostMessageContent = fastPostMessageContent.trim();
  886. fastPostMessage.style.opacity = '0';
  887. fastPostMessage.value = fastPostMessageContent.concat(attachContent);
  888. setTimeout(() => {
  889. fastPostMessage.value = fastPostMessageContent;
  890. fastPostMessage.style.opacity = '1';
  891. }, 100);
  892. }
  893. }
  894.  
  895. !!fastPostMessage && fastPostMessage.removeAttribute('onkeydown');
  896.  
  897. !!fastPostMessage && fastPostMessage.addEventListener('keydown', function (event) {
  898. if (event.ctrlKey && event.which === 13) {
  899. editor_content();
  900. seditor_ctlent(event, 'fastpostvalidate($(\'fastpostform\'))');
  901. }
  902. if (event.altKey && event.which === 83) {
  903. editor_content();
  904. seditor_ctlent(event, 'fastpostvalidate($(\'fastpostform\'))');
  905. }
  906. }, false);
  907.  
  908. const fastPostSubmit = document.getElementById('fastpostsubmit');
  909. !!fastPostSubmit && fastPostSubmit.addEventListener('click', editor_content, false);
  910.  
  911.  
  912. // Automatically expand all posts
  913. // if (typeof display_blocked_post === 'function') display_blocked_post();
  914.  
  915. // Display Emoji
  916. if (GLOBAL_CONFIG.display_emoji) {
  917. const post = document.getElementsByClassName('t_f');
  918. for (let i = 0; i < post.length; i++) {
  919. post[i].innerHTML = post[i].innerHTML.replace(/\&amp;#.*?;/g, function (char) {
  920. if (char.length === 13) {
  921. return String.fromCodePoint(parseInt(char.match(/[0-9]+/)));
  922. }
  923. return char;
  924. }
  925. );
  926. }
  927. }
  928.  
  929. // Compatibility settings
  930.  
  931. // Cascading Style Sheets・www.hostloc.com
  932. site === 'HOSTLOC' && GM_addStyle(`
  933. #hiddenpoststip {
  934. padding: 0;
  935. }
  936.  
  937. #hiddenpoststip a {
  938. height: 32px;
  939. line-height: 32px;
  940. font-size: 16px;
  941. }
  942.  
  943. #hiddenpoststip a:hover {
  944. color: #f33;
  945. }
  946.  
  947. #hiddenpoststip a::before {
  948. padding-right: 8px;
  949. content: "🌜";
  950. }
  951.  
  952. #hiddenpoststip a::after {
  953. padding-left: 8px;
  954. content: "🌛";
  955. }
  956. `);
  957.  
  958. // Cascading Style Sheets・bbs.pcbeta.com
  959. site === 'PCBETA' && GM_addStyle(`
  960. #wp > div:first-child {
  961. display: none !important;
  962. }
  963.  
  964. #wp > div,
  965. #nv_forum > span,
  966. .pls .tip,
  967. ignore_js_op .tip {
  968. display: none;
  969. }
  970.  
  971. #wp > div.cl,
  972. #wp > div.wp,
  973. #nv_forum #scrolltop {
  974. display: block;
  975. }
  976.  
  977. .pls .avatar {
  978. overflow: unset;
  979. }
  980.  
  981. .pb_pls .avatar img {
  982. border-radius: 50%;
  983. background: none;
  984. -webkit-transition: 0.5s;
  985. -moz-transition: 0.5s;
  986. -ms-transition: 0.5s;
  987. -o-transition: 0.5s;
  988. transition: 0.5s;
  989. }
  990.  
  991. .pb_pls .avatar img:hover {
  992. border-radius: 0;
  993. }
  994.  
  995. .hdc {
  996. position: relative;
  997. }
  998.  
  999. .function-buttons {
  1000. position: absolute;
  1001. right: 0;
  1002. padding: 0 8px 4px 0;
  1003. }
  1004.  
  1005. .custom-function-button {
  1006. margin: 0 4px;
  1007. }
  1008.  
  1009. .wp .pgs {
  1010. -moz-user-select: none;
  1011. -ms-user-select: none;
  1012. -webkit-user-select: none;
  1013. user-select: none;
  1014. }
  1015. `);
  1016. })();

QingJ © 2025

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