GoogleRes

在谷歌搜索结果页面添加底部搜索框,并修改搜索结果打开方式为新窗口打开

  1. // ==UserScript==
  2. // @name GoogleRes
  3. // @version 1.0
  4. // @author (σ`д′)σ
  5. // @description 在谷歌搜索结果页面添加底部搜索框,并修改搜索结果打开方式为新窗口打开
  6. // @description:en Add another search input at the bottom of result page & change the redirect way from "current tab" to "new tab"
  7. // @namespace https://greasyfork.org/zh-CN/scripts/33481
  8. // @license GPL-3.0-or-later
  9. // @include *://www.google.com*/search*
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.slim.min.js
  11. // @grant none
  12. // @run-at document-body
  13. // @supportURL https://github.com/Xli33/fun-script
  14. // @homepageURL https://github.com/Xli33/fun-script
  15. // ==/UserScript==
  16.  
  17. $(function () {
  18. "use strict";
  19.  
  20. var $as = $("#rso").children().children().find("a"),
  21. $fas = $("#fbar").find("a"),
  22. $tsf = $("#tsf"),
  23. $resul = $("sbtc").children(".gstl_0.sbdd_a"),
  24. $lst = $("#lst-ib"),
  25. $cloneForm = $tsf.clone(true);
  26. $as.each(function (i, e) {
  27. e.target = "_blank";
  28. });
  29. $fas.each(function (i, e) {
  30. e.target = "_blank";
  31. });
  32. $cloneForm
  33. .attr("id", "_cloneForm")
  34. .find("#gs_st0")
  35. .attr("id", "_cloneGs_st0")
  36. .next()
  37. .find("#lst-ib")
  38. .attr("id", "_cloneLst-ib")
  39. .on({
  40. click: function (e) {
  41. e.stopPropagation();
  42. },
  43. focus: function () {
  44. $tsf.css("position", "fixed");
  45. },
  46. input: function () {
  47. $lst.val(this.value); //.trigger('input');
  48. },
  49. blur: function () {
  50. $resul.hide();
  51. },
  52. });
  53. $cloneForm.css("marginBottom", "25px");
  54. $cloneForm
  55. .find("#_cloneGs_st0")
  56. .children("a")
  57. .on("click", function () {
  58. $("#gs_st0").children("a").click();
  59. });
  60. $("#rcnt")
  61. .on("click", function () {
  62. $tsf.css("position", "");
  63. })
  64. .append($cloneForm);
  65. });