不想见到csdn

在bing/baidu搜索时排除csdn的结果

  1. // ==UserScript==
  2. // @name 不想见到csdn
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 在bing/baidu搜索时排除csdn的结果
  6. // @author You
  7. // @match https://*.baidu.com/*
  8. // @match https://*.bing.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com
  10. // @grant none
  11. // @license MIT
  12. // @require https://cdn.staticfile.org/jquery/3.6.1/jquery.min.js
  13.  
  14. // ==/UserScript==
  15.  
  16. /* globals jQuery. $ */
  17.  
  18.  
  19. function debounce(func, wait, immediate){
  20. var timeout, args, context, timestamp, result;
  21. if (null == wait) wait = 100;
  22.  
  23. function later() {
  24. var last = Date.now() - timestamp;
  25.  
  26. if (last < wait && last >= 0) {
  27. timeout = setTimeout(later, wait - last);
  28. } else {
  29. timeout = null;
  30. if (!immediate) {
  31. result = func.apply(context, args);
  32. context = args = null;
  33. }
  34. }
  35. };
  36.  
  37. var debounced = function(){
  38. context = this;
  39. args = arguments;
  40. timestamp = Date.now();
  41. var callNow = immediate && !timeout;
  42. if (!timeout) timeout = setTimeout(later, wait);
  43. if (callNow) {
  44. result = func.apply(context, args);
  45. context = args = null;
  46. }
  47.  
  48. return result;
  49. };
  50.  
  51. debounced.clear = function() {
  52. if (timeout) {
  53. clearTimeout(timeout);
  54. timeout = null;
  55. }
  56. };
  57.  
  58. debounced.flush = function() {
  59. if (timeout) {
  60. result = func.apply(context, args);
  61. context = args = null;
  62.  
  63. clearTimeout(timeout);
  64. timeout = null;
  65. }
  66. };
  67.  
  68. return debounced;
  69. };
  70.  
  71. (function () {
  72. 'use strict';
  73. // 选择需要观察变动的节点
  74. const targetNode = document
  75.  
  76. // 观察器的配置(需要观察什么变动)
  77. const config = { attributes: true, childList: true, subtree: true }
  78.  
  79. // 当观察到变动时执行的回调函数
  80. const callback = debounce(function () {
  81. const bing = $('a[href*="csdn"]').parents('.b_algo')
  82. const kaifa = $('a[href*="csdn"]').parents('.ant-list-item')
  83. const baidu = $('.result[mu*="csdn"]')
  84. bing.remove()
  85. kaifa.remove()
  86. baidu.remove()
  87. }, 200)
  88.  
  89. // 先调用一次
  90. callback()
  91.  
  92. // 创建一个观察器实例并传入回调函数
  93. const observer = new MutationObserver(callback)
  94.  
  95. // 以上述配置开始观察目标节点
  96. observer.observe(targetNode, config)
  97. })();

QingJ © 2025

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