GoogleEasySearch

建立搜索引擎允许的语法上使我们更快找到自己所需要的内容!

  1. // ==UserScript==
  2. // @name GoogleEasySearch
  3. // @version 2.9
  4. // @license MIT
  5. // @description 建立搜索引擎允许的语法上使我们更快找到自己所需要的内容!
  6. // @author 小乘字节
  7. // @match *.google.com/*
  8. // @include http*://www.google.*/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  10. // @grant none
  11. // @require http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js
  12. // @namespace https://blog.csdn.net/qq_38238956?type=blog
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. // 配置Google搜索语法
  18. let dict = [
  19. {
  20. "value": "AND ",
  21. "describe": "并且"
  22. },
  23. {
  24. "value": "OR ",
  25. "describe": "或者"
  26. },
  27. {
  28. "value": "intitle:",
  29. "describe": "标题包含"
  30. }, {
  31. "value": "intext:",
  32. "describe": "内容包含"
  33. }, {
  34. "value": "site:",
  35. "describe": "指定网站"
  36. }, {
  37. "value": "index of /",
  38. "describe": "网站目录"
  39. }, {
  40. "value": "inurl:",
  41. "describe": "指定路径"
  42. }, {
  43. "value": "filetype:",
  44. "describe": "文件类型"
  45. }, {
  46. "value": "similar to ",
  47. "describe": "相似网站"
  48. }, {
  49. "value": "alternative to ",
  50. "describe": "相似软件"
  51. }, {
  52. "value": "link:",
  53. "describe": "查找外链"
  54. }, {
  55. "value": "define ",
  56. "describe": "词的意思"
  57. }, {
  58. "value": "weather:",
  59. "describe": "查询天气"
  60. }, {
  61. "value": "movie:",
  62. "describe": "电影信息"
  63. }, {
  64. "value": "stocks:",
  65. "describe": "查询股票"
  66. }
  67. ];
  68.  
  69. let q = jQuery("input[name='q']");
  70. let form = q.parent().parent().parent().parent().parent().parent().filter("form");
  71. let RNNXgb = form.find("div.RNNXgb");
  72. let newValue = q.val();
  73. let logo = form.find("div.logo");
  74. let sfbg = jQuery("div.sfbg");
  75.  
  76. jQuery("head").append(`<style>
  77. .earySearch{
  78. position: absolute;
  79. top: 38px;
  80. left: ${window.location.pathname === "/search"? "2.5vw":"calc(50% - 410px)"};
  81. }
  82. .earySearch select{
  83. width: 100px;
  84. background-color: #fff;
  85. }
  86. .earySearch select option{
  87. font-weight: 700;
  88. text-align: center;
  89. }
  90. </style>`);
  91. sfbg.height(sfbg.height()+20);
  92. logo.css("top", "0px");
  93. form.css({"position": "relative"});
  94.  
  95. // 添加相关元素
  96. RNNXgb.before(`<div class="easySearchText" style="margin:0 0 5px 0;color:#758a99;">
  97. 模糊匹配【*】、精确匹配【" "】、过滤【-】、包含【+】、范围【..】
  98. </div>`);
  99. form.append(`<div class='earySearch'>
  100. <select class='earySearchDict'>
  101. <option value='-1'>--进阶搜索--</option>
  102. <option value='https://blog.csdn.net/qq_38238956/article/details/126424625' style="color:#00e09e;">使用帮助</option>
  103. </select>
  104. </div>`);
  105. let earySearch = form.find("div.earySearch");
  106. let earySearchDict = earySearch.find(".earySearchDict");
  107. dict.map((data)=>{
  108. earySearchDict.append(`<option value='${data.value}'>${data.describe}</option>`);
  109. });
  110.  
  111. // 监听select元素
  112. earySearchDict.change(function() {
  113. let index = this.selectedIndex;
  114. if (index === 0) {
  115. return;
  116. }else if(index === 1){
  117. window.location.href = this.value;
  118. return;
  119. }
  120. // 向搜索框添加内容
  121. q.val(newValue.concat(" ", this.value));
  122. q.focus();
  123. });
  124.  
  125. // 获取键盘输入的内容
  126. q.on("input", function() {
  127. clearTimeout(this.myTimeOut);
  128. let _this = this;
  129. this.myTimeOut = setTimeout(()=>{
  130. newValue = _this.value;
  131. }, 300);
  132. });
  133.  
  134. // 清空搜索框
  135. let ariaLavel = jQuery("div.BKRPef > div");
  136. ariaLavel.on('click', function() {
  137. newValue = '';
  138. });
  139.  
  140. })();

QingJ © 2025

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