NickGPT

Use NickGPT on Google Search page!

当前为 2023-04-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NickGPT
  3. // @namespace https://ugpt.nickname4th.vip/
  4. // @version 0.7
  5. // @description Use NickGPT on Google Search page!
  6. // @author InJeCTrL
  7. // @match *://www.google.com/search*
  8. // @match *://www.google.com.hk/search*
  9. // @match *://www.google.co.uk/search*
  10. // @match *://www.baidu.com*
  11. // @match *://www.baidu.com/s*
  12. // @match *://so.toutiao.com/search*
  13. // @match *://cn.bing.com/search*
  14. // @match *://www.bing.com/search*
  15. // @match *://duckduckgo.com/?*
  16. // @match *://www.so.com/s?*
  17. // @match *://www.sogou.com/*
  18. // @grant window.onurlchange
  19. // @grant GM_addElement
  20. // @icon https://s1.ax1x.com/2023/04/21/p9E40Ve.png
  21. // @require https://code.jquery.com/jquery-3.6.0.js
  22. // @require https://cdn.bootcdn.net/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js
  23. // @resource css https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css
  24. // @run-at document-end
  25. // @license MIT
  26. // ==/UserScript==
  27.  
  28. (function () {
  29. 'use strict';
  30.  
  31. function getSearchContent() {
  32. var url = window.location.href;
  33. if (url.indexOf("www.baidu.com") != -1) {
  34. return document.getElementById('kw').value;
  35. } else if (url.indexOf("www.google.") != -1) {
  36. return document.getElementsByTagName('textarea')[0].textContent;
  37. } else if (url.indexOf("so.toutiao.com") != -1) {
  38. return document.getElementsByTagName('input')[0].value;
  39. } else if (url.indexOf("bing.com") != -1) {
  40. return document.getElementById('sb_form_q').value;
  41. } else if (url.indexOf("duckduckgo.com") != -1) {
  42. return document.getElementById('search_form_input').value;
  43. } else if (url.indexOf("www.so.com") != -1) {
  44. return document.getElementById('keyword').value;
  45. } else if (url.indexOf("www.sogou.com") != -1) {
  46. return document.getElementById('upquery').value;
  47. }
  48. }
  49.  
  50. function searchKeyword() {
  51. document.getElementById('nickgpt-wnd')
  52. .contentWindow.postMessage({
  53. "nickGPT": getSearchContent()
  54. }, '*');
  55. }
  56.  
  57. function nickgptHandler(message) {
  58. if (message.data == "chatready") {
  59. searchKeyword();
  60. }
  61. }
  62.  
  63. function insertWnd() {
  64. var box = document.createElement("div");
  65. var ifr = document.createElement("iframe");
  66. ifr.id = "nickgpt-wnd";
  67. ifr.src = "https://ugpt.nickname4th.vip";
  68. box.id = "nickgpt-box";
  69. document.body.insertBefore(box, document.body.firstChild);
  70. GM_addElement(box, 'iframe', {
  71. src: "https://ugpt.nickname4th.vip",
  72. id: "nickgpt-wnd"
  73. });
  74.  
  75. $(function () {
  76. $("#nickgpt-box").draggable();
  77. });
  78.  
  79. window.addEventListener("message", nickgptHandler);
  80. }
  81.  
  82. function insertStyle() {
  83. var css = "\
  84. #nickgpt-box {\
  85. border: 1px solid #cceff5;\
  86. position: fixed;\
  87. right: 10%;\
  88. top: 8%;\
  89. width: 30%;\
  90. height: 80%;\
  91. z-index: 998;\
  92. padding-top:25px;\
  93. background: #1E90FF;\
  94. cursor: grab;\
  95. border-radius: 25px;\
  96. box-shadow: 1px 1px 1px 1px grey;\
  97. }\
  98. #nickgpt-wnd {\
  99. border: none;\
  100. width: 100%;\
  101. height: 100%;\
  102. z-index: 999;\
  103. background: white;\
  104. border-radius: 25px;\
  105. }";
  106. const style = document.createElement('style');
  107. style.type = 'text/css';
  108. style.appendChild(document.createTextNode(css));
  109. document.children[0].appendChild(style);
  110. }
  111.  
  112. if (window.onurlchange === null &&
  113. (window.location.href.indexOf("www.so.com") != -1 || window.location.href.indexOf("www.baidu.com") != -1)) {
  114. window.addEventListener('urlchange', (info) => {
  115. searchKeyword();
  116. });
  117. }
  118.  
  119. insertStyle();
  120. insertWnd();
  121. })();

QingJ © 2025

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