洛谷关键词屏蔽讨论

屏蔽标题中包含关键词的讨论

目前为 2023-09-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         洛谷关键词屏蔽讨论
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  屏蔽标题中包含关键词的讨论
// @author       You
// @match        https://www.luogu.com.cn
// @match        https://www.luogu.com.cn/discuss
// @match        https://www.luogu.com.cn/discuss/list*
// @icon         https://www.luogu.com.cn/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';
  const BLOCKLIST = [' 求调 ', ' 站外题 ', ' 小游戏 ', ' 咕值 ', ' 估值 ', ' 捞 ', 'pts', ' 全 WA',
    ' 全 wa',
  ];
  const BLOCKLISTREGEX = [/\d {1,2} 分 /];
  const HREF = document.location.href;
  if (HREF.indexOf ('discuss') === -1) {
    const DISCUSSLIST = document.querySelectorAll ('.am-panel-primary');
    console.log (DISCUSSLIST);
    for (const DISCUSS of DISCUSSLIST) {
      if (DISCUSS.children [0].children [1] === undefined) {
        continue;
      }
      const TITLE = DISCUSS.children [0].children [1].children [0].innerText;
      let erased = false;
      for (const KEY of BLOCKLIST) {
        if (TITLE.indexOf (KEY) !== -1) {
          DISCUSS.parentNode.removeChild (DISCUSS);
          erased = true;
          break;
        }
      }
      if (erased) {
        continue;
      }
      for (const REGEXP of BLOCKLISTREGEX) {
        if (REGEXP.test (TITLE)) {
          DISCUSS.parentNode.removeChild (DISCUSS);
          break;
        }
      }
    }
  } else {
    const DISCUSSLIST = document.querySelectorAll ('.card.post-item.padding-default')
    for (const DISCUSS of DISCUSSLIST) {
      const TITLE = DISCUSS.children [0].children [1].children [0].children [0].innerText;
      let erased = false;
      for (const KEY of BLOCKLIST) {
        if (TITLE.indexOf (KEY) !== -1) {
          DISCUSS.parentNode.removeChild (DISCUSS);
          erased = true;
          break;
        }
      }
      if (erased) {
        continue;
      }
      for (const REGEXP of BLOCKLISTREGEX) {
        if (REGEXP.test (TITLE)) {
          DISCUSS.parentNode.removeChild (DISCUSS);
          break;
        }
      }
    }
  }
})();

QingJ © 2025

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