隐藏百度搜索结果中 CSDN&百度经验&百度知道 的垃圾内容

try to take over the world!

  1. // ==UserScript==
  2. // @name 隐藏百度搜索结果中 CSDN&百度经验&百度知道 的垃圾内容
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.4
  5. // @description try to take over the world!
  6. // @author pozhu
  7. // @include http*://www.baidu.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14.  
  15. // Your code here...
  16. function cleanTheResult() {
  17. var list = Array.from(document.getElementsByClassName("source_1Vdff")).map((item) => item.firstChild);
  18. var rex = /CSDN|csdn|百度知道|百度经验|mamicode|bubuko|codercto|javascriptcn|程序员软件开发技术分享社区|编程字典|编程圈|thinbug|voidcc|慕课网|码客|编程之家/;
  19. var num = 0;
  20.  
  21. function findParent(item) {
  22. // console.log(item);
  23. if (item.classList.contains("c-container")) {
  24. item.style.display = "none";
  25. num++;
  26. } else {
  27. findParent(item.parentElement);
  28. }
  29. }
  30. list.map((item) => {
  31. if (rex.test(item.innerText)) {
  32. findParent(item);
  33. }
  34. });
  35. console.log("已屏蔽" + num + "条搜索结果");
  36. }
  37.  
  38. document.addEventListener("click", () => {
  39. cleanTheResult();
  40. });
  41.  
  42. window.addEventListener("DOMContentLoaded", function () {
  43. cleanTheResult();
  44. });
  45. })();

QingJ © 2025

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