双搜索引擎

2021/1/4 上午10:33:27

  1. // ==UserScript==
  2. // @name 双搜索引擎
  3. // @namespace Violentmonkey Scripts
  4. // @include https://www.google.com*
  5. // @match https://www.baidu.com/s
  6. // @match https://www.baidu.com/
  7. // @grant none
  8. // @version 1.3
  9. // @author -
  10. // @description 2021/1/4 上午10:33:27
  11. // ==/UserScript==
  12. var e_0 = document.createElement("div");
  13. var e_1 = document.createElement("div");
  14. e_1.setAttribute("class", "FAuhyb zgAlFc");
  15. var e_2 = document.createElement("span");
  16. e_2.setAttribute("class", "z1asCe MZy1Rb");
  17. var e_3 = document.createElementNS("http://www.w3.org/2000/svg","svg");
  18. e_3.setAttribute("focusable", "false");
  19. e_3.setAttribute("xmlns", "http://www.w3.org/2000/svg");
  20. e_3.setAttribute("fill", "#4e6ef2");
  21. e_3.setAttribute("viewBox", "0 0 24 24");
  22. var e_4 = document.createElementNS("http://www.w3.org/2000/svg","path");
  23. e_4.setAttribute("d", "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z");
  24. e_3.appendChild(e_4);
  25. e_2.appendChild(e_3);
  26. e_1.appendChild(e_2);
  27. e_0.appendChild(e_1);
  28.  
  29. window.onload = () => {
  30. if ( /www\.google\.com\./.test(window.location.hostname)) {
  31. const box = document.querySelector("div.RNNXgb[jsname='RNNXgb']");
  32. const input = document.querySelector("input[aria-label='搜索']");
  33. const a = document.createElement('a');
  34. a.className = 'Tg7LZd'
  35. a.ariaLabel = '百度搜索'
  36. a.style = `
  37. display: flex;
  38. align-items: center;
  39. justify-content: center;
  40. box-sizing: border-box;
  41. `
  42. a.href = `https://www.baidu.com/s?wd=${input.value}`
  43. input.oninput = (e) => {
  44. a.href= `https://www.baidu.com/s?wd=${e.target.value}`
  45. }
  46. a.appendChild(e_0)
  47. box.appendChild(a)
  48. } else if (/www\.google\.com/.test(window.location.hostname)) {
  49. const box = document.querySelector("div.RNNXgb[jsname='RNNXgb']");
  50. const textarea = document.querySelector("textarea[aria-label='搜索']");
  51. const a = document.createElement('a');
  52. a.className = 'Tg7LZd'
  53. a.ariaLabel = '百度搜索'
  54. a.style = `
  55. display: flex;
  56. align-items: center;
  57. justify-content: center;
  58. box-sizing: border-box;
  59. `
  60. a.href = `https://www.baidu.com/s?wd=${textarea.value}`
  61. textarea.oninput = (e) => {
  62. a.href= `https://www.baidu.com/s?wd=${e.target.value}`
  63. }
  64. a.appendChild(e_0)
  65. box.appendChild(a)
  66. } else if (window.location.hostname === "www.baidu.com") {
  67. const su = document.getElementById('su')
  68. su.style = 'border-radius: 0'
  69. const input = document.createElement('input')
  70. const kw = document.getElementById('kw')
  71. input.style = `
  72. vertical-align:top;
  73. cursor: pointer;
  74. width: 60px;
  75. height: 100%;
  76. line-height: 40px;
  77. line-height: 40px\\9;
  78. background-color: #4e6ef2;
  79. border-radius: 0 10px 10px 0;
  80. font-size: 17px;
  81. box-shadow: none;
  82. font-weight: 400;
  83. border: 0;
  84. outline: 0;
  85. letter-spacing: normal;
  86. color: #ffffff;
  87. `
  88. input.type = 'submit'
  89. input.value = '谷歌'
  90. input.onclick = () => {
  91. window.location.href=`https://www.google.com/search?q=${kw.value}`
  92. // window.open(`https://www.google.com/search?q=${kw.value}`)
  93. }
  94. const box = su.parentNode
  95. box.style = `width: max-content;`
  96. const form = document.getElementById('form')
  97. form.style.width = 'max-content'
  98.  
  99. box.appendChild(input)
  100. }
  101. }

QingJ © 2025

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