google百度搜索屏蔽CSDN

自动在搜索条件后面增加 -csdn, 以此屏蔽csdn网站信息。只适用于google和百度的搜索页面

  1. // ==UserScript==
  2. // @name google百度搜索屏蔽CSDN
  3. // @icon https://csdnimg.cn/public/favicon.ico
  4. // @namespace http://cjcmx.net/
  5. // @version 0.1
  6. // @description 自动在搜索条件后面增加 -csdn, 以此屏蔽csdn网站信息。只适用于google和百度的搜索页面
  7. // @author cjcmx
  8. // @match *://www.google.com/search*
  9. // @match *://www.baidu.com/s*
  10. // @match *://www.baidu.com/$
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var className = {
  17. "baidu":"s_ipt",
  18. "google": "gLFyf gsfi"
  19. };
  20. var key = window.location.href.indexOf("://www.baidu.com")!=-1 ? "baidu" : "google";
  21. var wordInput = document.getElementsByClassName(className[key])[0];
  22. if(wordInput){
  23. wordInput.addEventListener("keydown",function(e){
  24. if(e.key=='Enter' && this.value.length>0 && this.value.indexOf("-csdn")==-1){
  25. this.value += " -csdn";
  26. }
  27. });
  28. wordInput.addEventListener("blur",function(){
  29. if(this.value.length>0 && this.value.indexOf("-csdn")==-1){
  30. this.value += " -csdn";
  31. }
  32. });
  33. wordInput.addEventListener("focus",function(){
  34. var index = this.value.indexOf(" -csdn");
  35. if(index != -1){
  36. this.value = this.value.substring(0,index);
  37. }
  38. })
  39. }
  40. })();

QingJ © 2025

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