GoogleFullSearchButton

Add to the Google Full Search button.

目前為 2015-08-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name GoogleFullSearchButton
  3. // @name:zh-CN 谷歌全面搜索按钮
  4. // @namespace http://www.coofly.com/
  5. // @version 1.2
  6. // @description Add to the Google Full Search button.
  7. // @description:zh-cn 给Google添加上全面搜索按钮。
  8. // @author Coofly
  9. // @match http://tampermonkey.net/scripts.php
  10. // @include /^https?://.+\.google\..+/.*$/
  11. // @exclude https://plus.google.*/*
  12. // @exclude http://plus.google.*/*
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function(){
  17. var intervalId = -1;
  18. var waitTime = 0;
  19. console.log('GoogleFullSearchButton执行, url = ' + location.href);
  20. function InsertButton(abCtls)
  21. {
  22. var targetUrl = '';
  23. var btnClass = '';
  24. if (location.href.indexOf('&safe=off') >= 0)
  25. {
  26. targetUrl = location.href.replace('&safe=off', '');
  27. btnClass = 'ab_button selected';
  28. }
  29. else
  30. {
  31. targetUrl = location.href + '&safe=off';
  32. btnClass = 'ab_button';
  33. }
  34. console.log('targetUrl = ' + targetUrl);
  35. var buttonHtml = '<li class="ab_ctl" id="full_search_btn"><a href="' + targetUrl + '" class="' + btnClass + '">全面搜索</a></li>';
  36. abCtls.insertAdjacentHTML('afterbegin', buttonHtml);
  37. }
  38. function CheckAndInsert ()
  39. {
  40. var abCtls = document.getElementById('ab_ctls');
  41. if (null === abCtls) return;
  42.  
  43. var fullSearchElem = document.getElementById('full_search_btn');
  44. if (null === fullSearchElem) InsertButton(abCtls);
  45. }
  46. var abCtls = document.getElementById('ab_ctls');
  47. if(null === abCtls)
  48. {
  49. intervalId = setInterval(CheckAndInsert, 200);
  50. console.log('intervalId = ' + intervalId);
  51. return;
  52. }
  53. else
  54. {
  55. CheckAndInsert();
  56. }
  57. })();