remove CSDN

在搜索结果中屏蔽 CSDN。支持 Google / Baidu / Bing / 360 搜索

  1. // ==UserScript==
  2. // @name remove CSDN
  3. // @namespace czqu
  4. // @version 1.1
  5. // @icon https://www.google.com/s2/favicons?sz=64&domain=csdn.net
  6. // @description 在搜索结果中屏蔽 CSDN。支持 Google / Baidu / Bing / 360 搜索
  7. // @license GNU-GPLv3
  8. // @include *://*.baidu.com/baidu?*
  9. // @include *://*.baidu.com/s?*
  10. // @include *://*.google.*/search*
  11. // @include *://*.bing.com/search*
  12. // @include *://*.so.com/s*
  13. // @include *://*.csdn.net/*
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. function isSite(domain) {
  18. return window.location.href.match(new RegExp("^https?:\/\/[\\w.]+?" + domain))
  19. }
  20.  
  21. function HideCSDN(){
  22. const filters = ".source_1Vdff, .iUh30, .b_attribution, .g-linkinfo-a,.c-showurl".split(", ")
  23. const Elements=document.querySelectorAll(".result.c-container, .g, .b_algo, .res-list");
  24. let num;
  25. Elements.forEach(function(Item,i){
  26. for (var filter in filters) {
  27. let selectedContent=Item.querySelector(filters[filter])
  28. if (selectedContent !== null) {
  29. console.log(selectedContent.innerText)
  30. if (selectedContent.innerText.toLowerCase().includes("csdn")) {
  31. Item.parentNode.removeChild(Item);
  32. num = i;
  33. break;
  34. }
  35. }
  36. }
  37. });
  38. if (num !== undefined) {
  39. console.log(`[Fuck CSDN] 已去除 ${num} CSDN 内容`)
  40. }
  41. }
  42.  
  43. function bind() {
  44. document.querySelectorAll(".page-item_M4MDr, #form, #page, .ac_wrap").forEach(
  45. function(Item) {
  46. Item.addEventListener('mousedown',function () {
  47. setTimeout(function(){
  48. HideCSDN();
  49. if (isSite('so.com')) {
  50. bind();
  51. }
  52. },1000);
  53. })
  54. }
  55. )}
  56.  
  57. // 绑定回车事件
  58. document.querySelectorAll("input.gLFyf.gsfi, input#kw, input#keyword").forEach(
  59. function(Item) {
  60. Item.addEventListener('keydown', function () {
  61. var evt = window.event || arguments.callee.caller.arguments[0];
  62. if (evt.keyCode == "13") {
  63. setTimeout(function(){HideCSDN();},1000);
  64. }
  65. })})
  66.  
  67. if (isSite('csdn.net')) {
  68. document.body.innerHTML = "Blocked by Fuck CSDN.";
  69. window.history.go(-1);
  70. }
  71.  
  72. HideCSDN();
  73. bind();

QingJ © 2025

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