Luogu Comment Filter

过滤洛谷无意义评论

  1. // ==UserScript==
  2. // @name Luogu Comment Filter
  3. // @version 0.1
  4. // @description 过滤洛谷无意义评论
  5. // @author CoderOJ
  6. // @match https://www.luogu.com.cn/discuss/*
  7. // @icon https://www.google.com/s2/favicons?domain=luogu.com.cn
  8. // @grant none
  9. // @namespace https://gf.qytechs.cn/users/799991
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const filterList = [
  16. "qp",
  17. "hp",
  18. "前排",
  19. "后排",
  20. "滋滋",
  21. "滋磁",
  22. "zc",
  23. "这么前",
  24. "sqlm",
  25. "hqlm",
  26. "stlm",
  27. "考古",
  28. "%%%",
  29. "orz",
  30. "Orz",
  31. "sto",
  32. "兜售",
  33. "mian包",
  34. ];
  35.  
  36. function isFiltered(content) {
  37. let pamLength = 0;
  38. for (const rule of filterList) {
  39. if (content.search(rule) != -1) {
  40. pamLength += (content.split(rule).length - 1) * rule.length;
  41. }
  42. }
  43. const actLength = content.split("").filter(c => !c.match(/\s/)).length;
  44. return pamLength >= actLength * 0.5;
  45. }
  46.  
  47. function hideDom(dom) {
  48. let p = dom.parentNode.parentNode;
  49. p.style.display = "none";
  50. }
  51.  
  52. let filteredContents = [];
  53. for (const dom of document.getElementsByClassName("am-comment-bd")) {
  54. const content = dom.innerText;
  55. if (isFiltered(content.trim())) {
  56. filteredContents.push(content.trim());
  57. hideDom(dom);
  58. }
  59. }
  60. console.log("[lgcf] filtered contents");
  61. filteredContents.forEach(a => console.log(a));
  62. })();

QingJ © 2025

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