Advertisement
name

论坛帖子显示隐藏助手(用户脚本)

Mar 5th, 2020 (edited)
2,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         论坛帖子显示隐藏助手(用户脚本)
  3. // @namespace    https://pastebin.com/8BVBeieH
  4. // @version      0.0.1
  5. // @description  适用于 Discuz! 论坛帖子列表页面,基于帖子标题关键词重点显示或隐藏某些帖子。
  6. // @homepage     https://pastebin.com/8BVBeieH
  7. // @icon         https://s.pc.qq.com/tousu/img/20211017/1049266_1634438609.jpg
  8. // @updateURL    https://pastebin.com/raw/8BVBeieH
  9. // @installURL   https://pastebin.com/raw/8BVBeieH
  10. // @downloadURL  https://pastebin.com/raw/8BVBeieH
  11. // @supportURL   https://hostloc.com/space-username-论坛大师.html
  12. // @author       论坛大师
  13. // @match        http*://*/forum-*-*.html
  14. // @match        http*://*/forum.php?mod=forumdisplay&fid=*
  15. // @grant        none
  16. // ==/UserScript==
  17.  
  18. (() => {
  19.   const allowlist = [
  20.     /免费/i,
  21.     /送/i,
  22.     /漏洞/i,
  23.     /抢/i,
  24.     /踢号/i,
  25.     /T号/i,
  26.     /踢楼/i,
  27.     /T楼/i,
  28.     /传家宝/i,
  29.     /薅羊毛/i,
  30.     /白嫖/i,
  31.     /白女票/i,
  32.   ];
  33.  
  34.   const blocklist = [
  35.     /新闻联播/i,
  36.     /股票/i,
  37.     /炒股/i,
  38.     /基金/i,
  39.     /期货/i,
  40.     /贷款/i,
  41.   ];
  42.  
  43.   const POST_LIST = document.getElementById('threadlisttableid').getElementsByClassName('s');
  44.   for (const post of POST_LIST) {
  45.     const POST_TITLE = post.innerHTML;
  46.     for (const allow of allowlist) {
  47.       if (allow.test(POST_TITLE)) {
  48.         const icon = post.parentElement.parentElement.getElementsByClassName('icn')[0];
  49.         icon.style.cursor = 'default';
  50.         icon.innerHTML = '🔴';
  51.         post.innerHTML = POST_TITLE.replace(allow, `<span style="color: red;">${POST_TITLE.match(allow)[0]}</span>`);
  52.       }
  53.     }
  54.     for (const block of blocklist) {
  55.       if (block.test(POST_TITLE)) {
  56.         post.parentElement.parentElement.parentElement.style.display = 'none';
  57.       }
  58.     }
  59.   }
  60. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement