fCSDNck

屏蔽百度搜索结果中 CSDN 相关搜索结果

当前为 2022-03-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name fCSDNck
  3. // @namespace https://github.com/tempestLXC/fCSDNck
  4. // @version 0.0.3
  5. // @description 屏蔽百度搜索结果中 CSDN 相关搜索结果
  6. // @author tempestlxc
  7. // @match *://www.baidu.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var CSDN='-(csdn)';
  15. var button = document.createElement("button");
  16. button.id = "bdIndexButton"
  17. button.className = "btn self-btn bg s_btn";
  18. button.textContent = "fCSDNck";
  19. button.style.background = "#e33e33";
  20. button.style.display = "none";
  21. button.addEventListener("click", clickBotton);
  22.  
  23. function clickBotton(){
  24. var kw =document.getElementById('kw');
  25. if( !isEmpty(kw.value) && !kw.value.includes(CSDN) ){
  26. kw.value = kw.value + ' ' +CSDN;
  27. }
  28. }
  29.  
  30. var like_comment = document.getElementById('s_btn_wr');
  31.  
  32. if(!isEmpty(like_comment)){
  33. var span = document.getElementById(like_comment.id);
  34.  
  35. span.onmouseover = function() { button.style.display = "block"; };
  36.  
  37. span.onmouseout = function() { button.style.display = "none"; };
  38.  
  39. }
  40. like_comment.appendChild(button);
  41.  
  42. function isEmpty(obj){
  43. if(typeof obj == "undefined" || obj == null || obj == ""){
  44. return true;
  45. }else{
  46. return false;
  47. }
  48. }
  49. })();