屏蔽DogeDoge、Baidu、Bing、Google包含Csdn的搜索结果

try to take over the world!

  1. // ==UserScript==
  2. // @name 屏蔽DogeDoge、Baidu、Bing、Google包含Csdn的搜索结果
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author https://github.com/yizhitangtongxue
  7. // @include https://www.dogedoge.com/results?*
  8. // @include https://cn.bing.com/search?*
  9. // @include https://www.baidu.com/s?*
  10. // @include https://www.google.com/search?*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. let domain = document.domain
  16.  
  17. if (domain.indexOf("doge") != -1) {
  18.  
  19. let elements = document.querySelectorAll(".result.results_links_deep.highlight_d.result--url-above-snippet")
  20.  
  21. elements.forEach(function (item) {
  22. let itemDomain = item.getAttribute("data-domain")
  23. if (itemDomain.indexOf("csdn") != -1) {
  24. item.style.display = "none"
  25. }
  26. })
  27. }
  28.  
  29. if (domain.indexOf("bing") != -1) {
  30. let elements = document.querySelectorAll(".b_algo")
  31. console.log(elements)
  32. elements.forEach(function (item) {
  33.  
  34. let itemDomain = item.getElementsByTagName("cite")[0].innerHTML
  35.  
  36. if (itemDomain.indexOf("csdn") != -1) {
  37. item.style.display = "none"
  38. }
  39. })
  40. }
  41.  
  42. if (domain.indexOf("baidu") != -1) {
  43. processingBaidu()
  44. }
  45. if (domain.indexOf("google") != -1 || domain.indexOf("bing") != -1) {
  46.  
  47. let elements = document.querySelectorAll(".g")
  48. elements.forEach(function (item) {
  49. let itemDomain = item.getElementsByTagName("cite")[0].innerHTML
  50.  
  51. if (itemDomain.indexOf("csdn") != -1) {
  52. item.style.display = "none"
  53. }
  54. })
  55.  
  56. }
  57.  
  58. })();
  59.  
  60. function log(parameter) {
  61. console.log(parameter)
  62. }
  63.  
  64. function processingBaidu() {
  65. let left = document.getElementById("content_left")
  66. let getHeight = left.offsetHeight
  67.  
  68. setInterval(function(){
  69. let elements = document.querySelectorAll(".c-container");
  70.  
  71. elements.forEach(function (item) {
  72.  
  73. let content = item.querySelector(".f13 a:first-child")
  74. if (content !== null) {
  75. let contentText = content.text
  76. if (contentText.indexOf("csdn") != -1 || contentText.indexOf("CSDN") != -1) {
  77.  
  78. item.style.display = "none"
  79.  
  80. }
  81. }
  82.  
  83. });
  84. })
  85. }