chatGPT tools Plus(修改版)

Google、必应、百度、Yandex、360搜索、谷歌镜像、搜狗、b站、F搜、duckduckgo、CSDN侧边栏Chat搜索,集成国内一言,星火,天工,混元,通义AI,ChatGLM,360智脑,miniMax,DeepSeek、Gemini。即刻体验AI,无需翻墙,无需注册(不可用),无需等待!

  1. // ==UserScript==
  2. // @name chatGPT tools Plus(修改版)
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.6.6
  5. // @description Google、必应、百度、Yandex、360搜索、谷歌镜像、搜狗、b站、F搜、duckduckgo、CSDN侧边栏Chat搜索,集成国内一言,星火,天工,混元,通义AI,ChatGLM,360智脑,miniMax,DeepSeek、Gemini。即刻体验AI,无需翻墙,无需注册(不可用),无需等待!
  6. // @description:en Google, Bing, Baidu, Yandex, 360 Search, Google Mirror, Sogou, B Station, F Search, DuckDuckgo, CSDN sidebar CHAT search, integrate domestic words, star fire, sky work, righteous AI, Chatglm, 360 wisdom, 360 wisdom brain. Experience AI immediately, no need to turn over the wall, no registration, no need to wait!
  7. // @description:zh-TW Google、必應、百度、Yandex、360搜索、谷歌鏡像、搜狗、b站、F搜、duckduckgo、CSDN側邊欄Chat搜索,集成國內一言,星火,天工,通義AI,ChatGLM,360智腦。即刻體驗AI,無需翻墻,無需註冊,無需等待!
  8. // @author 夜雨
  9. // @match https://cn.bing.com/*
  10. // @match https://www.bing.com/*
  11. // @match *://*.bing.com/*
  12. // @match https://chat.openai.com/chat
  13. // @match https://www.google.com/*
  14. // @match https://duckduckgo.com/*
  15. // @match https://www.so.com/s*
  16. // @match *://m.so.com/s*
  17. // @match *://www.baidu.com/s*
  18. // @match https://www.baidu.com/*
  19. // @match https://m.baidu.com/*
  20. // @match *://baidu.com/s*
  21. // @match *://yandex.ru/search*
  22. // @match *://yandex.com/search*
  23. // @match https://search.ecnu.cf/search*
  24. // @match https://search.aust.cf/search*
  25. // @match https://search.*.cf/search*
  26. // @match https://*.cf:*/*
  27. // @match *://gooo.azurewebsites.net/*
  28. // @match https://fsoufsou.com/search*
  29. // @match https://www.google.com.hk/*
  30. // @match *://www.sogou.com/*
  31. // @match *://m.sogou.com/*
  32. // @match *://chat.scnet.cn/*
  33. // @match *://wap.sogou.com/*
  34. // @match *://*.tiangong.cn/*
  35. // @match *://www.bilibili.com/video/*
  36. // @match *://blog.csdn.net/*/article/details/*
  37. // @match *://chatglm.cn/*
  38. // @icon64 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAZlBMVEUAAAD///+hoaFoaGhsbGy7u7vd3d2+vr76+vra2tr29va2trYrKyvg4ODs7OxXV1dgYGCtra0xMTGXl5fExMQ6OjqOjo7R0dEVFRWnp6dSUlIiIiIcHBwLCwt4eHhycnKEhIRHR0f14+hfAAADN0lEQVRYhe1WyZajMAyEsMQshgABEwIJ+f+fbC02W0yHnjnNvNYFDFbZKpUlO86v/e/Wpve/8M4TFckwSvI/cx8z11g2/tw9vZKrEIKe159GUkvwipPxVb4eQQzvYV12XX3Y/x6BT5LqUZkgWixEHF/9/hAAeozz0I8nOtzoccDfg8CbaZQrYkOGYUaEFO2RDUTT4MZefjkMpVcQo5/Wr2DSi9/bhlYPhukvZqf41l3hiiFv8xJR2CslIT+XXfc+YapojY60kG1ZA0rknj+lL4YtnGCQ4lbESSczf5R6Ugc5ee4AoL9KAwbwYXDWXJTXhaDhf2L3R44rxzkbgFgHn55Y0JJjzyeONpYLDn4CCPn7A46VaggjwIB6eEltAOConCUAcZVDXBKIHHgbp9IZ4KW0AZj8LAHaQEzaY0lmHk60AXiQ8XYFEDoVrRpXOmSfdQFfbMe7MuTOJMLU6IJqkh7PuTMVrhosAJCp2xrApA6Lk+p4VllMQjsAcNNkpzeQlKkPHhQb0VkAEgO8TSMaVqhMH/EyW57W2R7moNoBCjwDPg1QzM07QAk7o+wUrIcNwAVZ1ktAROE7gBMaEq4kaW8NgHlQOsrULiUoHjGT40PIqngHOIGYzRK22ggJz3TpbrCt7AMU9gPZwc4y5slJC7FO4woAxmcLgMMi0dF1ymSOtnMEYFDczxqtdJRM6HlAbhSvARIqHG+G5BJGqONoK2opooIMLQFaYMvWs0EJruNRV1b8vy+wqDtbEj2caAcQg5NWdIQL6IJPjIGg1gDKhLINARyxed4DpgLFq+vvKoRiEszGWmlCy0OmcyrqSxKr/eaUzFvDGnDWCX2d5zQmNdJsO4xoz8XeyqcpIdRexZ0BBOYl2r2wyHfwB2WFO0zBjS/Zv2Vc8Pey3l3kor0iR65Q+61Vr6GmttNSOtxRf+jgvfnW3eFa4CZ+3fb1k1q1uC0D3GmKC2s5zkxKvieqWbKQPvFpfbRnNF+pYn/+3ny6m0zW+9eYDIMxlQsbvKuO3zfrV5fWKMc4GLu6G+m2KY/fNNnu6/vu2drTv7fFjVuOP3dHy5MolJEqrKfvoPXp57vpr/3r9gUxwiW4OiuC3wAAAABJRU5ErkJggg==
  39. // @grant GM_xmlhttpRequest
  40. // @grant GM_addStyle
  41. // @grant GM_openInTab
  42. // @grant GM_registerMenuCommand
  43. // @grant GM_setValue
  44. // @grant GM_getValue
  45. // @grant GM_getResourceText
  46. // @grant GM_setClipboard
  47. // @grant GM_info
  48. // @run-at document-end
  49. // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.4.0/jquery.min.js
  50. // @require https://s4.zstatic.net/ajax/libs/showdown/2.1.0/showdown.min.js
  51. // @require https://s4.zstatic.net/ajax/libs/highlight.js/11.7.0/highlight.min.js
  52. // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
  53. // @require https://s4.zstatic.net/ajax/libs/KaTeX/0.16.6/katex.min.js
  54. // @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/toastr.js/2.1.4/toastr.min.js
  55. // @require https://s4.zstatic.net/ajax/libs/marked/13.0.2/marked.min.js
  56. // @resource toastCss https://cdn.bootcdn.net/ajax/libs/toastr.js/2.1.4/toastr.min.css
  57. // @resource katexCss https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.6/katex.css
  58. // @connect api.forchange.cn
  59. // @connect hunyuan.tencent.com
  60. // @connect yuanbao.tencent.com
  61. // @connect baichuan-ai.com
  62. // @connect chatbot.theb.ai
  63. // @connect cbjtestapi.binjie.site
  64. // @connect freechatgpt.xgp.one
  65. // @connect luntianxia.uk
  66. // @connect xjai.pro
  67. // @connect zw7.lol
  68. // @connect chatforai.store
  69. // @connect aifree.site
  70. // @connect ai5.wuguokai.top
  71. // @connect chat.aidutu.cn
  72. // @connect aichat.leiluan.cc
  73. // @connect chat.gptservice.xyz
  74. // @connect promplate.dev
  75. // @connect ai.ls
  76. // @connect letsearches.com
  77. // @connect powerchat.top
  78. // @connect wobcw.com
  79. // @connect chat.68686.ltd
  80. // @connect qianwen.biz.aliyun.com
  81. // @connect t-chat.cn
  82. // @connect free.anzz.top
  83. // @connect chat.ohtoai.com
  84. // @connect freeopenai.xyz
  85. // @connect supremes.pro
  86. // @connect onrender.com
  87. // @connect free-chat.asia
  88. // @connect chat7.aifks001.online
  89. // @connect a0.chat
  90. // @connect chatgpt.com
  91. // @connect www.ftcl.store
  92. // @connect sunls.me
  93. // @connect chat.bushiai.com
  94. // @connect chatgpt.qdymys.cn
  95. // @connect pp2pdf.com
  96. // @connect api.aichatos.cloud
  97. // @connect binjie.fun
  98. // @connect ai.fakeopen.com
  99. // @connect chat2.wuguokai.cn
  100. // @connect www.gtpcleandx.xyz
  101. // @connect gpt.esojourn.org
  102. // @connect free-api.cveoy.top
  103. // @connect chatcleand.xyz
  104. // @connect gptforlove.com
  105. // @connect xcbl.cc
  106. // @connect hz-it-dev.com
  107. // @connect 6bbs.cn
  108. // @connect toyaml.com
  109. // @connect 38.47.97.76
  110. // @connect lbb.ai
  111. // @connect lovebaby.today
  112. // @connect gamejx.cn
  113. // @connect chat86.cn
  114. // @connect ai001.live
  115. // @connect ai003.live
  116. // @connect ai006.live
  117. // @connect promptboom.com
  118. // @connect hehanwang.com
  119. // @connect caipacity.com
  120. // @connect chatzhang.top
  121. // @connect 51mskd.com
  122. // @connect forwardminded.xyz
  123. // @connect 1chat.cc
  124. // @connect api.minimax.chat
  125. // @connect cytsee.com
  126. // @connect skybyte.me
  127. // @connect alllinkai1.com
  128. // @connect baidu.com
  129. // @connect scnet.cn
  130. // @connect chatgptdddd.com
  131. // @connect anfans.cn
  132. // @connect bing.com
  133. // @connect openai.com
  134. // @connect generativelanguage.googleapis.com
  135. // @connect tongyi.aliyun.com
  136. // @connect qianwen.aliyun.com
  137. // @connect yuxin-ai.com
  138. // @connect xinghuo.xfyun.cn
  139. // @connect geetest.com
  140. // @connect neice.tiangong.cn
  141. // @connect chat.tiangong.cn
  142. // @connect work.tiangong.cn
  143. // @connect yeyu2048.xyz
  144. // @connect chatglm.cn
  145. // @connect open.bigmodel.cn
  146. // @connect gptgo.ai
  147. // @connect chat.360.cn
  148. // @connect mixerbox.com
  149. // @connect ohmygpt.com
  150. // @connect muspimerol.site
  151. // @connect frechat.xyz
  152. // @compatible Chrome
  153. // @compatible Firefox
  154. // @license MIT
  155. // @website https://yeyu2048.xyz/gpt.html
  156.  
  157. // ==/UserScript==
  158.  
  159. // import {
  160. // GM_registerMenuCommand,GM_openInTab,GM_xmlhttpRequest,GM_setValue,GM_getValue,
  161. // GM_setClipboard,GM_addStyle
  162. // } from "../jslib/tampermonkey";
  163. (function () {
  164. 'use strict';
  165.  
  166.  
  167. const JSver = '3.6.6';
  168.  
  169.  
  170. function getGPTMode() {
  171. return localStorage.getItem("GPTMODE");
  172. }
  173.  
  174. let darkTheme = localStorage.getItem("darkTheme")
  175. console.log(darkTheme)
  176.  
  177. //katex Css
  178. try {
  179. GM_addStyle(GM_getResourceText("katexCss"))
  180. }catch (e) {}
  181.  
  182. //toastr css
  183. try {
  184. GM_addStyle(GM_getResourceText("toastCss"))
  185. }catch (e) {}
  186.  
  187.  
  188.  
  189. //(prefers-color-scheme: light)
  190. function addHeadCss() {
  191. if(!document.getElementById("github-markdown-link")){
  192. if(!darkTheme) {
  193. //暗黑
  194. $("head").append($(
  195. '<link id="github-markdown-link" rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/github-markdown-css/5.2.0/github-markdown-dark.min.css">'
  196. ));
  197. }else{
  198. $("head").append($(
  199. '<link id="github-markdown-link" rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/github-markdown-css/5.2.0/github-markdown-light.min.css">'
  200. ));
  201. }
  202.  
  203. }
  204. if(!document.getElementById("highlight-link")){
  205. if(!darkTheme) {
  206. //暗黑
  207. $("head").append($(
  208. '<link id="highlight-link" rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/highlight.js/11.7.0/styles/monokai-sublime.min.css">'
  209. ));
  210. }else{
  211. $("head").append($(
  212. '<link id="highlight-link" rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/highlight.js/11.7.0/styles/atom-one-light.min.css">'
  213. ));
  214. }
  215.  
  216. }
  217.  
  218. //spark-js
  219. if(!document.getElementById("spark-js")){
  220. $("head").append($(
  221. '<script id="spark-js" src="https://static.geetest.com/g5/gd.js"></script>'
  222. ));
  223. }
  224.  
  225. }
  226. setTimeout(addHeadCss)
  227. setInterval(addHeadCss,5000)
  228.  
  229.  
  230.  
  231.  
  232. try {
  233. console.log(
  234. `%cchatGPT tools Plus${JSver} 已加载`,
  235. 'color: yellow;font-size: large;font-weight: bold;background-color: darkblue;'
  236. );
  237. const menu_updateChat_id = GM_registerMenuCommand("更新Chat", function (event) {
  238. GM_openInTab("https://gf.qytechs.cn/zh-CN/scripts/459997")
  239. }, "updateChat");
  240. const menu_groupNum_id = GM_registerMenuCommand("交流群", function (event) {
  241. Toast.info("交流群7:817298021\n交流群6:792365186\n交流群4:745163513\n交流群3:177193765\n交流群2:734403992\n交流群1:710808464\n交流总群:249733992",
  242. "QQ交流群", {timeOut: 15000} )
  243. }, "groupNum");
  244.  
  245. const menu_pubkey_id = GM_registerMenuCommand("更新key", function (event) {
  246. Toast.info("正在更新...")
  247. setPubkey();
  248. }, "PUBKEY");
  249.  
  250. //禁用console 未转义警告
  251. hljs.configure({
  252. ignoreUnescapedHTML: true
  253. })
  254.  
  255. //toastr配置
  256. toastr.options = {
  257. // "closeButton": false,
  258. // "debug": false,
  259. // "newestOnTop": false,
  260. // "progressBar": false,
  261. "positionClass": "toast-top-right", // 提示框位置,这里填类名
  262. // "preventDuplicates": false,
  263. // "onclick": null,
  264. "showDuration": "300", // 提示框渐显所用时间
  265. "hideDuration": "300", // 提示框隐藏渐隐时间
  266. "timeOut": "3000", // 提示框持续时间
  267. "extendedTimeOut": "1000",
  268. "showEasing": "swing",
  269. "hideEasing": "linear",
  270. "showMethod": "fadeIn",
  271. "hideMethod": "fadeOut"
  272. }
  273.  
  274.  
  275. } catch (ex) {
  276. console.error(ex)
  277. }
  278.  
  279. //toastr 封装 ----start----
  280. const Toast = {
  281.  
  282. warn: function(msg, title, options) {
  283. try {
  284. toastr.warning(msg, title, options)
  285. }catch (e) {}
  286. },
  287. info: function(msg, title, options) {
  288. try {
  289. toastr.info(msg, title, options)
  290. }catch (e) {}
  291. },
  292. success: function(msg, title, options) {
  293. try {
  294. toastr.success(msg, title, options)
  295. }catch (e) {}
  296. },
  297. error: function(msg, title, options) {
  298. try {
  299. toastr.error(msg, title, options)
  300. }catch (e) {}
  301. },
  302. };
  303.  
  304. //toastr 封装 ----end----
  305.  
  306. //封装GM_xmlhttpRequest ---start---
  307. async function GM_fetch(details) {
  308. return new Promise((resolve, reject) =>{
  309. switch (details.responseType){
  310. case "stream":
  311. details.onloadstart = (res)=>{
  312. resolve(res)
  313. }
  314. break;
  315. default:
  316. details.onload = (res)=>{
  317. resolve(res)
  318. };
  319. }
  320.  
  321. details.onerror = (res)=>{
  322. reject(res)
  323. };
  324. details.ontimeout = (res)=>{
  325. reject(res)
  326. };
  327. details.onabort = (res)=>{
  328. reject(res)
  329. };
  330.  
  331. //中断支持
  332. if(details.responseType === "stream"){
  333. abortXml = GM_xmlhttpRequest(details)
  334. }else{
  335. GM_xmlhttpRequest(details)
  336. }
  337.  
  338. });
  339. }
  340.  
  341. function GM_httpRequest(details, callBack, errorCallback, timeoutCallback, abortCallback){
  342. if(callBack){
  343. switch (details.responseType){
  344. case "stream":
  345. details.onloadstart = callBack;
  346. break;
  347. default:
  348. details.onload = callBack
  349. }
  350. }
  351. if(errorCallback){
  352. details.onerror = errorCallback;
  353. }
  354. if(timeoutCallback){
  355. details.ontimeout = timeoutCallback;
  356. }
  357. if(abortCallback){
  358. details.onabort = abortCallback;
  359. }
  360. console.log(details)
  361. //中断支持
  362. if(details.responseType === "stream"){
  363. abortXml = GM_xmlhttpRequest(details)
  364. }else{
  365. GM_xmlhttpRequest(details)
  366. }
  367. }
  368.  
  369. //封装GM_xmlhttpRequest ---end---
  370.  
  371.  
  372. //is TM
  373. function isTM(){
  374. try{
  375. if(/Tampermonkey/gi.test(GM_info.scriptHandler)){
  376. return true;
  377. }else{
  378. return false;
  379. }
  380. }catch (e) {
  381. return false;
  382. }
  383. }
  384.  
  385. //获取chrome版本
  386. function getChromeVersion() {
  387. try {
  388. const brands = navigator.userAgentData.brands
  389. for (let i = 0; i < brands.length; i++) {
  390. if(/Chromium/gi.test(brand[i].brand )){
  391. return Number(brand[i].version)
  392. }
  393. }
  394. }catch (e) {
  395. return 0
  396. }
  397. return 0
  398. }
  399.  
  400. const generateRandomIP = () => {
  401. const ip = [];
  402. for (let i = 0; i < 4; i++) {
  403. ip.push(Math.floor(Math.random() * 256));
  404. }
  405. console.log(ip.join('.'))
  406. return ip.join('.');
  407. }
  408.  
  409.  
  410. //动态pubkey
  411. function setPubkey() {
  412. let GPTMODE = getGPTMode()
  413. if(GPTMODE === "ZhipuAI"){
  414. localStorage.removeItem("ZhipuapiKey")
  415. let manualInput = confirm("请输入你自己的apiKey");
  416. if (manualInput) {
  417. let ZhipuapiKey = prompt("请输入您的智谱apikey", "");
  418. if (ZhipuapiKey) {
  419. localStorage.setItem("ZhipuapiKey", ZhipuapiKey)
  420. zhipu_apiKey = ZhipuapiKey
  421. }
  422. }
  423. }else if(GPTMODE === "Gemini"){
  424. localStorage.removeItem("gemini_key")
  425. let manualInput = confirm("请输入你自己的apiKey");
  426. if (manualInput) {
  427. let gm_key = prompt("请输入您的gemini apikey", "");
  428. if (gm_key) {
  429. localStorage.setItem("gemini_key", gm_key)
  430. gemini_key = gm_key
  431. }
  432. }
  433. }else if(GPTMODE === "miniMax"){
  434.  
  435. localStorage.removeItem("minimax_group_id")
  436. let minimax_group_id_input = prompt("请输入您的minimax_group_id", "");
  437. if (minimax_group_id_input) {
  438. localStorage.setItem("minimax_group_id", minimax_group_id_input)
  439. minimax_group_id = minimax_group_id_input;
  440. }
  441.  
  442. localStorage.removeItem("minimax_api_key")
  443. let minimax_api_key_input = prompt("请输入您的minimax_api_key", "");
  444. if (minimax_api_key_input){
  445. localStorage.setItem("minimax_api_key",minimax_api_key_input)
  446. minimax_api_key = minimax_api_key_input;
  447. }
  448.  
  449. }else {
  450. //Toast.error("该线路不适用")
  451. }
  452.  
  453. }
  454.  
  455.  
  456. //enc-start
  457. async function digestMessage(r) {
  458. const hash = CryptoJS.SHA256(r);
  459. return hash.toString(CryptoJS.enc.Hex);
  460. }
  461.  
  462. const generateSignatureWithPkey = async r => {
  463. const {
  464. t: e,
  465. m: t,
  466. pkey: n
  467. } = r;
  468. console.log("CURRENT KEY:" + n)
  469. const a = `${e}:${t}:${n}`;
  470. return await digestMessage(a);
  471. };
  472.  
  473. let aesKey = "hj6cdzrhj72x8ht1";
  474. const AES_CBC = {
  475.  
  476. encrypt: function(e, t) {
  477. return CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(e), CryptoJS.enc.Utf8.parse(t), {
  478. iv: CryptoJS.enc.Utf8.parse(aesKey),
  479. mode: CryptoJS.mode.CBC
  480. }).toString()
  481. },
  482. decrypt: function(e, t) {
  483. return CryptoJS.AES.decrypt(e, CryptoJS.enc.Utf8.parse(t), {
  484. iv: CryptoJS.enc.Utf8.parse(aesKey),
  485. mode: CryptoJS.mode.CBC
  486. }).toString(CryptoJS.enc.Utf8)
  487. }
  488. };
  489. //enc-end
  490.  
  491. //start
  492.  
  493.  
  494. function addChatBtn() {
  495.  
  496. let mybtn =
  497. `<span class="bg s_btn_wr"><input type="button" id="mybtn" value="加载chat" class="bg s_btn"></span>`;
  498. $(".bg.s_btn_wr").after(mybtn)
  499. document.getElementById("mybtn").addEventListener("click", function () {
  500. console.log("reloadPage")
  501. if (window.location.href.indexOf("baidu.com\/s") > -1) {
  502. GM_add_box_style(2)
  503. addBothStyle()
  504. keyEvent()
  505. appendBox(2).then((res) => {
  506. pivElemAddEventAndValue(2)
  507. })
  508. }
  509. })
  510. }
  511.  
  512. function isMobile() {
  513. let userAgentInfo = navigator.userAgent.toLowerCase();
  514. let mobileAgents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod","Mobile"];
  515. let mobile_flag = false;
  516. //根据userAgent判断是否是手机
  517. for (let v = 0; v < mobileAgents.length; v++) {
  518. if (userAgentInfo.indexOf(mobileAgents[v].toLowerCase()) > -1) {
  519. mobile_flag = true;
  520. break;
  521. }
  522. }
  523. return mobile_flag;
  524. }
  525.  
  526.  
  527. //end
  528.  
  529. const katex_options = {displayMode: false, throwOnError: false}
  530. function toRawText(exp){
  531. //处理html标签
  532. try {
  533. exp = exp.replace(/\&amp;/gi, "&").replace(/<br>/g,"\n").replace(/<br \/>/g,"\n")
  534. .replace(/\&gt;/g,">").replace(/\&lt;/g,"<")
  535. // 处理矩阵
  536. exp = exp.replace(/\\begin\{bmatrix\}(.*?)\\end\{bmatrix\}/g, (_, tex) => {
  537. //debugger
  538. return `\\begin\{bmatrix\}${tex.replace(/\\/g,"\\\\")}\\end\{bmatrix\}`;
  539. })
  540. exp = exp.replace(/\\begin\{pmatrix\}(.*?)\\end\{pmatrix\}/g, (_, tex) => {
  541. //debugger
  542. return `\\begin\{pmatrix\}${tex.replace(/\\/g,"\\\\")}\\end\{pmatrix\}`;
  543. })
  544. }catch (e) { }
  545.  
  546. return exp;
  547. }
  548. function katexTohtml(rawHtml) {
  549. // console.log("========katexTohtml start=======")
  550. let renderedHtml = rawHtml;
  551. try {
  552. renderedHtml = rawHtml.replace(/<em>/g, "").replace(/<\/em>/g, "").replace(/\$\$(.*?)\$\$/g, (_, tex) => {
  553. //debugger
  554. return katex.renderToString(toRawText(tex), katex_options);
  555. });
  556. renderedHtml = renderedHtml.replace(/\$(.*?)\$/g, (_, tex) => {
  557. //debugger
  558. return katex.renderToString(toRawText(tex), katex_options);
  559. });
  560. }catch (ex) {
  561. console.error(ex)
  562. }
  563.  
  564. // console.log("========katexTohtml end=======")
  565. //console.log(renderedHtml)
  566.  
  567. return renderedHtml;
  568. }
  569.  
  570.  
  571.  
  572. let rawAns = undefined;
  573. let isShowRaw = false;
  574. //显示答案并高亮代码函数
  575. function showAnserAndHighlightCodeStr(codeStr) {
  576. if(!codeStr) return
  577. rawAns = codeStr;//记录原文
  578. try {
  579. document.getElementById('gptAnswer').innerHTML = mdConverter(codeStr)
  580. } catch (ex) {
  581. console.error(ex)
  582. }
  583. highlightCodeStr()//高亮
  584. //添加代码复制按钮 start
  585. let preList = document.querySelectorAll("#gptAnswer pre")
  586. preList.forEach((pre)=>{
  587. try{
  588. if(!pre.querySelector(".btn-pre-copy")){
  589. //<span class=\"btn-pre-copy\" onclick='preCopy(this)'>复制代码</span>
  590. let copyBtn = document.createElement("span");
  591. copyBtn.setAttribute("class","btn-pre-copy");
  592. copyBtn.addEventListener("click",(event)=>{
  593. let _this = event.target
  594. console.log(_this)
  595. let pre = _this.parentNode;
  596. console.log(pre.innerText)
  597. _this.innerText = '';
  598. GM_setClipboard(pre.innerText, "text");
  599. _this.innerText = '复制成功'
  600. Toast.success("复制成功!")
  601. setTimeout(() =>{
  602. _this.innerText = '复制代码'
  603. },2000)
  604. })
  605. copyBtn.innerText = '复制代码'
  606. pre.insertBefore(copyBtn, pre.firstChild)
  607. }
  608. }catch (e) {
  609. console.log(e)
  610. }
  611. })
  612. //添加代码复制按钮 end
  613. }
  614.  
  615. //高亮代码函数
  616. function highlightCodeStr() {
  617. let gptAnswerDiv = document.querySelector("#gptAnswer");
  618. gptAnswerDiv.querySelectorAll('pre code').forEach((el) => {
  619. hljs.highlightElement(el);
  620. });
  621. }
  622.  
  623. //顶级配置
  624. let webSessionId
  625. let autoClick = localStorage.getItem("autoClick")
  626. let autoTips = localStorage.getItem("autoTips")? localStorage.getItem("autoTips") :'on';
  627. let isFullScreen = false;
  628. let your_qus;
  629. let abortXml;
  630. let regx = /search.*?\.cf/g;
  631. if (window.location.href.indexOf("bing.com") > -1) {
  632.  
  633. GM_add_box_style(0)
  634. addBothStyle()
  635. keyEvent()
  636. appendBox(0).then((res) => {
  637. pivElemAddEventAndValue(0)
  638. })
  639. //linkToBing_beautification_script()
  640. }
  641. if (window.location.href.indexOf("google.com") > -1 || window.location.href.match(regx)) {
  642. GM_add_box_style(1)
  643. addBothStyle()
  644. keyEvent()
  645. appendBox(1).then((res) => {
  646. if(isMobile()){
  647. pivElemAddEventAndValue(11)
  648. }else {
  649. pivElemAddEventAndValue(1)
  650. }
  651. })
  652. }
  653. if (window.location.href.indexOf("baidu.com\/s") > -1 && !isMobile()) {
  654. GM_add_box_style(2)
  655. addBothStyle()
  656. keyEvent()
  657. appendBox(2).then((res) => {
  658. pivElemAddEventAndValue(2)
  659. })
  660. } else if (window.location.href.indexOf("https:\/\/m.baidu.com") > -1 || (window.location.href.indexOf(
  661. "baidu.com") > -1 && isMobile())) { //手机百度
  662. GM_add_box_style(2)
  663. addBothStyle()
  664. keyEvent()
  665. appendBox(6).then((res) => {
  666. pivElemAddEventAndValue(2)
  667. })
  668. }
  669. //俄罗斯yandex
  670. if (window.location.href.indexOf("yandex.ru\/search") > -1 || window.location.href.indexOf(
  671. "yandex.com\/search") > -1) {
  672. GM_add_box_style(1)
  673. addBothStyle()
  674. keyEvent()
  675. appendBox(3).then((res) => {
  676. pivElemAddEventAndValue(3)
  677. })
  678. }
  679.  
  680. //360so
  681. if (window.location.href.indexOf("so.com\/s") > -1) {
  682. GM_add_box_style(1)
  683. addBothStyle()
  684. keyEvent()
  685. appendBox(4).then((res) => {
  686. if(isMobile()){
  687. pivElemAddEventAndValue(9)
  688. }else {
  689. pivElemAddEventAndValue(4)
  690. }
  691. })
  692. }
  693.  
  694. //fsoufsou
  695. if (window.location.href.indexOf("fsoufsou.com\/search") > -1) {
  696. setTimeout(() => {
  697. GM_add_box_style(1)
  698. addBothStyle()
  699. keyEvent()
  700. appendBox(5).then((res) => {
  701. pivElemAddEventAndValue(5)
  702. })
  703. }, 3000)
  704. }
  705.  
  706. //duckduckgo.com
  707. if (window.location.href.indexOf("duckduckgo.com\/\?q") > -1) {
  708. GM_add_box_style(1)
  709. addBothStyle()
  710. keyEvent()
  711. appendBox(7).then((res) => {
  712. pivElemAddEventAndValue(7)
  713. })
  714. }
  715.  
  716. //sogou.com
  717. if (window.location.href.indexOf("sogou.com") > -1) {
  718. GM_add_box_style(1)
  719. addBothStyle()
  720. keyEvent()
  721. appendBox(8).then((res) => {
  722. if(isMobile()){
  723. pivElemAddEventAndValue(10)
  724. }else{
  725. pivElemAddEventAndValue(8)
  726. }
  727. })
  728. }
  729.  
  730. //bilibili.com
  731. if (window.location.href.includes("bilibili.com")) {
  732. GM_add_box_style(1)
  733. addBothStyle()
  734. keyEvent()
  735. appendBox(9).then((res) => {
  736. pivElemAddEventAndValue(null)
  737. })
  738. }
  739.  
  740.  
  741. //csdn
  742. if (window.location.href.includes("blog.csdn.net")) {
  743. GM_add_box_style(1)
  744. addBothStyle()
  745. keyEvent()
  746. appendBox(10).then((res) => {
  747. pivElemAddEventAndValue(null)
  748. document.getElementById('hideGptDiv').click()
  749. })
  750. }
  751.  
  752. //顶级函数
  753. function uuid() { //uuid 产生
  754. let s = [];
  755. let hexDigits = "0123456789abcdef";
  756. for (let i = 0; i < 36; i++) {
  757. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  758. }
  759. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  760. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  761. s[8] = s[13] = s[18] = s[23] = "-";
  762.  
  763. return s.join("");
  764. }
  765.  
  766. function GM_add_box_style(case_web) {
  767. case_web = 2;
  768. switch (case_web) {
  769. case 2:
  770. GM_addStyle(`
  771. #gptAnswer{
  772. margin: 10px;
  773. border-top: solid;
  774. border-bottom: solid;
  775. }
  776. #gptInput{
  777. border-radius: 20px;
  778. flex: 1;
  779. padding-left: 10px;
  780. height: 35px;
  781. border:0;
  782. background-color: transparent;
  783. font-size: 15px;
  784. font-weight: 500;
  785. }
  786. #button_GPT:hover{
  787. cursor: pointer;
  788. }
  789. #gptDiv{
  790. width:452px;
  791. flex: 1;
  792. display: flex;
  793. flex-direction: column;
  794. height: fit-content;
  795. }
  796. #gptInputBox{
  797. display:flex;
  798. justify-content: space-around;
  799. border-radius: 20px;
  800. border: 1px solid #c4c7ce;
  801. margin-left: 10px;
  802. }
  803. #button_GPT{
  804. border: 0;
  805. background-color: transparent;
  806. font-size: 14px;
  807. padding: 5px;
  808. }
  809. #gptStatus{
  810. margin-left: 10px;
  811. }
  812. #modeSelect {
  813. border: 1px solid #c4c7ce;
  814. border-radius: 10px;
  815. margin: 3px;
  816. text-align: center;
  817. color: RGB(193,73,55);
  818. -webkit-appearance: none;
  819. }
  820. #modeSelect::-webkit-scrollbar {
  821. width: 8px; /* 滚动条宽度 */
  822. }
  823. #modeSelect::-webkit-scrollbar-thumb {
  824. background-color: #888; /* 滚动条颜色 */
  825. border-radius: 4px; /* 滚动条圆角 */
  826. }
  827. #modeSelect::-webkit-scrollbar-thumb:hover {
  828. background-color: #555; /* 滚动条悬停时颜色 */
  829. }
  830. #modeSelect::-webkit-scrollbar-track {
  831. background-color: #f1f1f1; /* 滚动条背景色 */
  832. border-radius: 4px; /* 滚动条背景圆角 */
  833. }
  834. .chatSetting{
  835. display: block;
  836. text-align: right;
  837. margin-top: 10px;
  838. margin-right: 8px;
  839. margin-bottom: 1px;
  840. }
  841. .chatHide{
  842. display: none;
  843. }
  844. #chatSetting{
  845. text-decoration: none !important;
  846. }
  847. #chatSetting:hover{
  848. cursor: pointer;
  849. text-decoration: underline !important;
  850. }
  851. #website a:nth-child(odd){
  852. color: #ffbb00;
  853. }
  854. #website a:nth-child(even){
  855. color: #0bbbac;
  856. }
  857. #website a {
  858. border: 1px solid;
  859. border-radius: 3px;
  860. margin-right: 9px;
  861. margin-bottom: 5px;
  862. }
  863. #website hr {
  864. border: none;
  865. border-top: 1px dashed #999;
  866. margin: 5px 0px 5px 0px;
  867. }
  868.  
  869. gptDiv p{
  870. white-space: pre-line;
  871. }
  872. pre .btn-pre-copy{
  873. text-align: right;
  874. display: block;
  875. }
  876. pre .btn-pre-copy:hover{
  877. cursor: pointer;
  878. }
  879. .fullScreen{
  880. z-index: 999 !important;
  881. position: fixed !important;
  882. top: 0 !important;
  883. left: 0 !important;
  884. right: 0 !important;
  885. width: 100% !important;
  886. height: 100% !important;
  887. bottom: 0 !important;
  888. overflow-y: scroll !important;
  889. }
  890. .bgtransparent{
  891. background-color: transparent !important;
  892. }
  893. .floating-button {
  894. position: fixed;
  895. bottom: 20px;
  896. right: 20px;
  897. background-color: #007bff;
  898. color: #fff;
  899. border-radius: 50%;
  900. padding: 10px;
  901. box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.25);
  902. z-index: 9999 !important;
  903. }
  904.  
  905. .floating-button a {
  906. text-decoration: none;
  907. color: inherit;
  908. z-index: 9999 !important;
  909. }
  910. /* fix bilibili高级弹幕背景问题 */
  911. #bilibili-player pre {
  912. background-color: transparent !important;
  913. overflow-x: hidden; !important;
  914. overflow-y: hidden; !important;
  915. }
  916. `)
  917. break;
  918. default:
  919. Toast.error("参数没设定")
  920. }
  921.  
  922. }
  923.  
  924. function do_it() {
  925.  
  926. isShowRaw = false; //设置显示原文
  927. rawAns = undefined;//设置显示原文
  928.  
  929. document.getElementById('gptAnswer').innerHTML = `<div>加载中<span id="dot"></span></div>`;
  930. //自定义模式
  931. let GPTMODE = getGPTMode()
  932. if (GPTMODE && GPTMODE === "YeYu") {
  933. console.log("当前模YeYu")
  934. //YeYu()
  935. //end if
  936. return;
  937. } else if (GPTMODE && GPTMODE === "THEBAI") {
  938. console.log("当前模式XJAI")
  939. THEBAI()
  940. //end if
  941. return;
  942. } else if (GPTMODE && GPTMODE === "YQCLOUD") {
  943. console.log("当前模式YQCLOUD")
  944. YQCLOUD()
  945. //end if
  946. return;
  947. } else if (GPTMODE && GPTMODE === "TDCHAT") {
  948. console.log("当前模式TDCHAT")
  949. TDCHAT()
  950. //end if
  951. return;
  952. } else if (GPTMODE && GPTMODE === "AILS") {
  953.  
  954. console.log("AILS")
  955. AILS()
  956.  
  957. return;
  958. //end if
  959. } else if (GPTMODE && GPTMODE === "CVEOY") {
  960. console.log("CVEOY")
  961. CVEOY();
  962.  
  963. return;
  964. //end if
  965. }else if (GPTMODE && GPTMODE === "TOYAML") {
  966. console.log("TOYAML")
  967. TOYAML();
  968.  
  969. return;
  970. //end if
  971. }else if (GPTMODE && GPTMODE === "newBing") {
  972. console.log("newBing")
  973. newBing();
  974.  
  975. return;
  976. //end if
  977. }else if (GPTMODE && GPTMODE === "AIFREE") {
  978. console.log("AIFREE")
  979. AIFREE();
  980.  
  981. return;
  982. //end if
  983. }else if (GPTMODE && GPTMODE === "OPENAI" || GPTMODE === "OPENAI-3.5") {
  984. console.log("OPENAI-3.5")
  985. OPENAI("text-davinci-002-render-sha")
  986.  
  987. return;
  988. //end if
  989. }else if (GPTMODE && GPTMODE === "Gemini") {
  990. console.log("Gemini")
  991. Gemini()
  992.  
  993. return;
  994. //end if
  995. }else if (GPTMODE && GPTMODE === "TONGYI") {
  996. console.log("TONGYI")
  997. TONGYI()
  998.  
  999. return;
  1000. //end if
  1001. }else if (GPTMODE && GPTMODE === "SPARK") {
  1002. console.log("SPARK")
  1003. SPARK()
  1004.  
  1005. return;
  1006. //end if
  1007. }else if (GPTMODE && GPTMODE === "TIANGONG") {
  1008. console.log("TIANGONG")
  1009. TIANGONG()
  1010.  
  1011. return;
  1012. //end if
  1013. }else if (GPTMODE && GPTMODE === "Hunyuan") {
  1014. console.log("Hunyuan")
  1015. Hunyuan('')
  1016.  
  1017. return;
  1018. //end if
  1019. }else if (GPTMODE && GPTMODE === "DeepSeekYuanBao") {
  1020. console.log("DeepSeekYuanBao")
  1021. Hunyuan('deepseek')
  1022.  
  1023. return;
  1024. //end if
  1025. }else if (GPTMODE && GPTMODE === "YIYAN") {
  1026. console.log("YIYAN")
  1027. YIYAN()
  1028.  
  1029. return;
  1030. //end if
  1031. }else if (GPTMODE && GPTMODE === "DeepSeek") {
  1032. console.log("DeepSeek")
  1033. DeepSeek()
  1034.  
  1035. return;
  1036. //end if
  1037. }else if (GPTMODE && GPTMODE === "ChatGLM") {
  1038. console.log("ChatGLM")
  1039. ChatGLM()
  1040.  
  1041. return;
  1042. //end if
  1043. }else if (GPTMODE && GPTMODE === "ChatGLM4") {
  1044. console.log("ChatGLM4")
  1045. ChatGLM4()
  1046.  
  1047. return;
  1048. //end if
  1049. }else if (GPTMODE && GPTMODE === "ZhipuAI") {
  1050. console.log("ZhipuAI")
  1051. ZhipuAI()
  1052.  
  1053. return;
  1054. //end if
  1055. }else if (GPTMODE && GPTMODE === "chatforai") {
  1056. console.log("chatforai")
  1057. chatforai()
  1058.  
  1059. return;
  1060. //end if
  1061. }else if (GPTMODE && GPTMODE === "Zhinao360") {
  1062. console.log("Zhinao360")
  1063. Zhinao360()
  1064.  
  1065. return;
  1066. //end if
  1067. }else if (GPTMODE && GPTMODE === "BAICHUAN") {
  1068. console.log("BAICHUAN")
  1069. BAICHUAN()
  1070.  
  1071. return;
  1072. //end if
  1073. }else if (GPTMODE && GPTMODE === "MixerBox") {
  1074. console.log("MixerBox")
  1075. MixerBox()
  1076.  
  1077. return;
  1078. //end if
  1079. }else if (GPTMODE && GPTMODE === "miniMax") {
  1080. console.log("miniMax")
  1081. miniMax()
  1082.  
  1083. return;
  1084. //end if
  1085. }
  1086.  
  1087. console.log("默认线路:")
  1088. AIFREE()
  1089.  
  1090. }
  1091.  
  1092.  
  1093.  
  1094. function creatBox() {
  1095. return new Promise((resolve) => {
  1096. let divE = document.createElement('div');
  1097. let divId = document.createAttribute("id"); //创建属性
  1098. divId.value = 'gptDiv'; //设置属性值
  1099. divE.setAttributeNode(divId); //给div添加属性
  1100. let pE = document.createElement('p');
  1101. let pClass = document.createAttribute('class');
  1102. pClass.value = 'textClass';
  1103. pE.setAttributeNode(pClass)
  1104. let pText = document.createTextNode("");
  1105. pE.appendChild(pText);
  1106. divE.appendChild(pE);
  1107. divE.classList.add("gpt-container");
  1108. divE.classList.add("markdown-body");
  1109. divE.innerHTML = `
  1110. <div id="gptInputBox">
  1111. <input autocomplete="off" placeholder="若用不了,请更新KEY或切换线路" id="gptInput" list="suggestions" type=text><button id="button_GPT" ><svg width="15px" height="15px" focusable="false" viewBox="0 0 24 24"><path fill="#34a853" d="M10 2v2a6 6 0 0 1 6 6h2a8 8 0 0 0-8-8"></path><path fill="#ea4335" d="M10 4V2a8 8 0 0 0-8 8h2c0-3.3 2.7-6 6-6"></path><path fill="#fbbc04" d="M4 10H2a8 8 0 0 0 8 8v-2c-3.3 0-6-2.69-6-6"></path><path fill="#4285f4" d="M22 20.59l-5.69-5.69A7.96 7.96 0 0 0 18 10h-2a6 6 0 0 1-6 6v2c1.85 0 3.52-.64 4.88-1.68l5.69 5.69L22 20.59"></path></svg>搜索</button>
  1112. <datalist id="suggestions">
  1113. </datalist>
  1114. </div>
  1115. <div class="chatSetting"><a id="chatSetting"><svg fill="#909399" width="15px" height="15px" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13.85 22.25h-3.7c-.74 0-1.36-.54-1.45-1.27l-.27-1.89c-.27-.14-.53-.29-.79-.46l-1.8.72c-.7.26-1.47-.03-1.81-.65L2.2 15.53c-.35-.66-.2-1.44.36-1.88l1.53-1.19c-.01-.15-.02-.3-.02-.46 0-.15.01-.31.02-.46l-1.52-1.19c-.59-.45-.74-1.26-.37-1.88l1.85-3.19c.34-.62 1.11-.9 1.79-.63l1.81.73c.26-.17.52-.32.78-.46l.27-1.91c.09-.7.71-1.25 1.44-1.25h3.7c.74 0 1.36.54 1.45 1.27l.27 1.89c.27.14.53.29.79.46l1.8-.72c.71-.26 1.48.03 1.82.65l1.84 3.18c.36.66.2 1.44-.36 1.88l-1.52 1.19c.01.15.02.3.02.46s-.01.31-.02.46l1.52 1.19c.56.45.72 1.23.37 1.86l-1.86 3.22c-.34.62-1.11.9-1.8.63l-1.8-.72c-.26.17-.52.32-.78.46l-.27 1.91c-.1.68-.72 1.22-1.46 1.22zm-3.23-2h2.76l.37-2.55.53-.22c.44-.18.88-.44 1.34-.78l.45-.34 2.38.96 1.38-2.4-2.03-1.58.07-.56c.03-.26.06-.51.06-.78s-.03-.53-.06-.78l-.07-.56 2.03-1.58-1.39-2.4-2.39.96-.45-.35c-.42-.32-.87-.58-1.33-.77l-.52-.22-.37-2.55h-2.76l-.37 2.55-.53.21c-.44.19-.88.44-1.34.79l-.45.33-2.38-.95-1.39 2.39 2.03 1.58-.07.56a7 7 0 0 0-.06.79c0 .26.02.53.06.78l.07.56-2.03 1.58 1.38 2.4 2.39-.96.45.35c.43.33.86.58 1.33.77l.53.22.38 2.55z"></path><circle cx="12" cy="12" r="3.5" fill="#909399"></circle></svg>设置</a></div>
  1116. <div id=gptCueBox>
  1117. <p class="chatHide" id="gptStatus">
  1118. <select id="modeSelect">
  1119. <option value="Default">默认接口</option>
  1120. <option style="display: none" value="newBing">New Bing</option>
  1121. <option style="display: none" value="OPENAI-3.5">OPENAI-3.5</option>
  1122. <option value="Gemini">Gemini-2.0</option>
  1123. <option value="DeepSeek">DeepSeek(满血)</option>
  1124. <option value="TONGYI">通义千问</option>
  1125. <option value="YIYAN">百度文心</option>
  1126. <option value="SPARK">讯飞星火</option>
  1127. <option value="TIANGONG">天工AI</option>
  1128. <option value="Hunyuan">腾讯元宝</option>
  1129. <option value="DeepSeekYuanBao">腾讯Deepseek(联网)</option>
  1130. <option value="ChatGLM">ChatGLM</option>
  1131. <option value="ChatGLM4">ChatGLM4</option>
  1132. <option value="ZhipuAI">智谱AI</option>
  1133. <option value="Zhinao360">360智脑</option>
  1134. <option value="BAICHUAN">百川AI</option>
  1135. <option value="miniMax">miniMax</option>
  1136. <option value="AIFREE">AIFREE</option>
  1137. <option value="chatforai">chatforai</option>
  1138. <option value="MixerBox">MixerBox</option>
  1139. <option style="display: none" value="THEBAI">XJAI</option>
  1140. <option value="YQCLOUD">YQCLOUD</option>
  1141. <option value="TDCHAT">TDCHAT</option>
  1142. <option value="AILS">AILS</option>
  1143. <option value="CVEOY">CVEOY</option>
  1144. <option value="TOYAML">TOYAML</option>
  1145. </select> 部分线路需要科学上网</p>
  1146. <p class="chatHide" id="warn" style="margin: 10px" ><a id="updatePubkey" style="color: #4e6ef2;" href="javascript:void(0)"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class=" iconify iconify--ri" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795Z"></path></svg>更新KEY</a>:适用于自定义、智谱、Gemini</p>
  1147. <p class="chatHide" id="autoClickP" style="margin: 10px" ><a id="autoClick" style="color: #4e6ef2;" href="javascript:void(0)"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="text-lg iconify iconify--ri" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M15 4H5v16h14V8h-4V4ZM3 2.992C3 2.444 3.447 2 3.998 2H16l5 5v13.992A1 1 0 0 1 20.007 22H3.993A1 1 0 0 1 3 21.008V2.992Zm9 8.508a2.5 2.5 0 1 1 0-5a2.5 2.5 0 0 1 0 5ZM7.527 17a4.5 4.5 0 0 1 8.945 0H7.527Z"></path></svg>自动点击开关</a>:用于设置搜索是否自动点击</p>
  1148. <p class="chatHide" id="darkThemeP" style="margin: 10px" ><a id="darkTheme" style="color: #4e6ef2;" href="javascript:void(0)"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class=" iconify iconify--ri" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M12 21.997c-5.523 0-10-4.478-10-10c0-5.523 4.477-10 10-10s10 4.477 10 10c0 5.522-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16a8 8 0 0 0 0 16Zm0-2v-12a6 6 0 0 1 0 12Z"></path></svg>暗黑模式开关</a>:用于设置暗黑/白天</p>
  1149. <p class="chatHide" id="autoTipsP" style="margin: 10px"><a id="autoTips" href="javascript:void(0)"><svg withd="15" height="15" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  1150. <path d="M12,2c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9S16.97,2,12,2z M12,18c-3.86,0-7-3.14-7-7s3.14-7,7-7s7,3.14,7,7S15.86,18,12,18z" fill="#fff" stroke="#000"></path>
  1151. <circle cx="12" cy="12" r="5" fill="#ffd700"></circle>
  1152. <path d="M12,17v1a1,1,0,0,1-2,0V17" stroke="#000" stroke-linecap="round" stroke-linejoin="round"></path>
  1153. <path d="M13,14.5h-2a.5.5,0,0,1-.5-.5v-1a.5.5,0,0,1,.5-.5h2a.5.5,0,0,1,.5.5v1A.5.5,0,0,1,13,14.5Z" fill="#fff" stroke="#000"></path>
  1154. </svg>自动提示开关</a>:用于设置是否开启提示</p>
  1155. <div class="chatHide" id="website" style="margin-left: 10px; ">
  1156. <hr>
  1157. <a target="_blank" href="https://chat.deepseek.com/">DeepSeek</a>
  1158. <a target="_blank" href="https://yiyan.baidu.com/">文心</a>
  1159. <a target="_blank" href="https://qianwen.aliyun.com/">通义</a>
  1160. <a target="_blank" href="https://www.tiangong.cn/">天工</a>
  1161. <a target="_blank" href="https://xinghuo.xfyun.cn/">讯飞</a>
  1162. <a target="_blank" href="https://hunyuan.tencent.com/">元宝</a>
  1163. <a target="_blank" href="https://www.doubao.com/chat/">豆包</a>
  1164. <hr>
  1165. <a target="_blank" href="https://chatgpt.com">OpenAI</a>
  1166. <a target="_blank" href="https://www.bing.com/search?q=Bing+AI&showconv=1">Bing</a>
  1167. <a target="_blank" href="https://gemini.google.com/app">Gemini</a>
  1168. <a target="_blank" href="https://claude.ai/">Claude</a>
  1169. <a target="_blank" href="https://chatglm.cn/chat">GLM</a>
  1170. <a target="_blank" href="https://www.baichuan-ai.com/">百川</a>
  1171. <hr>
  1172. <a target="_blank" href="https://kimi.moonshot.cn/">Kimi</a>
  1173. <a target="_blank" href="https://chat.360.cn/">360智脑</a>
  1174. <a target="_blank" href="https://chat.sensetime.com/">商量</a>
  1175. <a target="_blank" href="https://poe.com/">Poe</a>
  1176. <a target="_blank" href="https://taichu-web.ia.ac.cn/#/chat">紫东</a>
  1177. <a target="_blank" href="https://chat.deepseek.com/">DeepSeek</a>
  1178. <hr>
  1179. <a target="_blank" href="https://gf.qytechs.cn/scripts/459997">更新</a>
  1180. <a href="https://q1.qlogo.cn/g?b=qq&nk=2471543762&s=640">用爱发电</a>
  1181. <hr>
  1182. </div>
  1183. <article id="gptAnswer" class="markdown-body"><div id="gptAnswer_inner">版本: ${JSver} 已启动,部分线路需要科学上网,更换AI接口请点击"设置"。当前线路: ${getGPTMode() || "Default"};当前自动点击状态: ${localStorage.getItem("autoClick") || "关闭"}</article>
  1184. </div>
  1185. <span class="speak" style="margin-right: 10px;text-align: right">
  1186. <a id="speakAnser" style="cursor: pointer" href="javascript:void(0)" >
  1187. <svg width="20" height="20" viewBox="0 0 17 16">
  1188. <path d="M9 16.5v-9l6 4.5-6 4.5z" fill="#909399"></path>
  1189. <path d="M0 0h24v24H0z" fill="none"></path>
  1190. </svg>朗读</a>
  1191. <a id="copyAns" style="cursor: pointer" href="javascript:void(0)" >
  1192. <svg width="12" height="12" data-v-13fede38="" t="1679666016648" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6241" class="icon"><path data-v-13fede38="" d="M661.333333 234.666667A64 64 0 0 1 725.333333 298.666667v597.333333a64 64 0 0 1-64 64h-469.333333A64 64 0 0 1 128 896V298.666667a64 64 0 0 1 64-64z m-21.333333 85.333333H213.333333v554.666667h426.666667v-554.666667z m191.829333-256a64 64 0 0 1 63.744 57.856l0.256 6.144v575.701333a42.666667 42.666667 0 0 1-85.034666 4.992l-0.298667-4.992V149.333333H384a42.666667 42.666667 0 0 1-42.368-37.674666L341.333333 106.666667a42.666667 42.666667 0 0 1 37.674667-42.368L384 64h447.829333z" fill="#909399" p-id="6242"></path></svg>
  1193. 复制</a>
  1194. <a id="rawAns" style="cursor: pointer" href="javascript:void(0)" >
  1195. <svg width="13" height="13" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  1196. <circle cx="12" cy="12" r="8" stroke="#909399" stroke-width="4" fill="none"></circle>
  1197. </svg>原文</a>
  1198. <a id="stopAns" style="cursor: pointer" href="javascript:void(0)">
  1199. <svg width="13" height="13" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  1200. <path fill="#909399" d="M12 2c-5.5 0-10 4.5-10 10s4.5 10 10 10 10-4.5 10-10-4.5-10-10-10zm6.7 15.3c-.2.2-.5.2-.7 0L12 12.7l-6.1 4.6c-.2.2-.5.2-.7 0-.2-.2-.2-.5 0-.7l6.1-4.6-6.1-4.6c-.2-.2-.2-.5 0-.7s.5-.2.7 0L12 11.3l6.1-4.6c.2-.2.5-.2.7 0 .2.2.2.5 0 .7l-6.1 4.6 6.1 4.6c.2.2.2.5 0 .7z"></path>
  1201. </svg>中断</a>
  1202. <a id="fullScreen" style="cursor: pointer" href="javascript:void(0)">
  1203. <svg width="13" height="13" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  1204. <rect x="3" y="4" width="18" height="14" rx="2" ry="2" stroke="black" fill="#909399"/>
  1205. <line x1="3" y1="8" x2="21" y2="8" stroke="black" stroke-width="2"/>
  1206. <line x1="3" y1="16" x2="21" y2="16" stroke="black" stroke-width="2"/>
  1207. </svg>全屏</a>
  1208. <a id="hideGptDiv" style="cursor: pointer" href="javascript:void(0)">
  1209. <svg width="13" height="13" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
  1210. <circle cx="12" cy="12" r="10" fill="#909399"></circle>
  1211. <circle cx="12" cy="12" r="5" fill="#fff"></circle>
  1212. </svg>隐藏</a>
  1213.  
  1214. </span>`;
  1215. resolve(divE)
  1216. })
  1217. }
  1218.  
  1219. let speakAudio;
  1220. let isPlayend = true;
  1221. async function pivElemAddEventAndValue(append_case) {
  1222. let search_content
  1223.  
  1224. try {
  1225. if (append_case === 11) {//手机google
  1226. search_content = document.querySelector("#tsf textarea").value
  1227. }
  1228. if (append_case === 10) {//手机sogou
  1229. search_content = document.querySelector("input#keyword").value
  1230. }
  1231. if (append_case === 9) {//手机360
  1232. search_content = document.querySelector("input#q").value
  1233. }
  1234. if (append_case === 8) {
  1235. search_content = document.querySelector("input#upquery").value
  1236. }
  1237. if (append_case === 7) {
  1238. search_content = document.querySelector("#search_form input").value
  1239. }
  1240. if (append_case === 5) {
  1241. search_content = document.getElementById("search-input").value
  1242. }
  1243.  
  1244. if (append_case === 4) {
  1245. search_content = document.getElementById("keyword").value
  1246. }
  1247.  
  1248. if (append_case === 3) {
  1249. search_content = document.querySelectorAll("input")[0].value
  1250. }
  1251.  
  1252. if (append_case === 2) {
  1253. search_content = document.getElementById('kw').value
  1254. }
  1255. if (append_case === 1) {
  1256. try {
  1257. search_content = document.querySelector(
  1258. "#tsf > div:nth-child(1) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input:nth-child(3)"
  1259. ).value
  1260. } catch (e) {
  1261. search_content = document.querySelector("textarea").value
  1262. }
  1263.  
  1264. }
  1265. if (append_case === 0) {
  1266. search_content = document.getElementsByClassName('b_searchbox')[0].value
  1267. if (!search_content) {
  1268. search_content = document.querySelector("textarea[class='b_searchbox']").value;
  1269. }
  1270. }
  1271. } catch (e) {
  1272. console.log(e)
  1273. }
  1274.  
  1275. document.getElementById("gptInput").value = search_content || ''
  1276. document.getElementById('button_GPT').addEventListener('click', () => {
  1277. your_qus = document.getElementById("gptInput").value
  1278.  
  1279. //字体设置
  1280. if(your_qus.startsWith("/font-size:")){
  1281. let fontSize = your_qus.substring("/font-size:".length)
  1282. document.querySelector("#gptDiv").style.fontSize = fontSize;
  1283. localStorage.setItem("gpt_font_size",fontSize)
  1284. Toast.success(`字体设置成功:${fontSize}`)
  1285. return
  1286. }
  1287.  
  1288. //禁用历史记录
  1289. if(your_qus.startsWith("/history_disable:")){
  1290. let dis = your_qus.substring("/history_disable:".length)
  1291. history_disable = (dis === 'true' ? true : false);
  1292. localStorage.setItem("history_disable", dis)
  1293. Toast.success(`禁用历史记录设置成功:${history_disable}`)
  1294. return
  1295. }
  1296.  
  1297. do_it()
  1298.  
  1299. })
  1300.  
  1301. //搜索建议
  1302. document.getElementById('gptInput').addEventListener('keyup', () => {
  1303. console.log("autoTips:",autoTips)
  1304. if(autoTips !== 'on') return
  1305.  
  1306. let current;
  1307. let word = document.getElementById('gptInput').value;
  1308. if(!word) return;
  1309. if(current){
  1310. current.abort();
  1311. }
  1312. console.log(word)
  1313. current = GM_xmlhttpRequest({
  1314. method: "GET",
  1315. url: "https://www.baidu.com/sugrec?&prod=pc&wd="+encodeURIComponent(word),
  1316. responseType: "text",
  1317. onload:(r) => {
  1318. //console.log(r)
  1319. if (r.status === 200) {
  1320. //console.log(r);
  1321. let dataList = JSON.parse(r.responseText).g;
  1322. const su = document.querySelector('#suggestions');
  1323. su.innerHTML = '';
  1324. dataList && dataList.forEach(v => {
  1325. const optionElement = document.createElement('option');
  1326. optionElement.value = v.q;
  1327. optionElement.innerText = v.q;
  1328. su.appendChild(optionElement);
  1329. });
  1330. }
  1331.  
  1332. }
  1333. });
  1334. })
  1335.  
  1336. document.getElementById('updatePubkey').addEventListener('click', () => {
  1337. Toast.info("正在更新,请稍后...")
  1338. setPubkey()
  1339. })
  1340.  
  1341. document.getElementById('autoClick').addEventListener('click', () => {
  1342. if(autoClick){
  1343. localStorage.removeItem("autoClick")
  1344. autoClick = undefined;
  1345. Toast.error("自动点击已经关闭")
  1346. }else{
  1347. localStorage.setItem("autoClick", "开启")
  1348. autoClick = "开启"
  1349. Toast.success("自动点击已经开启")
  1350. }
  1351. })
  1352.  
  1353. document.getElementById('autoTips').addEventListener('click', () => {
  1354. if(autoTips === 'on'){
  1355. //关闭
  1356. localStorage.setItem("autoTips", "off")
  1357. autoTips = "off"
  1358. Toast.error("自动提示已关")
  1359. }else{
  1360. //开启
  1361. localStorage.setItem("autoTips", "on")
  1362. autoTips = "on"
  1363. Toast.success("自动提示已开启")
  1364. }
  1365. })
  1366.  
  1367. document.getElementById('darkTheme').addEventListener('click', () => {
  1368. try{
  1369. document.getElementById("github-markdown-link").remove()
  1370. document.getElementById("highlight-link").remove()
  1371. }catch (e) { console.error(e) }
  1372.  
  1373. if(darkTheme){
  1374. localStorage.removeItem("darkTheme")
  1375. darkTheme = undefined;
  1376. Toast.success("暗黑已经开启")
  1377. }else{
  1378. localStorage.setItem("darkTheme", "关闭")
  1379. darkTheme = "关闭"
  1380. Toast.error("暗黑已经关闭")
  1381. }
  1382. })
  1383. //朗读
  1384. document.getElementById('speakAnser').addEventListener('click', () => {
  1385. let ans = document.querySelector("#gptAnswer");
  1386. if(!isPlayend){
  1387. Toast.success('已暂停播放!');
  1388. speakAudio.pause();
  1389. isPlayend = true;
  1390. return;
  1391. }else {
  1392. Toast.warn('音频已停止,正在重新播放!')
  1393. }
  1394. if(ans){
  1395. // let speakText = encodeURIComponent(ans.innerText);
  1396. let speakText = ans.innerText;
  1397.  
  1398. //new sogou api
  1399. // 弹出对话框询问用户是否同意
  1400. const result = confirm("是否启用外国口音朗读? 默认为中文口音。");
  1401. let dialect = "zh-CHS"
  1402. if (result) {
  1403. dialect = "en"
  1404. console.log("英文朗读!");
  1405. }
  1406.  
  1407. let f = JSON.stringify({
  1408. curTime: Date.now(),
  1409. rate: "1",
  1410. spokenDialect: dialect,
  1411. text: speakText
  1412. })
  1413.  
  1414. let sParam = CryptoJS.AES.encrypt(f.replace(/^"|"$/g, ""), CryptoJS.enc.Utf8.parse("76350b1840ff9832eb6244ac6d444366"), {
  1415. "iv": CryptoJS.enc.Utf8.parse(atob("AAAAAAAAAAAAAAAAAAAAAA==") || "76350b1840ff9832eb6244ac6d444366"),
  1416. "mode": CryptoJS.mode.CBC,
  1417. "pad": CryptoJS.pad.Pkcs7
  1418. }).toString();
  1419.  
  1420.  
  1421. speakAudio = new Audio(`https://fanyi.sogou.com/openapi/external/getWebTTS?S-AppId=102356845&S-Param=${encodeURIComponent(sParam)}`);
  1422. speakAudio.play()
  1423. isPlayend = false;
  1424. speakAudio.addEventListener("ended",function() {
  1425. isPlayend = true;
  1426. Toast.success('音频已播放完毕!');
  1427. })
  1428. }
  1429. })
  1430.  
  1431. //原文切换
  1432. document.getElementById('rawAns').addEventListener('click', (ev) => {
  1433. let ans = document.querySelector("#gptAnswer");
  1434. if(!rawAns) {
  1435. Toast.error("原文无内容")
  1436. return
  1437. };
  1438. if(!isShowRaw){
  1439. ans.innerText = rawAns;
  1440. isShowRaw = true;
  1441. Toast.success("已为你显示原文")
  1442. }else{
  1443. showAnserAndHighlightCodeStr(rawAns)
  1444. isShowRaw = false;
  1445. Toast.success("已为你显示非原文")
  1446. }
  1447.  
  1448. })
  1449.  
  1450. //中断回答
  1451. document.getElementById('stopAns').addEventListener('click', (ev) => {
  1452. try{
  1453. if(abortXml){
  1454. abortXml.abort();
  1455. abortXml = undefined;
  1456. }else {
  1457. Toast.error("无法中断!")
  1458. }
  1459. }catch(ex){
  1460. console.error("中断失败:",ex)
  1461. Toast.error("中断失败!")
  1462. }
  1463. })
  1464.  
  1465. //全屏
  1466. document.getElementById('fullScreen').addEventListener('click', (ev) => {
  1467. try{
  1468. if(!isFullScreen){
  1469. document.getElementById("gptDiv").classList.add("fullScreen")
  1470. isFullScreen = true;
  1471. }else {
  1472. document.getElementById("gptDiv").classList.remove("fullScreen")
  1473. isFullScreen = false;
  1474. }
  1475.  
  1476. }catch(ex){
  1477. console.error("ex:",ex)
  1478. Toast.error("未知异常!")
  1479. }
  1480. })
  1481. //隐藏
  1482. document.getElementById('hideGptDiv').addEventListener('click', (ev) => {
  1483. try{
  1484. $("body").append(`<div class="floating-button"><a href="javascript:void(0)">显示</a></div>`)
  1485. $(".floating-button a").click(function() {
  1486. $("#gptDiv").show();
  1487. $(".floating-button").remove()
  1488. });
  1489. $("#gptDiv").hide();
  1490. }catch(ex){
  1491. console.error("ex:",ex)
  1492. Toast.error("未知异常!")
  1493. }
  1494. })
  1495.  
  1496. //复制答案
  1497. document.getElementById('copyAns').addEventListener('click', (ev) => {
  1498. let ans = document.querySelector("#gptAnswer");
  1499. if(isShowRaw){
  1500. GM_setClipboard(rawAns, "text");
  1501. }else{
  1502. let cps = document.querySelectorAll(".btn-pre-copy");
  1503. for (let cp of cps){
  1504. cp.innerText = ''
  1505. }
  1506. GM_setClipboard(ans.innerText, "text");
  1507.  
  1508. for (let cp of cps){
  1509. cp.innerText = '复制代码'
  1510. }
  1511. }
  1512. Toast.success("复制成功!")
  1513. })
  1514.  
  1515. document.getElementById('modeSelect').addEventListener('change', () => {
  1516. const selectEl = document.getElementById('modeSelect');
  1517. const selectedValue = selectEl.options[selectEl.selectedIndex].value;
  1518. localStorage.setItem('GPTMODE', selectedValue);
  1519.  
  1520. Toast.success(`切换成功,当前线路:${selectedValue}`)
  1521. });
  1522.  
  1523. let chatSetting = false;
  1524. document.getElementById('chatSetting').addEventListener('click', () => {
  1525. if(!chatSetting){
  1526. //显示内容
  1527. try{
  1528. document.querySelector("#gptStatus").classList.remove("chatHide")
  1529. document.querySelector("#warn").classList.remove("chatHide")
  1530. document.querySelector("#autoClickP").classList.remove("chatHide")
  1531. document.querySelector("#darkThemeP").classList.remove("chatHide")
  1532. document.querySelector("#website").classList.remove("chatHide")
  1533. document.querySelector("#autoTipsP").classList.remove("chatHide")
  1534. }catch (e) {
  1535. console.log(e)
  1536. }
  1537. chatSetting = true;
  1538. }else{
  1539. //隐藏
  1540. try{
  1541. document.querySelector("#gptStatus").classList.add("chatHide")
  1542. document.querySelector("#warn").classList.add("chatHide")
  1543. document.querySelector("#autoClickP").classList.add("chatHide")
  1544. document.querySelector("#darkThemeP").classList.add("chatHide")
  1545. document.querySelector("#website").classList.add("chatHide")
  1546. document.querySelector("#autoTipsP").classList.add("chatHide")
  1547. }catch (e) {
  1548. console.log(e)
  1549. }
  1550. chatSetting = false;
  1551. }
  1552. })
  1553.  
  1554. }
  1555.  
  1556. async function appendBox(append_case) {
  1557. return new Promise((resolve, reject) => {
  1558. creatBox().then((divE) => {
  1559. let resetWidth = (width)=>{
  1560. try {
  1561. if(width){
  1562. document.querySelector("#gptDiv").style.setProperty("width",width);
  1563. return
  1564. }
  1565. document.querySelector("#gptDiv").style.setProperty("width",
  1566. "100%")
  1567. /*document.querySelector("#gptInput").setAttribute("class",
  1568. "se-input adjust-input")*/
  1569. } catch (e) {
  1570. console.error(e)
  1571. }
  1572. }
  1573.  
  1574. switch (append_case) {
  1575. case 0: //bing
  1576. if (divE) {
  1577. if(isMobile()){
  1578. //手机bing
  1579. document.getElementById('b_results').prepend(divE)
  1580. resetWidth();
  1581. }else{
  1582. document.getElementById('b_context').prepend(divE)
  1583. }
  1584. }
  1585. break;
  1586. case 1: //google
  1587. if(isMobile()){
  1588. //手机google
  1589. document.querySelector("div#msc").after(divE);
  1590. resetWidth();
  1591. }else if (document.getElementsByClassName('TQc1id ')[0]) {
  1592. document.getElementsByClassName('TQc1id ')[0].prepend(divE);
  1593. } else {
  1594. //other
  1595. document.getElementById("rcnt").appendChild(divE);
  1596. }
  1597. break;
  1598. case 2: //baidu
  1599. if (document.getElementById('content_right')) {
  1600. document.getElementById('content_right').prepend(divE)
  1601. }
  1602. break;
  1603. case 3: //yandex
  1604. if (document.getElementById('search-result-aside')) {
  1605. document.getElementById('search-result-aside').prepend(divE)
  1606. }
  1607. break;
  1608. case 4: //360
  1609. if(isMobile()){
  1610. //手机360
  1611. document.getElementById("search-box").appendChild(divE);
  1612. resetWidth();
  1613. }else{
  1614. if (document.getElementById('side')) {
  1615. document.getElementById('side').prepend(divE)
  1616. }
  1617. }
  1618.  
  1619. break;
  1620. case 5: //fsoufsou
  1621. if(isMobile()){
  1622. //手机fsou
  1623. let frow = document.querySelectorAll(".flex-row")[3]
  1624. if (frow.children!==undefined ) {
  1625. frow.children.item(0).prepend(divE)
  1626. }
  1627. resetWidth()
  1628. }else{
  1629. let frow = document.querySelectorAll(".flex-row")[2]
  1630. if (frow.children!==undefined && frow.children.length === 2) {
  1631. frow.children.item(1).prepend(divE)
  1632. } else {
  1633. frow.innerHTML = frow.innerHTML +
  1634. `<div><div class="wiki-container" style="margin-left: 124px!important;padding: 15px!important;">${divE.innerHTML}</div></div>`
  1635. }
  1636. }
  1637.  
  1638. break;
  1639. case 6: //手机百度
  1640. if (document.getElementById('page-bd')) {
  1641. document.getElementById('page-bd').prepend(divE)
  1642. //调整css
  1643. resetWidth();
  1644. }
  1645. break;
  1646. case 7: //duckduckgo
  1647. if(isMobile()){
  1648. //手机dockgo
  1649. document.querySelector('form#search_form').after(divE)
  1650. resetWidth();
  1651. }else{
  1652. if (document.querySelector('[data-area="sidebar"]')) {
  1653. document.querySelector('[data-area="sidebar"]').prepend(divE)
  1654. }
  1655. }
  1656. break;
  1657. case 8: //sogou
  1658. if(isMobile()){
  1659. //手机搜狗
  1660. document.querySelector('form#searchform').after(divE)
  1661. resetWidth();
  1662. }else{
  1663. if (document.querySelector('div.right')) {
  1664. document.querySelector('div.right').prepend(divE)
  1665. }
  1666. }
  1667.  
  1668. break;
  1669. case 9: //bilibili
  1670. if (document.querySelector('div#danmukuBox')) {
  1671. document.querySelector('div#danmukuBox').children.item(0).prepend(divE)
  1672. resetWidth();
  1673. }
  1674.  
  1675. break;
  1676.  
  1677. case 10: //csdn
  1678. let asideDiv = document.querySelector("aside.blog_container_aside div")
  1679. if (asideDiv) {
  1680. asideDiv.after(divE)
  1681. let t = asideDiv.offsetTop + asideDiv.offsetHeight + 5;
  1682. const screenHeight = window.screen.height;
  1683. document.querySelector("#gptDiv").setAttribute("style",
  1684. `position: fixed;top: ${t}px;left: 0px;z-index: 9999;width:410px;`)
  1685.  
  1686. //滚动条
  1687. document.querySelector("#gptAnswer").setAttribute("style",
  1688. `height: ${screenHeight/5}px;overflow-y:scroll`)
  1689.  
  1690.  
  1691. }
  1692.  
  1693. break;
  1694. default:
  1695. if (divE) {
  1696. console.log(`啥情况${divE}`)
  1697. }
  1698. }
  1699. }).catch((err) => {
  1700. throw new Error(err)
  1701. }).finally(()=>{
  1702. if(autoClick){
  1703. setTimeout(() => {
  1704. document.getElementById("button_GPT").click(); //自动点击
  1705. }, 1500)
  1706. }
  1707. })
  1708.  
  1709. resolve("finished")
  1710. })
  1711. }
  1712.  
  1713. //焦点函数
  1714. function isBlur() {
  1715. let myInput = document.getElementById('gptInput');
  1716. if (myInput === document.activeElement) {
  1717. return 1
  1718. } else {
  1719. return 0
  1720. }
  1721. }
  1722.  
  1723. function keyEvent() {
  1724. document.onkeydown = function (e) {
  1725. let keyNum = window.event ? e.keyCode : e.which;
  1726. if (13 === keyNum) {
  1727. if (isBlur()) {
  1728. document.getElementById('button_GPT').click()
  1729. } else {
  1730. console.log("失焦不执行")
  1731. }
  1732.  
  1733. }
  1734.  
  1735.  
  1736. }
  1737.  
  1738. }
  1739.  
  1740.  
  1741.  
  1742.  
  1743. function addBothStyle() {
  1744. GM_addStyle(`
  1745. .gpt-container {
  1746. box-sizing: border-box;
  1747. height: -webkit-min-content;
  1748. height: min-content;
  1749. width: 455px;
  1750. margin-top: 8px;
  1751. margin-bottom: 8px;
  1752. border: 1px solid #dfe1e5;
  1753. border-radius: 8px;
  1754. overflow: hidden;
  1755. padding: 15px;
  1756. background-color:#fcfcfc
  1757. }
  1758.  
  1759. #dot{
  1760. height: 4px;
  1761. width: 4px;
  1762. display: inline-block;
  1763. border-radius: 2px;
  1764. animation: dotting 2.4s infinite step-start;
  1765. }
  1766. @keyframes dotting {
  1767. 25%{
  1768. box-shadow: 4px 0 0 #71777D;
  1769. }
  1770. 50%{
  1771. box-shadow: 4px 0 0 #71777D ,14px 0 0 #71777D;
  1772. }
  1773. 75%{
  1774. box-shadow: 4px 0 0 #71777D ,14px 0 0 #71777D, 24px 0 0 #71777D;
  1775. }
  1776. }
  1777. pre{
  1778. overflow-x: scroll;
  1779. overflow-y: hidden;
  1780. background: #fffaec;
  1781. border-radius: 4px;
  1782. padding: 14px 3px;
  1783. }
  1784. pre::-webkit-scrollbar {
  1785. }`);
  1786. }
  1787.  
  1788.  
  1789.  
  1790. function Uint8ArrayToString(fileData) {
  1791. let dataString = "";
  1792. for (let i = 0; i < fileData.length; i++) {
  1793. dataString += String.fromCharCode(fileData[i]);
  1794. }
  1795.  
  1796. return dataString;
  1797. }
  1798.  
  1799. function decodeUnicode(str) {
  1800. str = str.replace(/\\/g, "%");
  1801. //转换中文
  1802. str = unescape(str);
  1803. //将其他受影响的转换回原来
  1804. str = str.replace(/%/g, "\\");
  1805. //对网址的链接进行处理
  1806. str = str.replace(/\\/g, "");
  1807. return str;
  1808. }
  1809.  
  1810.  
  1811. (function (extension) {
  1812. if (typeof showdown !== 'undefined') {
  1813. // global (browser or node.js global)
  1814. extension(showdown);
  1815. } else if (typeof define === 'function' && define.amd) {
  1816. // AMD
  1817. define(['showdown'], extension);
  1818. } else if (typeof exports === 'object') {
  1819. // Node, CommonJS-like
  1820. module.exports = extension(require('showdown'));
  1821. } else {
  1822. // showdown was not found so an error is thrown
  1823. throw Error('Could not find showdown library');
  1824. }
  1825. }(function (showdown) {
  1826. // loading extension into showdown
  1827. showdown.extension('myext', function () {
  1828. return [
  1829. //to katex
  1830. {
  1831. type: 'output',
  1832. filter: function (source, converter, options) {
  1833. //debugger
  1834. return katexTohtml(source);
  1835. }
  1836. },
  1837. // filter xss
  1838. {
  1839. type: 'output',
  1840. filter: function (source, converter, options) {
  1841. //debugger
  1842. return source.replace(/<script/gi, '&lt;script').replace(/<meta/gi, '&lt;meta');
  1843. }
  1844. },
  1845. //Adds simple footnotes
  1846.  
  1847. {
  1848. type: 'output',
  1849. filter: text => text.replace(
  1850. /^\[\^([\d\w]+)\]:\s*((\n+(\s{2,4}|\t).+)+)$/mg,
  1851. (str, name, rawContent, _, padding) => {
  1852. const content = converter.makeHtml(rawContent.replace(new RegExp(`^${padding}`, 'gm'), ''))
  1853. return `<div class="footnote" id="footnote-${name}"><a href="#footnote-${name}"><sup>[${name}]</sup></a>:${content}</div>`
  1854. }
  1855. )
  1856. },
  1857. {
  1858. type: 'lang',
  1859. filter: text => text.replace(
  1860. /^\[\^([\d\w]+)\]:( |\n)((.+\n)*.+)$/mg,
  1861. (str, name, _, content) =>
  1862. `<small class="footnote" id="footnote-${name}"><a href="#footnote-${name}"><sup>[${name}]</sup></a>: ${content}</small>`
  1863. )
  1864. },
  1865. {
  1866. type: 'lang',
  1867. filter: text => text.replace(
  1868. /\[\^([\d\w]+)\]/m,
  1869. (str, name) => `<a href="#footnote-${name}"><sup>[${name}]</sup></a>`
  1870. )
  1871. },
  1872.  
  1873. //replace \n
  1874. {
  1875. type: 'lang',
  1876. filter: text => text.replace(/\\n+/g, "\n")
  1877. },
  1878. /**
  1879. * Showdown Icon Extension, Glyphicon and FontAwesome support for showdown
  1880. * http://github.com/dbtek/showdown-icon
  1881. * 2014, Ismail Demirbilek
  1882. * License: MIT
  1883. */
  1884. {
  1885. type: "lang",
  1886. regex: "\\B(\\\\)?@glyphicon-([\\S]+)\\b",
  1887. replace: function(a, b, c) {
  1888. return b === "\\" ? a : '<span class="glyphicon glyphicon-' + c + '">' + "</span>"
  1889. }
  1890. },
  1891. {
  1892. type: "lang",
  1893. regex: "\\B(\\\\)?@fa-([\\S]+)\\b",
  1894. replace: function(a, b, c) {
  1895. return b === "\\" ? a : '<i class="fa fa-' + c + '">' + "</i>"
  1896. }
  1897. }
  1898.  
  1899. ];
  1900. })
  1901. }));
  1902. function mdConverter(rawData) {
  1903. let tmpData = rawData;
  1904. let converter = new showdown.Converter({
  1905. extensions: ['myext']
  1906. });
  1907. converter.setOption('tables',
  1908. true); //启用表格选项。从showdown 1.2.0版开始,表支持已作为可选功能移入核心拓展,showdown.table.min.js扩展已被弃用
  1909. converter.setOption('openLinksInNewWindow',true) //链接在新窗口打开
  1910. converter.setOption('strikethrough', true) //删除线
  1911. converter.setOption('emoji', true) //开启emoji
  1912.  
  1913. /***
  1914. * original: John Gruber 规范中的原始 Markdown 风格
  1915. * vanilla:对决基础风味(v1.3.1 起)
  1916. * github: GitHub 风格的 Markdown,或 GFM
  1917. */
  1918. showdown.setFlavor('github');
  1919.  
  1920. try {
  1921. return converter.makeHtml(rawData);
  1922. }catch (ex) {
  1923. console.error(ex)
  1924. //fix script markdown render
  1925. try {
  1926. return katexTohtml(marked.parse(rawData))
  1927. }catch (ex) {
  1928. console.error("备用渲染失败")
  1929. }
  1930. }
  1931. return tmpData;
  1932.  
  1933. }
  1934.  
  1935. //实时监控
  1936. setInterval(() => {
  1937. //百度
  1938. if (window.location.href.indexOf("baidu.com\/s") > -1 && !isMobile()) {
  1939. if (!document.getElementById("gptDiv") && document.getElementById("mybtn")) {
  1940. document.getElementById("mybtn").click()
  1941. }
  1942.  
  1943. if (!document.getElementById("gptDiv") && !document.getElementById("mybtn")) {
  1944. addChatBtn();
  1945. document.getElementById("mybtn").click()
  1946. }
  1947.  
  1948. }
  1949. //360 注意请如果你在360相关浏览器上使用插件。360搜索将不会生效,因为已被浏览器禁用在so.com网址上使用
  1950. if (window.location.href.indexOf("so.com\/s") > -1 && !document.getElementById("gptDiv")) {
  1951. GM_add_box_style(1)
  1952. addBothStyle()
  1953. keyEvent()
  1954. appendBox(4).then((res) => {
  1955. pivElemAddEventAndValue(4)
  1956. })
  1957. }
  1958. //bilibli
  1959. if (window.location.href.indexOf("bilibili.com\/video") > -1 && !document.getElementById("gptDiv")) {
  1960. GM_add_box_style(1)
  1961. addBothStyle()
  1962. keyEvent()
  1963. appendBox(9).then((res) => {
  1964. pivElemAddEventAndValue(null)
  1965. })
  1966. }
  1967.  
  1968. }, 2000)
  1969.  
  1970.  
  1971. function generateRandomString(length) {
  1972. let result = '';
  1973. let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  1974. let charactersLength = characters.length;
  1975. for (let i = 0; i < length; i++) {
  1976. result += characters.charAt(Math.floor(Math.random() * charactersLength));
  1977. }
  1978. return result;
  1979. }
  1980.  
  1981.  
  1982.  
  1983. let messageChain2 = [];//AILS
  1984.  
  1985. let messageChain10 = [];//PRTBOOM
  1986.  
  1987. function addMessageChain(messageChain, element,maxLength) {
  1988. maxLength = maxLength || 6;
  1989. if (messageChain.length >= maxLength) {
  1990. messageChain.shift();
  1991. }
  1992. messageChain.push(element);
  1993. console.log(messageChain,maxLength)
  1994. return messageChain;
  1995. }
  1996.  
  1997. function formattedDate() {
  1998. const now = new Date();
  1999. const year = now.getFullYear();
  2000. const month = now.getMonth() + 1;
  2001. const day = now.getDate();
  2002.  
  2003. const formattedMonth = month < 10 ? `0${month}` : month;
  2004. const formattedDay = day < 10 ? `0${day}` : day;
  2005.  
  2006. return `${year}-${formattedMonth}-${formattedDay}`;
  2007. }
  2008.  
  2009.  
  2010.  
  2011. let ails_clientv = "0.1.293";
  2012. let ails_signKey = "WI,2rU#_r:r~aF4aJ36[.Z(/8Rv93Rf";
  2013. function AILS() {
  2014.  
  2015. let vtime = function converTimestamp(t) {
  2016. const e = parseInt(t)
  2017. , n = e % 10
  2018. , r = n % 2 === 0 ? n + 1 : n;
  2019. return (e - n + r).toString()
  2020. }
  2021.  
  2022. let now = vtime(new Date().getTime());
  2023. const pk = `${ails_signKey}:${your_qus.length}`;//查看js的generateSignature函数中的key
  2024. let Baseurl = "https://api.caipacity.com/"
  2025. generateSignatureWithPkey({
  2026. t: now,
  2027. m: your_qus || "",
  2028. pkey: pk
  2029. }).then(sign => {
  2030. addMessageChain(messageChain2, {role: "user", content: your_qus})//连续话
  2031. console.log(sign)
  2032. GM_fetch({
  2033. method: "POST",
  2034. url: Baseurl + "v1/chat/completions?full=false",
  2035. headers: {
  2036. "Content-Type": "application/json",
  2037. "authorization": "Bearer free",
  2038. "client-id": uuidv4(),
  2039. "client-v": ails_clientv,
  2040. "Referer": "https://ai.ls/",
  2041. "from-url": "https://ai.ls/?chat=1",
  2042. "origin": "https://ai.ls",
  2043. "X-Forwarded-For": generateRandomIP(),
  2044. "accept": "application/json"
  2045. },
  2046. data: JSON.stringify({
  2047. model: "gpt-3.5-turbo",
  2048. messages: messageChain2,
  2049. stream: true,
  2050. t: `${now}`,
  2051. d: formattedDate(),
  2052. s: sign,
  2053. temperature:0.6
  2054. }),
  2055. responseType: "stream"
  2056. }).then((stream) => {
  2057. let result = [];
  2058. let finalResult;
  2059. const reader = stream.response.getReader();
  2060. reader.read().then(function processText({done, value}) {
  2061. if (done) {
  2062. finalResult = result.join("")
  2063. try {
  2064. console.log(finalResult)
  2065. addMessageChain(messageChain2, {
  2066. role: "assistant",
  2067. content: finalResult
  2068. })
  2069. showAnserAndHighlightCodeStr(finalResult)
  2070. } catch (e) {
  2071. console.log(e)
  2072. }
  2073. return;
  2074. }
  2075. try {
  2076. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  2077. console.log(d)
  2078. /*d.split("\n").forEach(item=>{
  2079. try {
  2080. let chunk = JSON.parse(item.replace(/data:/,"").trim())
  2081. .choices[0].delta.content;
  2082. result.push(chunk)
  2083. }catch (ex){}
  2084. })*/
  2085. result.push(d)
  2086. showAnserAndHighlightCodeStr(result.join(""))
  2087. } catch (e) {
  2088. console.log(e)
  2089. }
  2090.  
  2091. return reader.read().then(processText);
  2092. });
  2093. },(reason)=>{
  2094. console.log(reason)
  2095. Toast.error("未知错误!")
  2096. }).catch((ex)=>{
  2097. console.log(ex)
  2098. });
  2099.  
  2100. });
  2101. }
  2102.  
  2103.  
  2104. async function delay(ms) {
  2105. return new Promise(resolve => setTimeout(resolve, ms));
  2106. }
  2107.  
  2108.  
  2109. let ds_x_token_dasclient = ""
  2110.  
  2111. async function initDS_x_token_dasclient() {
  2112. if (location.href.includes("scnet.cn")) {
  2113. ds_x_token_dasclient = localStorage.getItem("user_chat_token");
  2114. console.log("ds_x_token_dasclient",ds_x_token_dasclient)
  2115. GM_setValue("ds_x_token_dasclient", ds_x_token_dasclient)
  2116. try {
  2117. if(ds_x_token_dasclient){
  2118. Toast.info("ds_x_token_dasclient 获取成功:",ds_x_token_dasclient)
  2119. }else{
  2120. Toast.info("`ds_x_token_dasclient获取失败,请再次刷新.`",ds_x_token_dasclient)
  2121. }
  2122. }catch (e) {}
  2123. } else {
  2124. ds_x_token_dasclient = GM_getValue("ds_x_token_dasclient")
  2125. }
  2126. }
  2127.  
  2128. setTimeout(initDS_x_token_dasclient)
  2129.  
  2130.  
  2131. async function DeepSeek() {
  2132.  
  2133.  
  2134. showAnserAndHighlightCodeStr(`此线路为超算互联Deepseek线路,如果出错请尝试打开官方后刷新页面再试:[Deepseek](https://chat.scnet.cn/)`)
  2135.  
  2136. if(!ds_x_token_dasclient){
  2137. showAnserAndHighlightCodeStr(`x_token_dasclient为空,请尝试打开官方后刷新页面再试:[Deepseek](https://chat.scnet.cn/)`)
  2138. return
  2139. }
  2140. console.warn("x_token_dasclient:",ds_x_token_dasclient)
  2141.  
  2142.  
  2143.  
  2144. let baseURL = "https://chat.scnet.cn/";
  2145. let res = await GM_fetch({
  2146. method: "POST",
  2147. url: baseURL + "api/chat/Ask/",
  2148. headers: {
  2149. "accept": "application/json, text/plain, */*",
  2150. "content-type": "application/json",
  2151. "x-token-dasclient": ds_x_token_dasclient,
  2152. "Referer": baseURL
  2153. },
  2154. data: JSON.stringify(
  2155. {
  2156. "modelType": "DeepSeek-R1-671B",
  2157. "query": your_qus,
  2158. "conversationId": "",
  2159. "messageType": "local"
  2160. }
  2161. )
  2162. });
  2163. if (res.status === 200) {
  2164. console.log('ds:成功....')
  2165. console.log(res)
  2166. let ds_messageId = JSON.parse(res.responseText).data.messageId;
  2167. console.log("ds_messageId",ds_messageId)
  2168.  
  2169.  
  2170. GM_fetch({
  2171. method: "GET",
  2172. url: `https://chat.scnet.cn/api/chat/GetReplay?messageId=${ds_messageId}&query=&modelType=DeepSeek-R1-671B`,
  2173. headers: {
  2174. "Referer": baseURL,
  2175. "x-token-dasclient": ds_x_token_dasclient,
  2176. "accept": "text/event-stream",
  2177. },
  2178. responseType: "stream"
  2179. }).then((stream) => {
  2180. let result = [];
  2181. let finalResult;
  2182. const reader = stream.response.getReader();
  2183. reader.read().then(function processText({done, value}) {
  2184. if (done) {
  2185. finalResult = result.join("")
  2186. showAnserAndHighlightCodeStr(finalResult)
  2187. return;
  2188. }
  2189.  
  2190. try {
  2191.  
  2192. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  2193. console.log("raw:",d)
  2194. let responseItem = d.trim().split("\n");
  2195. console.warn(responseItem)
  2196. responseItem.forEach(item=>{
  2197. try {
  2198. if(item && item.startsWith("data:")){
  2199. let ii = item.replace(/data:/gi,"")
  2200. console.log("ii:",ii)
  2201. if(ii){
  2202. if(ii.length > 2 ){
  2203. result.push(ii.trim().slice(1,-1))
  2204. }else{
  2205. result.push(ii.trim())
  2206. }
  2207. showAnserAndHighlightCodeStr(result.join(""))
  2208. }
  2209. }
  2210. }catch (ex){
  2211. console.error(item)
  2212. }
  2213. })
  2214. } catch (e) {
  2215. console.log(e)
  2216. }
  2217.  
  2218. return reader.read().then(processText);
  2219. });
  2220. },function (err) {
  2221. console.log(err)
  2222. Toast.error("未知错误!")
  2223. }).catch((ex)=>{
  2224. console.log(ex)
  2225. Toast.error("未知错误!")
  2226. })
  2227.  
  2228.  
  2229. } else {
  2230. console.log(res)
  2231. Toast.error('访问失败了')
  2232. }
  2233.  
  2234. }
  2235.  
  2236.  
  2237. //取某个cookie的值
  2238. function getCookieValue(cookies, cookieName) {
  2239. let name = cookieName + "=";
  2240. let cookieArray = cookies.split(';');
  2241. for(let i = 0; i < cookieArray.length; i++) {
  2242. let cookie = cookieArray[i];
  2243. while (cookie.charAt(0) === ' ') {
  2244. cookie = cookie.substring(1);
  2245. }
  2246. if (cookie.indexOf(name) === 0) {
  2247. return cookie.substring(name.length, cookie.length);
  2248. }
  2249. }
  2250. return "";
  2251. }
  2252.  
  2253. //取header的cookie
  2254. function getCookies(headers) {
  2255. let cookieArray = headers.split('\r\n');
  2256. cookieArray.forEach(item => {
  2257. if(item.startsWith('set-cookie')){
  2258. return item;
  2259. }
  2260. })
  2261. return "";
  2262. }
  2263.  
  2264.  
  2265.  
  2266. let userId_yqcloud = "#/chat/" + Date.now();
  2267. //fix 24.3.12 https://chat18.aichatos.xyz
  2268. function YQCLOUD() {
  2269. console.log(userId_yqcloud)
  2270. abortXml = GM_xmlhttpRequest({
  2271. method: "POST",
  2272. //url: "https://cbjtestapi.binjie.site:7777/api/generateStream",
  2273. url: "https://api.binjie.fun/api/generateStream",
  2274. headers: {
  2275. "Content-Type": "application/json",
  2276. "Referer": "https://chat18.aichatos.xyz",
  2277. "origin": "https://chat18.aichatos.xyz",
  2278. "accept": "application/json, text/plain, */*"
  2279. },
  2280. data: JSON.stringify({
  2281. prompt: your_qus,
  2282. apikey: "",
  2283. system: "",
  2284. withoutContext: false,
  2285. userId: userId_yqcloud,
  2286. network: true
  2287. }),
  2288. onloadstart: (stream) => {
  2289. let result = [];
  2290. const reader = stream.response.getReader();
  2291. reader.read().then(function processText({done, value}) {
  2292. if (done) {
  2293. let finalResult = result.join("").
  2294. replace(/gptxyy/gi,"")
  2295. .replace(/aichatos/gi,"")
  2296. .replace(/https?:\/\/[^\s]+/g,"")
  2297. showAnserAndHighlightCodeStr(finalResult)
  2298. return;
  2299. }
  2300. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  2301. result.push(d)
  2302. try {
  2303. console.log(result.join(""))
  2304. showAnserAndHighlightCodeStr(result.join("").
  2305. replace(/gptxyy/gi,"")
  2306. .replace(/aichatos/gi,"")
  2307. .replace(/https?:\/\/[^\s]+/g,""))
  2308. } catch (e) {
  2309. console.log(e)
  2310. }
  2311. return reader.read().then(processText);
  2312. });
  2313. },
  2314. responseType: "stream",
  2315. onerror: function (err) {
  2316. console.log(err)
  2317. Toast.error("未知错误!")
  2318. }
  2319. })
  2320.  
  2321. }
  2322.  
  2323.  
  2324. let parentID_thebai;
  2325.  
  2326. //https://f2.cnote.top/#/chat/1002
  2327. function THEBAI() {
  2328. let ops = {};
  2329. if (parentID_thebai) {
  2330. ops = {parentMessageId: parentID_thebai};
  2331. }
  2332. console.log(ops)
  2333. abortXml = GM_xmlhttpRequest({
  2334. method: "POST",
  2335. url: "https://p1api.xjai.pro/freeapi/chat-process",
  2336. headers: {
  2337. "Content-Type": "application/json",
  2338. "Referer": "https://f2.cnote.top/",
  2339. "accept": "application/json, text/plain, */*"
  2340. },
  2341. data: JSON.stringify({
  2342. "prompt": your_qus,
  2343. "options": ops,
  2344. "systemMessage": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
  2345. "temperature": 0.8,
  2346. "top_p": 1
  2347. }),
  2348. onloadstart: (stream) => {
  2349. const reader = stream.response.getReader();
  2350. let result = []
  2351. reader.read().then(function processText({done, value}) {
  2352. if (done) {
  2353. showAnserAndHighlightCodeStr(result.join("").replace(/x-code.fun/gi,"")
  2354. .replace(/bilibili/gi,"").replace(/xjai/gi,"")
  2355. .replace(/ymiai/gi,"").replace(/aiflarepro/gi,"")
  2356. .split(/\.*?\&/gi)[2])
  2357.  
  2358. return;
  2359. }
  2360. try {
  2361. let byteArray = new Uint8Array(value);
  2362. let decoder = new TextDecoder('utf-8');
  2363. let d = decoder.decode(byteArray);
  2364. try {
  2365. let jsonObj = JSON.parse(d.trim())
  2366. if (jsonObj.id) {
  2367. parentID_thebai = jsonObj.id;
  2368. }
  2369. }catch (e) { }
  2370. console.log(d)
  2371. result.push(d)
  2372. showAnserAndHighlightCodeStr(result.join("").replace(/x-code.fun/gi,"")
  2373. .replace(/bilibili/gi,"")
  2374. .replace(/xjai/gi,"")
  2375. .replace(/ymiai/gi,"").replace(/aiflarepro/gi,""))
  2376.  
  2377.  
  2378. } catch (e) {
  2379. console.error(e)
  2380. }
  2381.  
  2382. return reader.read().then(processText);
  2383. });
  2384. },
  2385. responseType: "stream",
  2386. onerror: function (err) {
  2387. console.log(err)
  2388. Toast.error("未知错误!")
  2389. }
  2390. })
  2391. }
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397. /*setTimeout(async () => {
  2398. let rr = await GM_fetch({
  2399. method: "GET",
  2400. url: `https://yeyu2048.xyz/chat/haohula.json?r=${Math.random()}`
  2401. });
  2402. if (rr.status === 200) {
  2403. console.log(rr)
  2404. let result = JSON.parse(rr.responseText);
  2405.  
  2406.  
  2407. } else {
  2408. console.error(rr)
  2409. }
  2410.  
  2411. })*/
  2412.  
  2413. function isTokenExpired(token) {
  2414. if(!token) return true
  2415. try {
  2416. const tokenData = JSON.parse(atob(token.split('.')[1]));
  2417.  
  2418. if (!tokenData.exp) {
  2419. return false;
  2420. }
  2421.  
  2422. const expirationTime = tokenData.exp * 1000; // Convert expiration time to milliseconds
  2423. const currentTime = new Date().getTime();
  2424.  
  2425. if (currentTime > expirationTime) {
  2426. return true;
  2427. } else {
  2428. return false;
  2429. }
  2430. }catch (e) {
  2431. return false
  2432. }
  2433.  
  2434. return true;
  2435. }
  2436.  
  2437.  
  2438. let bingSocket;
  2439. let bing_sourceAttributions;
  2440. let bing_result;
  2441. function initBingSocket() {
  2442. let socket = new WebSocket(`wss://sydney.bing.com/sydney/ChatHub`);
  2443.  
  2444. // 监听连接成功事件
  2445.  
  2446. socket.addEventListener('open', (event) => {
  2447. console.log('initBingSocket 连接成功');
  2448. bingSocket = socket;
  2449. showAnserAndHighlightCodeStr("BingSocket:已连接,请勿重新点击,结果返回较慢请耐心等待,若长时间没反应则不可用。注意:本线路为new bing官网线路。若要使用线路,则需要科学上网和登录(不可用)微软账号:[BING AI](https://cn.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx)")
  2450. });
  2451.  
  2452. // 监听接收消息事件
  2453. socket.addEventListener('message', (event) => {
  2454. console.log('initBingSocket 接收到消息:', event.data);
  2455. let revData = event.data;
  2456. try{
  2457. let rr = revData.replace(String.fromCharCode(0x1e),"");
  2458.  
  2459. try{
  2460. let ref = '\n'
  2461. if(rr.startsWith('{"type":2')){
  2462. console.warn("bing_sourceAttributions foreach")
  2463. bing_sourceAttributions && bing_sourceAttributions.forEach((sb,index) =>{
  2464. try{
  2465. ref += `${index}.[${sb.providerDisplayName}](${sb.seeMoreUrl})\n\n`
  2466. }catch (e) {console.error("sb", e)}
  2467. })
  2468. showAnserAndHighlightCodeStr(bing_result + ref);
  2469. }
  2470. }catch (ex) { /*console.error("bing_sourceAttributions ex ", JSON.parse(rr))*/ }
  2471.  
  2472.  
  2473. let ans = JSON.parse(rr).arguments[0].messages[0].text;
  2474. bing_result = (ans ? ans : bing_result)
  2475. console.log(bing_result)
  2476. showAnserAndHighlightCodeStr(bing_result)
  2477. if(conversationId){
  2478. isStartOfSession = false;
  2479. }
  2480.  
  2481. if(JSON.parse(rr).arguments[0].messages[0].sourceAttributions){
  2482. let sb = JSON.parse(rr).arguments[0].messages[0].sourceAttributions;
  2483. bing_sourceAttributions = sb.length > 0 ? sb : bing_sourceAttributions;
  2484.  
  2485. console.warn('bing_sourceAttributions',bing_sourceAttributions)
  2486. }
  2487.  
  2488. }catch (e) {
  2489.  
  2490. }
  2491. /*if(revData.includes("allowReconnect")){
  2492. isStartOfSession = true;
  2493. }*/
  2494.  
  2495. });
  2496. }
  2497.  
  2498. //setTimeout(initBingSocket,1000)
  2499. let isStartOfSession = true;
  2500. let conversationId;
  2501. let clientId;
  2502. let conversationSignature;
  2503. let invocationId = 0;
  2504. let toneStyle = 'fast';
  2505. async function newBing() {
  2506.  
  2507. setTimeout(initBingSocket)
  2508. await delay(2000)
  2509.  
  2510. const genRanHex = (size) =>
  2511. [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')
  2512.  
  2513. if(isStartOfSession){
  2514. console.log("isStartOfSession:",isStartOfSession)
  2515. let req1 = await GM_fetch({
  2516. method: "GET",
  2517. url: "https://www.bing.com/turing/conversation/create"
  2518. })
  2519. let r = req1.responseText;
  2520. console.log(r)
  2521. conversationId = JSON.parse(r).conversationId;
  2522. clientId = JSON.parse(r).clientId;
  2523. conversationSignature = JSON.parse(r).conversationSignature;
  2524.  
  2525. }
  2526.  
  2527.  
  2528.  
  2529. if (bingSocket.readyState === 1) {
  2530. // 发送协议和版本号
  2531. const protocol = {protocol: "json", version: 1};
  2532. bingSocket.send(JSON.stringify(protocol) + String.fromCharCode(0x1e));
  2533.  
  2534. await delay(1000)
  2535. // 发送请求类型
  2536. const type = {type: 6};
  2537. bingSocket.send(JSON.stringify(type) + String.fromCharCode(0x1e));
  2538.  
  2539. await delay(500)
  2540. //发送提问
  2541. if(!isStartOfSession){
  2542. invocationId += 1;
  2543. }
  2544. let toneOption
  2545. if (toneStyle === 'creative') {
  2546. toneOption = 'h3imaginative'
  2547. } else if (toneStyle === 'precise') {
  2548. toneOption = 'h3precise'
  2549. } else if (toneStyle === 'fast') {
  2550. // new "Balanced" mode, allegedly GPT-3.5 turbo
  2551. toneOption = 'galileo'
  2552. } else {
  2553. // old "Balanced" mode
  2554. toneOption = 'harmonyv3'
  2555. }
  2556. const msg = {
  2557. "arguments": [{
  2558. "conversationId": conversationId,
  2559. "sliceIds": ["222dtappid", "225cricinfo", "224locals0"],
  2560. "optionsSets": [
  2561. 'nlu_direct_response_filter',
  2562. 'deepleo',
  2563. 'disable_emoji_spoken_text',
  2564. 'responsible_ai_policy_235',
  2565. 'enablemm',
  2566. toneOption,
  2567. 'dtappid',
  2568. 'cricinfo',
  2569. 'cricinfov2',
  2570. 'dv3sugg',
  2571. 'nojbfedge',
  2572. ],
  2573. "traceId": genRanHex(32),
  2574. "source": "cib",
  2575. "isStartOfSession": isStartOfSession,
  2576. "message": {
  2577. "author": "user",
  2578. "text": your_qus,
  2579. "messageType": "Chat"
  2580. },
  2581. "conversationSignature": conversationSignature,
  2582. "participant": {
  2583. "id": clientId
  2584. }
  2585. }],
  2586. "invocationId": `${invocationId}`,
  2587. "target": "chat",
  2588. "type": 4
  2589. }
  2590.  
  2591. bingSocket.send(JSON.stringify(msg) + String.fromCharCode(0x1e));
  2592. /* if(isStartOfSession){
  2593. isStartOfSession = false;
  2594. }*/
  2595. }
  2596.  
  2597.  
  2598.  
  2599. }
  2600.  
  2601.  
  2602.  
  2603. function uuidv4() {
  2604. let d = new Date().getTime(); // get current timestamp in ms (to ensure UUID uniqueness)
  2605. let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  2606. let r = (d + Math.random() * 16) % 16 | 0 // generate random nibble
  2607. d = Math.floor(d / 16) // correspond each UUID digit to unique 4-bit chunks of timestamp
  2608. return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16) // generate random hexadecimal digit
  2609. })
  2610. return uuid
  2611. }
  2612.  
  2613. //OPENAI update wss 2024.3.12
  2614. //let messageChain_openai = [];
  2615. let openai_conversation_id ;
  2616. let openai_parent_message_id ;
  2617. let history_disable = false ;
  2618. async function OPENAI(GPTModel){
  2619. // addMessageChain(messageChain_openai,{
  2620. // "role": "user",
  2621. // "id": uuidv4(),
  2622. // "content": {
  2623. // "content_type": "text",
  2624. // "parts": [
  2625. // your_qus
  2626. // ]
  2627. // },
  2628. // "metadata":{}
  2629. // },20)
  2630. showAnserAndHighlightCodeStr(`此线路为OpenAI官网线路:${GPTModel},使用前确定有访问权限且登录(不可用)账号:[OPENAI官网](https://chatgpt.com/)`)
  2631. let req1 = await GM_fetch({
  2632. method: "GET",
  2633. url: "https://chatgpt.com/api/auth/session"
  2634. })
  2635. let r = req1.responseText;
  2636. console.log(r)
  2637. let accessToken;
  2638. try{
  2639. accessToken = JSON.parse(r).accessToken;
  2640. }catch (e) {
  2641. showAnserAndHighlightCodeStr("验证出错,请确认有权限访问OPENAI官网[OPENAI](https://chatgpt.com/)")
  2642. }
  2643.  
  2644. if(!accessToken){
  2645. showAnserAndHighlightCodeStr("验证出错,请确认有权限OPENAI官网[OPENAI](https://chatgpt.com/)")
  2646. }
  2647.  
  2648. let paramObj = {
  2649. action: "next",
  2650. messages: [{
  2651. "author": {
  2652. "role": "user"
  2653. },
  2654. "id": uuidv4(),
  2655. "content": {
  2656. "content_type": "text",
  2657. "parts": [
  2658. your_qus
  2659. ]
  2660. },
  2661. "metadata":{}
  2662. }],
  2663. model: GPTModel,
  2664. parent_message_id: openai_parent_message_id ? openai_parent_message_id : uuidv4(),
  2665. suggestions: [],
  2666. arkose_token: null,
  2667. history_and_training_disabled: history_disable,
  2668. timezone_offset_min: new Date().getTimezoneOffset()
  2669. }
  2670. if(openai_conversation_id){
  2671. try {
  2672. Reflect.set(paramObj,"conversation_id", openai_conversation_id)
  2673. }catch (ex) {
  2674. console.error(ex)
  2675. }
  2676. }
  2677. console.log(paramObj)
  2678.  
  2679. let sendData = JSON.stringify(paramObj)
  2680. GM_fetch({
  2681. method: 'POST',
  2682. url: 'https://chatgpt.com/backend-api/conversation',
  2683. headers: {
  2684. 'Content-Type': 'application/json',
  2685. Authorization: 'Bearer ' + accessToken,
  2686. 'origin': 'https://chatgpt.com',
  2687. 'Referer': 'https://chatgpt.com/',
  2688. },
  2689. responseType: "stream",
  2690. data: sendData
  2691. }).then((stream)=> {
  2692. let reader = stream.response.getReader()
  2693. let reqJsonStr;
  2694. reader.read().then(function processText({done, value}) {
  2695. if (done) {
  2696.  
  2697. //连接openai websocket
  2698. let reqJson = JSON.parse(reqJsonStr)
  2699. //openai_conversation_id = reqJson.openai_conversation_id
  2700. let wssurl = reqJson.wss_url
  2701.  
  2702. let socket = new WebSocket(wssurl);
  2703. socket.addEventListener('open', (event) => {
  2704. console.log('OpenAI wss 连接成功');
  2705. });
  2706. socket.addEventListener('message', (event) => {
  2707. console.log('OpenAISocket 接收到消息:', event.data);
  2708. let revData = event.data;
  2709. try{
  2710. let revJSON = JSON.parse(revData);
  2711. if(revJSON.type == 'http.response.body'){
  2712. openai_parent_message_id = revJSON.message_id
  2713. if(revJSON.body !== 'ZGF0YTogW0RPTkVdCgo='){
  2714. //处理结果
  2715. try{
  2716. let responseItem = atob(revJSON.body)
  2717. console.log(responseItem)
  2718. showAnserAndHighlightCodeStr(JSON.parse(responseItem.slice(6)).message.content.parts[0])
  2719. if(JSON.parse(responseItem.slice(6)).conversation_id){
  2720. openai_conversation_id = JSON.parse(responseItem.slice(6)).conversation_id
  2721. openai_parent_message_id = JSON.parse(responseItem.slice(6)).message.id
  2722. }
  2723. }catch (ex) {
  2724. console.error(ex)
  2725. }
  2726. }
  2727.  
  2728. }
  2729.  
  2730. }catch (ex) { }
  2731.  
  2732. });
  2733.  
  2734.  
  2735.  
  2736. console.log("===done==")
  2737. // addMessageChain(messageChain_openai,{
  2738. // "role": "assistant",
  2739. // "id": uuidv4(),
  2740. // "content": {
  2741. // "content_type": "text",
  2742. // "parts": [
  2743. // answer
  2744. // ]
  2745. // },
  2746. // "metadata":{}
  2747. // }, 20)
  2748. return
  2749. }
  2750. reqJsonStr = String.fromCharCode(...Array.from(value))
  2751.  
  2752. /*try{
  2753. let responseItem = String.fromCharCode(...Array.from(value))
  2754. console.log(responseItem)
  2755. let items = responseItem.split('\n\n')
  2756. if (items.length > 2) {
  2757. let lastItem = items.slice(-3, -2)[0]
  2758. if (lastItem.startsWith('data: [DONE]')) {
  2759. responseItem = items.slice(-4, -3)[0]
  2760. } else {
  2761. responseItem = lastItem
  2762. }
  2763. }
  2764. if (responseItem.startsWith('data: {')) {
  2765. answer = JSON.parse(responseItem.slice(6)).message.content.parts[0]
  2766. showAnserAndHighlightCodeStr(answer)
  2767. if(JSON.parse(responseItem.slice(6)).conversation_id){
  2768. openai_conversation_id = JSON.parse(responseItem.slice(6)).conversation_id
  2769. openai_parent_message_id = JSON.parse(responseItem.slice(6)).message.id
  2770. }
  2771.  
  2772. } else if (responseItem.startsWith('data: [DONE]')) {
  2773.  
  2774. // return
  2775. }
  2776. }catch (e) {
  2777. console.error(e)
  2778. }*/
  2779.  
  2780. return reader.read().then(processText)
  2781. },function (reason) {
  2782. console.log(reason)
  2783. Toast.error("未知错误!")
  2784. }).catch((ex)=>{
  2785. console.log(ex)
  2786. Toast.error("未知错误!")
  2787. })
  2788. })
  2789. }
  2790.  
  2791. //Gemini api
  2792. let gemini_key = localStorage.getItem("gemini_key")
  2793. async function Gemini(GPTModel){
  2794.  
  2795. if(!gemini_key){
  2796. showAnserAndHighlightCodeStr(`gemini_key为空,请点击设置-更新key,请到获取[https://aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)`)
  2797. return
  2798. }
  2799.  
  2800. showAnserAndHighlightCodeStr(`请稍后。。。此线路为google官网线路,使用前确定apikey的正确性(设置-更新key),[key获取](https://aistudio.google.com/app/apikey)`)
  2801.  
  2802.  
  2803. GM_fetch({
  2804. method: 'POST',
  2805. url: `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${gemini_key}`,
  2806. headers: {
  2807. 'Content-Type': 'application/json; charset=utf-8',
  2808. "accept": "text/event-stream"
  2809. /*'Accept-Language':'zh-CN,zh;q=0.9'*/
  2810. },
  2811. responseType: "stream",
  2812. data: JSON.stringify({
  2813. contents: [{
  2814. parts: [{ text: your_qus }],
  2815. }],
  2816. })
  2817. }).then((stream)=> {
  2818. let reader = stream.response.getReader()
  2819. let answer = [];
  2820. reader.read().then(function processText({done, value}) {
  2821. if (done) {
  2822. console.log("===done==")
  2823. showAnserAndHighlightCodeStr(JSON.parse(answer.join("")).candidates[0].content.parts[0].text)
  2824.  
  2825. return
  2826. }
  2827. try{
  2828. let responseItem = new TextDecoder("utf8").decode(new Uint8Array(value))
  2829. showAnserAndHighlightCodeStr(responseItem)
  2830. answer.push(responseItem)
  2831. console.warn(responseItem)
  2832. }catch (e) {
  2833. console.error(e)
  2834. }
  2835.  
  2836. return reader.read().then(processText)
  2837. },function (reason) {
  2838. console.log(reason)
  2839. Toast.error("未知错误!")
  2840. }).catch((ex)=>{
  2841. console.log(ex)
  2842. Toast.error("未知错误!")
  2843. })
  2844. })
  2845. }
  2846.  
  2847.  
  2848. let csrfToken;
  2849. async function setCsrfToken(){
  2850. let req1 = await GM_fetch({
  2851. method: "GET",
  2852. url: "https://tongyi.aliyun.com/qianwen/",
  2853. headers: {
  2854. "origin":"https://qianwen.aliyun.com",
  2855. "referer":"https://tongyi.aliyun.com/qianwen/"
  2856. }
  2857. })
  2858. let r = req1.responseText;
  2859. console.log(r);
  2860. try{
  2861. csrfToken = /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/g.exec(r)[0];
  2862. console.log("csrfToken:",csrfToken)
  2863. }catch (e) {
  2864. Toast.error("csrfToken获取失败")
  2865. }
  2866. }
  2867. setTimeout(()=>{
  2868. if(getGPTMode()==="TONGYI"){
  2869. setCsrfToken()
  2870. }
  2871. })
  2872.  
  2873.  
  2874. let tongyi_sessionId = '';
  2875. let tongyi_pMsgId;
  2876.  
  2877. //通义千问 2023年5月13日
  2878. async function TONGYI(){
  2879. /*if(tongyi_first){
  2880. let req1 = await GM_fetch({
  2881. method: "POST",
  2882. url: "https://qianwen.aliyun.com/addSession",
  2883. headers: {
  2884. "origin":"https://qianwen.aliyun.com/",
  2885. "referer":"https://qianwen.aliyun.com/chat",
  2886. "Content-Type": "application/json",
  2887. "Bx-V": "2.5.3",
  2888. "x-platform": "pc_tongyi",
  2889. "x-xsrf-token": csrfToken
  2890. },
  2891. data:JSON.stringify({
  2892. "firstQuery": your_qus
  2893. })
  2894. })
  2895. let r = req1.responseText;
  2896. //console.log(r);
  2897.  
  2898. try{
  2899. tongyi_sessionId = JSON.parse(r).data.sessionId;
  2900. tongyi_first = false;
  2901. }catch (e) {
  2902. tongyi_first = true;
  2903. showAnserAndHighlightCodeStr("出错,请确认已登录(不可用)通义官网[通义](https://tongyi.aliyun.com/qianwen/)")
  2904. setTimeout(setCsrfToken)
  2905. }
  2906. }
  2907. */
  2908. showAnserAndHighlightCodeStr("请稍后....该接口需登录(不可用)通义官网[通义](https://tongyi.aliyun.com/qianwen/)")
  2909.  
  2910.  
  2911. let sendData = JSON.stringify({
  2912. "action": "next",
  2913. "userAction": tongyi_sessionId ? "chat" : "new_top",
  2914. // "msgId": generateRandomString(32),
  2915. "parentMsgId": (tongyi_sessionId && tongyi_pMsgId) ? tongyi_pMsgId : generateRandomString(32),
  2916. "requestId": generateRandomString(32),
  2917. "contents": [
  2918. {
  2919. "contentType": "text",
  2920. "content": your_qus,
  2921. "role": "user"
  2922. }
  2923. ],
  2924. "sessionId": tongyi_sessionId ? tongyi_sessionId : '',
  2925. // "sessionId": "",
  2926. "sessionType": "text_chat",
  2927. "model": "",
  2928. "mode": "chat",
  2929. "params": {"fileUploadBatchId": ""}
  2930.  
  2931. })
  2932.  
  2933. GM_fetch({
  2934. method: 'POST',
  2935. url: 'https://qianwen.biz.aliyun.com/dialog/conversation',
  2936. headers: {
  2937. "origin": "https://tongyi.aliyun.com",
  2938. "referer":"https://tongyi.aliyun.com/qianwen/",
  2939. "Content-Type": "application/json",
  2940. "accept": "text/event-stream",
  2941. "x-platform": "pc_tongyi",
  2942. "x-xsrf-token": csrfToken
  2943. },
  2944. responseType: "stream",
  2945. data: sendData
  2946. }).then((stream)=> {
  2947. let reader = stream.response.getReader()
  2948. let answer;
  2949. reader.read().then(function processText({done, value}) {
  2950. if (done) {
  2951. console.log("===done==")
  2952. return
  2953. }
  2954. let responseItem = new TextDecoder("utf-8").decode(value)
  2955. console.log(responseItem)
  2956. /*{
  2957. "aiDisclaimer": false,
  2958. "canFeedback": true,
  2959. "canRegenerate": true,
  2960. "canShare": true,
  2961. "canShow": true,
  2962. "contentFrom": "text",
  2963. "contentType": "text",
  2964. "contents": [
  2965. {
  2966. "content": "你好!有什么我能帮助你的吗?",
  2967. "contentType": "text",
  2968. "id": "102416421db845179064dd046d5ce8d4_0",
  2969. "role": "assistant",
  2970. "status": "generating"
  2971. }
  2972. ],
  2973. "msgId": "102416421db845179064dd046d5ce8d4",
  2974. "msgStatus": "generating",
  2975. "params": {},
  2976. "parentMsgId": "4880983feec04eae862ce2e08d67fc09",
  2977. "sessionId": "95812ea382de4b4e82051a7272d965cb",
  2978. "sessionOpen": true,
  2979. "sessionShare": true,
  2980. "sessionWarnNew": false,
  2981. "stopReason": "null",
  2982. "traceId": "0bc3b2e817159180903973007eb266"
  2983. }*/
  2984.  
  2985. responseItem.split("\n").forEach(item=>{
  2986. try {
  2987. let jsonObj = JSON.parse(item.replace(/data: /gi,"").trim())
  2988.  
  2989. jsonObj.contents.forEach((item)=>{
  2990.  
  2991. if(item.contentType === 'text'){
  2992. let content = item.content;
  2993. console.log(content)
  2994. showAnserAndHighlightCodeStr(content)
  2995. }
  2996. })
  2997.  
  2998.  
  2999. if(!tongyi_sessionId){
  3000. tongyi_sessionId = jsonObj.sessionId;
  3001. console.log("tongyi_sessionId:",tongyi_sessionId)
  3002. }
  3003. if(tongyi_pMsgId !== jsonObj.msgId){
  3004. tongyi_pMsgId = jsonObj.msgId;
  3005. console.log("tongyi_pMsgId:",tongyi_sessionId)
  3006. }
  3007.  
  3008.  
  3009.  
  3010. }catch (ex){}
  3011. })
  3012.  
  3013. return reader.read().then(processText)
  3014. },function (reason) {
  3015. console.log(reason)
  3016. Toast.error("未知错误!")
  3017. }).catch((ex)=>{
  3018. console.log(ex)
  3019. Toast.error("未知错误!")
  3020. })
  3021. })
  3022.  
  3023.  
  3024. }
  3025.  
  3026.  
  3027.  
  3028.  
  3029. //星火相关====start=====
  3030. let sp_appId = 'ihuqg3dmuzcr2kmghumvivsk7c3l4joe';
  3031. let sp_fd = String(+new Date()).slice(-6);//a = (a = String(+new Date)).substring(a.length - 6)
  3032. let sp_chatId;
  3033. let sp_GtToken;
  3034.  
  3035. async function init_sp_appId() {
  3036.  
  3037. sp_appId = 'ihuqg3dmuzcr2kmghumvivsk7c3l4joe'
  3038. return
  3039. //get https://xinghuo.xfyun.cn/chat
  3040. //script defer="defer" src="/static/js/main.04f3ec36.js"></script>
  3041. let req1 = await GM_fetch({
  3042. method: "GET",
  3043. url: "https://xinghuo.xfyun.cn/chat",
  3044. headers: {
  3045. "origin":"https://xinghuo.xfyun.cn",
  3046. "referer":"https://xinghuo.xfyun.cn/"
  3047. }
  3048. })
  3049. let r = req1.responseText;
  3050. //console.log(r);
  3051. let mainjs;
  3052.  
  3053. try{
  3054.  
  3055. mainjs = /src="(\/static\/js\/main.*?.js)"/.exec(r)[1];//https://xinghuo.xfyun.cn/static/js/main.04f3ec36.js
  3056. console.log("mainjs:",mainjs)
  3057. }catch (e) {
  3058. console.error(r)
  3059. Toast.error("出错了,js获取失败")
  3060. }
  3061.  
  3062. if(mainjs){
  3063. console.log("https://xinghuo.xfyun.cn"+ mainjs.trim())
  3064. let req2 = await GM_fetch({
  3065. method: "GET",
  3066. url: "https://xinghuo.xfyun.cn"+ mainjs.trim(),
  3067. headers: {
  3068. "origin":"https://xinghuo.xfyun.cn",
  3069. "referer":"https://xinghuo.xfyun.cn/"
  3070. }
  3071. })
  3072. let rr = req2.responseText;
  3073.  
  3074. console.log(rr.substring(0,100))
  3075. try{
  3076. const re = /appId:"(.*?)"/gi;
  3077. let match;
  3078. while ((match = re.exec(rr)) !== null) {
  3079. console.log(match[1]);
  3080. sp_appId = match[1];
  3081. }
  3082. /*let index = rr.indexOf("appId");
  3083. if (index !== -1) {
  3084. let sp_appId = rr.substring(index, index + 10); // 指定文本
  3085. }*/
  3086. console.log("sp_appId:",sp_appId)
  3087. }catch (e) {
  3088. console.error(e)
  3089. Toast.error("出错了,sp_appId获取失败",)
  3090. }
  3091. }
  3092.  
  3093.  
  3094. }
  3095.  
  3096. /*setTimeout(()=>{
  3097. if(getGPTMode()==="SPARK"){
  3098. init_sp_appId()
  3099. }
  3100. })*/
  3101. async function init_sp_chatId() {
  3102. //https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/create-chat-list
  3103. let req1 = await GM_fetch({
  3104. method: "POST",
  3105. url: "https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/create-chat-list",
  3106. headers: {
  3107. "accept": "application/json, text/plain, */*",
  3108. "x-requested-with": "XMLHttpRequest",
  3109. "origin":"https://xinghuo.xfyun.cn",
  3110. "Content-Type":"application/json",
  3111. "referer":"https://xinghuo.xfyun.cn/desk"
  3112. },
  3113. data:"{}"
  3114. })
  3115. let r = req1.responseText;
  3116. try{
  3117. sp_chatId = JSON.parse(r).data.id;
  3118. console.log("sp_chatId:",sp_chatId)
  3119. }catch (e) {
  3120. console.error(r)
  3121. Toast.error("sp_chatId获取失败")
  3122. }
  3123.  
  3124.  
  3125.  
  3126. }
  3127.  
  3128. setTimeout(()=>{
  3129. if(getGPTMode()==="SPARK"){
  3130. init_sp_chatId()
  3131. }
  3132. },500)
  3133.  
  3134. async function get_sp_GtToken() {
  3135. return new Promise(async (resolve, reject) => {
  3136.  
  3137. //https://riskct.geetest.com/g2/api/v1/pre_load?client_type=h5&callback=geetest_时间戳
  3138. let timestamp = Date.now();
  3139. let req1 = await GM_fetch({
  3140. method: "GET",
  3141. url: `https://riskct.geetest.com/g2/api/v1/pre_load?client_type=h5&callback=geetest_${timestamp}`,
  3142. headers: {
  3143. "accept": "*/*",
  3144. "referer": "https://xinghuo.xfyun.cn/"
  3145. }
  3146. })
  3147. let r = req1.responseText;
  3148. console.log(r);
  3149. try {
  3150. let rr = r.replace(`geetest_${timestamp}(`,
  3151. "");
  3152. rr = rr.substring(0, rr.length - 1)
  3153. console.log("rr", rr)
  3154. let rj = JSON.parse(rr);
  3155. console.log("rj:");
  3156. console.log(rj);
  3157.  
  3158. //====
  3159. let config = {
  3160. appId: sp_appId,
  3161. js: rj.data.js,
  3162. staticPath: rj.data.staticPath,
  3163. gToken: rj.data.gToken
  3164. }
  3165. console.log("config")
  3166. console.log(config)
  3167. setTimeout(() => {
  3168. initGeeGuard(config, (gd) => {
  3169. console.log(gd)
  3170. if (gd.data.gee_token) {
  3171. sp_GtToken = gd.data.gee_token;
  3172. resolve(sp_GtToken)
  3173. }else{
  3174. reject("出错")
  3175. }
  3176. })
  3177. }, 500)
  3178.  
  3179.  
  3180. } catch (e) {
  3181. console.error(e)
  3182. setTimeout(init_sp_chatId)
  3183. reject("出错")
  3184. }
  3185. })
  3186.  
  3187. }
  3188.  
  3189.  
  3190. //解码
  3191. function decodeSpark(src) {
  3192. /*let rv = function(e) {
  3193. return e.replace(/[^A-Za-z0-9\+\/]/g, "")
  3194. }*/
  3195.  
  3196. let dv = function(e) {
  3197. //return Buffer.from(e, "base64").toString("utf8")
  3198. // 将 base64 编码的字符串转换为字节数组
  3199. const bytes = CryptoJS.enc.Base64.parse(e);
  3200. // 将字节数组转换为 UTF-8 字符串
  3201. return bytes.toString(CryptoJS.enc.Utf8);
  3202. }//等价BASE64解码 6KaB
  3203.  
  3204. /*let fv = function(e) {
  3205. return dv(function(e) {
  3206. return rv(e.replace(/[-_]/g, (function(e) {
  3207. return "-" == e ? "+" : "/"
  3208. }
  3209. )))
  3210. }(e))
  3211. };*/
  3212. return dv(src);
  3213. }
  3214.  
  3215.  
  3216.  
  3217. let spark_first = true;
  3218. async function SPARK(){
  3219. showAnserAndHighlightCodeStr("请稍后,第一次切换到该线路需要刷新页面,该线路为官网线路,使用前确保已经登录(不可用)[讯飞星火](https://xinghuo.xfyun.cn/)")
  3220. if(!sp_chatId){
  3221. showAnserAndHighlightCodeStr("chatId为空,请重试。。。使用前确保已经登录(不可用)[讯飞星火](https://xinghuo.xfyun.cn/)")
  3222. init_sp_chatId()
  3223. return
  3224. }
  3225.  
  3226. await get_sp_GtToken()
  3227. console.log("sp_GtToken",sp_GtToken)
  3228. //重命名
  3229. if(spark_first){
  3230. let req1 = await GM_fetch({
  3231. method: "POST",
  3232. url: "https://xinghuo.xfyun.cn/iflygpt/u/chat-list/v1/rename-chat-list",
  3233. headers: {
  3234. "accept": "application/json, text/plain, */*",
  3235. "x-requested-with": "XMLHttpRequest",
  3236. "origin":"https://xinghuo.xfyun.cn",
  3237. "Content-Type":"application/json",
  3238. "referer":"https://xinghuo.xfyun.cn/desk"
  3239. },
  3240. data:JSON.stringify({
  3241. "chatListId": sp_chatId,
  3242. "chatListName": your_qus.substring(0,10)
  3243. })
  3244. })
  3245. let r = req1.responseText;
  3246. console.log("rename chat:",r)
  3247. spark_first = false;
  3248. }
  3249.  
  3250. //提问
  3251.  
  3252. let sendData = `------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"fd\"\r\n\r\n${sp_fd}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"clientType\"\r\n\r\n2\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"chatId\"\r\n\r\n${sp_chatId}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"text\"\r\n\r\n${your_qus}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk\r\nContent-Disposition: form-data; name=\"GtToken\"\r\n\r\n${sp_GtToken}\r\n------WebKitFormBoundaryAS7tSr3osJng5Nxk--\r\n`;
  3253. GM_fetch({
  3254. method: 'POST',
  3255. url: 'https://xinghuo.xfyun.cn/iflygpt-chat/u/chat_message/chat',
  3256. headers: {
  3257. "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryAS7tSr3osJng5Nxk",
  3258. "challenge": "undefined",
  3259. "seccode": "",
  3260. "validate": "undefined",
  3261. "accept": "text/event-stream",
  3262. "x-requested-with": "XMLHttpRequest",
  3263. "origin":"https://xinghuo.xfyun.cn",
  3264. "referer":"https://xinghuo.xfyun.cn/desk"
  3265. },
  3266. responseType: "stream",
  3267. data: sendData
  3268. }).then((stream)=> {
  3269. let reader = stream.response.getReader()
  3270. let ans = []
  3271. //let de = []
  3272. reader.read().then(function processText({done, value}) {
  3273. if (done) {
  3274. console.log("===done==")
  3275. //console.log(de)
  3276. return
  3277. }
  3278. let responseItem = new TextDecoder("utf-8").decode(value)
  3279. console.log(responseItem)
  3280.  
  3281. responseItem.split("\n").forEach(item=>{
  3282. try {
  3283. let ii = item.replace(/data:/gi,"").trim();
  3284. if(ii && ii !==""){
  3285. let chunk = decodeSpark(ii)
  3286. //de.push(item.replace(/data:/gi,"").trim())
  3287. ans.push(chunk)
  3288. showAnserAndHighlightCodeStr(ans.join(""))
  3289. }
  3290. }catch (ex){
  3291. console.error(item)
  3292. }
  3293. })
  3294.  
  3295. return reader.read().then(processText)
  3296. },function (reason) {
  3297. console.log(reason)
  3298. Toast.error("未知错误!")
  3299. }).catch((ex)=>{
  3300. console.log(ex)
  3301. Toast.error("未知错误!")
  3302. })
  3303. })
  3304.  
  3305.  
  3306. }
  3307.  
  3308. //星火相关====end=====
  3309.  
  3310.  
  3311.  
  3312. //天工 ----start--------
  3313.  
  3314. let tg_k_device_hash;
  3315.  
  3316. async function initDeviceHash() {
  3317. if (location.href.includes("tiangong.cn")) {
  3318. tg_k_device_hash = getCookieValue(document.cookie,"k_device_hash");
  3319. console.log("tg_k_device_hash",tg_k_device_hash)
  3320. GM_setValue("tg_k_device_hash", tg_k_device_hash)
  3321. try {
  3322. if(tg_k_device_hash){
  3323. document.querySelector('textarea').placeholder = `device_hash获取成功:${tg_k_device_hash}`
  3324. }else{
  3325. document.querySelector('textarea').placeholder = `device_hash获取失败,请再次刷新.`
  3326. }
  3327. }catch (e) {}
  3328. setTimeout(initDeviceHash,2000)
  3329. } else {
  3330. tg_k_device_hash = GM_getValue("tg_k_device_hash")
  3331. }
  3332. }
  3333.  
  3334. setTimeout(initDeviceHash)
  3335.  
  3336.  
  3337.  
  3338. let tg_conversation_id
  3339. async function TIANGONG(){
  3340. showAnserAndHighlightCodeStr("请稍后...使用该线路,请确保已经登天工官网获取token后刷新页面。[天工AI](https://www.tiangong.cn/)")
  3341. console.log("tg_k_device_hash:",tg_k_device_hash)
  3342. if(!tg_k_device_hash){
  3343. showAnserAndHighlightCodeStr("device_hash错误了。请确保已经登天工官网获取device_hash后刷新页面。[天工AI](https://www.tiangong.cn/)")
  3344. return
  3345. }
  3346.  
  3347.  
  3348.  
  3349. //请求
  3350. let req1 = await GM_fetch({
  3351. method: "POST",
  3352. url: "https://work.tiangong.cn/dialogue-aggregation/dialogue/aggregation/v1/chat/sensitive/words",
  3353. headers: {
  3354. "accept": "application/json, text/plain, */*",
  3355. "origin":"https://www.tiangong.cn",
  3356. "referer":"https://www.tiangong.cn/",
  3357. "channel": "",
  3358. "content-type": "application/json",
  3359. "device": "Web",
  3360. "device_hash": tg_k_device_hash,
  3361. "device_id": tg_k_device_hash,
  3362. },
  3363. data:JSON.stringify({
  3364. data:{
  3365. content: your_qus,
  3366. source: "web"
  3367. }
  3368. })
  3369. })
  3370. let req1Text = req1.responseText;
  3371. console.log(req1Text)
  3372. //获取对话id
  3373. let req2 = await GM_fetch({
  3374. method: "GET",
  3375. url: "https://work.tiangong.cn/agents_api/user/dialogue_list?offset=0",
  3376. headers: {
  3377. "accept": "application/json, text/plain, */*",
  3378. "origin":"https://www.tiangong.cn",
  3379. "referer":"https://www.tiangong.cn/",
  3380. "channel": "",
  3381. "content-type": "application/json",
  3382. "device": "Web",
  3383. "device_hash": tg_k_device_hash,
  3384. "device_id": tg_k_device_hash,
  3385. },
  3386. })
  3387. let req2Text = req2.responseText;
  3388. console.log(req2Text)
  3389. tg_conversation_id = JSON.parse(req2Text).data.datalist[0].session_id
  3390. console.log("tg_conversation_id",tg_conversation_id)
  3391.  
  3392.  
  3393. //获取信息信息
  3394.  
  3395. //连接天工 websocket
  3396.  
  3397. let wssurl = `wss://work.tiangong.cn/dialogue-aggregation/dialogue/aggregation/v2/agent?device=Web&device_id=${tg_k_device_hash}&device_hash=${tg_k_device_hash}`
  3398.  
  3399. let socket = new WebSocket(wssurl);
  3400. socket.addEventListener('open', (event) => {
  3401. console.log('天工 wss 连接成功');
  3402. socket.send(JSON.stringify({
  3403. "agent_id": "016",
  3404. "agent_type": "universal",
  3405. "conversation_id": tg_conversation_id,
  3406. "prompt": {
  3407. "ask_from": "user",
  3408. "ask_id": null,
  3409. "content": your_qus,
  3410. "prompt_content": null,
  3411. "template_id": null,
  3412. "action": null,
  3413. "file": null,
  3414. "template": null,
  3415. "copilot": false,
  3416. "bubble_text": null,
  3417. "publish_agent": null,
  3418. "copilot_option": null
  3419. }
  3420. }))
  3421. });
  3422.  
  3423. let tg_result = []
  3424. socket.addEventListener('message', (event) => {
  3425. console.log('天工 接收到消息:', event.data);
  3426. let revData = event.data;
  3427. try{
  3428. let revJSON = JSON.parse(revData);
  3429. if(revJSON.type == 1){
  3430. try {
  3431. tg_result.push(revJSON.arguments[0].messages[0].text)
  3432. showAnserAndHighlightCodeStr(tg_result.join(""))
  3433. }catch (e) { }
  3434. }
  3435.  
  3436. }catch (ex) { }
  3437.  
  3438. });
  3439.  
  3440.  
  3441.  
  3442. }
  3443.  
  3444.  
  3445. //天工 ----end--------
  3446.  
  3447.  
  3448.  
  3449. //问心一言 ----start---
  3450.  
  3451. let yy_aisearch_id;
  3452. let yy_pvId;
  3453. let yy_sessionId;
  3454.  
  3455. async function initYiYAN(){
  3456. let req1 = await GM_fetch({
  3457. method: "GET",
  3458. url: `https://chat.baidu.com/?pcasync=pc&asyncRenderUrl=&passportStaticPage=https%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fv3Jump.html&from=pc_tab&word=${encodeURI(your_qus)}&source=pd_ic`,
  3459. headers: {
  3460. "accept": "*/*",
  3461. "origin":"https://www.baidu.com",
  3462. "referer":`https://www.baidu.com/`
  3463. },
  3464. data:JSON.stringify({
  3465. data:{}
  3466. })
  3467. })
  3468. let r = req1.responseText;
  3469. yy_aisearch_id = /"aisearch_id":"(.*?)"/i.exec(r)[1];
  3470. yy_pvId = /"pvId":"(.*?)"/i.exec(r)[1];
  3471. yy_sessionId = /"sessionId":"(.*?)"/i.exec(r)[1];
  3472. console.log("yy_aisearch_id:",yy_aisearch_id)
  3473. console.log("yy_pvId:",yy_pvId)
  3474. console.log("yy_sessionId:",yy_sessionId)
  3475. }
  3476. setTimeout(()=>{
  3477. if(getGPTMode() === 'YIYAN'){
  3478. initYiYAN()
  3479. }
  3480. })
  3481. async function YIYAN() {
  3482. showAnserAndHighlightCodeStr("请稍后...该线路为官网线路,使用该线路,请确保已经登百度账号,再刷新页面。[百度](https://www.baidu.com/)")
  3483. GM_fetch({
  3484. method: 'POST',
  3485. url: 'https://chat-ws.baidu.com/aichat/api/conversation',
  3486. headers: {
  3487. "origin":"https://www.baidu.com",
  3488. "referer":`https://www.baidu.com/`,
  3489. "Content-Type": "application/json",
  3490. "accept": "text/event-stream"
  3491. },
  3492. responseType: "stream",
  3493. data: JSON.stringify({
  3494. "message": {
  3495. "inputMethod": "keyboard",
  3496. "isRebuild": false,
  3497. "content": {
  3498. "query": your_qus,
  3499. "qtype": 0
  3500. }
  3501. },
  3502. "sessionId": yy_sessionId,
  3503. "aisearchId": yy_aisearch_id,
  3504. "pvId": yy_pvId
  3505. })
  3506. }).then((stream)=> {
  3507. let reader = stream.response.getReader()
  3508. let ans = []
  3509. let preResponseItem = '';//前一记录
  3510. let combineItem = [];//合并
  3511. let referenceList;//引用
  3512. reader.read().then(function processText({done, value}) {
  3513. if (done) {
  3514. console.log("===done==")
  3515. //console.log(de)
  3516. let result = ans.join("");
  3517. let arr = result.match(/\^(.*?)\^/g);
  3518. let oldArr = arr.slice()
  3519. if(referenceList && referenceList.length > 0){
  3520. for (let i = 0; i < arr.length; i++) {
  3521. for (let j = 0; j < referenceList.length; j++) {
  3522. if(arr[i].includes(`[${j+1}]`)){
  3523. let url = referenceList[j].url;
  3524. arr[i] = arr[i].replace(`[${j+1}]`,`[${j+1}](${url})`)
  3525. }
  3526. }
  3527. }
  3528. }
  3529. console.log("arr:",arr)
  3530. console.log("oldArr:",oldArr)
  3531. for (let i = 0; i < oldArr.length; i++) {
  3532. result = result.replace(oldArr[i],arr[i].replace(/\^/g,""))
  3533. }
  3534. showAnserAndHighlightCodeStr(result)
  3535.  
  3536. return
  3537. }
  3538. let responseItem = new TextDecoder("utf-8").decode(value)
  3539. console.log(responseItem)
  3540. if(!responseItem.includes("event:ping") && !responseItem.startsWith("event:messag")){
  3541. combineItem.push(preResponseItem)
  3542. combineItem.push(responseItem)
  3543. preResponseItem = '';//恢复初始
  3544. responseItem = combineItem.join("")//合并
  3545. console.log("combineItem:",responseItem)
  3546. combineItem = [];//清空
  3547.  
  3548. }else if(!responseItem.includes("event:ping")){
  3549. preResponseItem = responseItem;
  3550. }
  3551.  
  3552.  
  3553. responseItem.split("\n").forEach(item=>{
  3554. try {
  3555. let ii = item.replace(/data:/gi,"").trim();
  3556. if(ii && ii !==""){
  3557. let chunk = JSON.parse(ii).data.message.content.generator.text
  3558. //de.push(item.replace(/data:/gi,"").trim())
  3559. ans.push(chunk)
  3560. showAnserAndHighlightCodeStr(ans.join(""))
  3561. if(JSON.parse(ii).data.message.content.generator.referenceList){
  3562. referenceList = JSON.parse(ii).data.message.content.generator.referenceList
  3563. }
  3564.  
  3565. }
  3566. }catch (ex){
  3567. console.error(item)
  3568. }
  3569. })
  3570.  
  3571. return reader.read().then(processText)
  3572. },function (reason) {
  3573. Toast.error("未知错误!")
  3574. console.log(reason)
  3575. }).catch((ex)=>{
  3576. Toast.error("未知错误!")
  3577. console.log(ex)
  3578. })
  3579. })
  3580.  
  3581. }
  3582. //问心一言 ----end---
  3583.  
  3584.  
  3585. //腾讯混元 ----start-----
  3586. let hunyuan_tUserId = '';
  3587. let hunyuan_count = 0;
  3588.  
  3589. async function initHunyuanID() {
  3590. if (location.href.includes("hunyuan.tencent.com") || location.href.includes("yuanbao.tencent.com")) {
  3591. hunyuan_tUserId = getCookieValue(document.cookie,"hy_user");
  3592. GM_setValue("hunyuan_tUserId", hunyuan_tUserId)
  3593. if(hunyuan_tUserId){
  3594. Toast.info(`hunyuan_tUserId获取成功:${hunyuan_tUserId}`)
  3595. }else{
  3596. setTimeout(initHunyuanID, 5000)
  3597. if(hunyuan_count < 3){
  3598. Toast.info(`hunyuan_tUserId获取失败,请再次刷新!`)
  3599. }
  3600. hunyuan_count++;
  3601. }
  3602.  
  3603. } else {
  3604. hunyuan_tUserId = GM_getValue("hunyuan_tUserId")
  3605. }
  3606. }
  3607. //setTimeout(initHunyuanID)
  3608.  
  3609.  
  3610. let hunyuan_isfirst = true;
  3611. let hunyuan_chatId ;
  3612. async function initHunyuan(){
  3613.  
  3614. let req1 = await GM_fetch({
  3615. method: "POST",
  3616. url: `https://hunyuan.tencent.com/api/generate/id`,
  3617. headers: {
  3618. "accept": "application/json, text/plain, */*",
  3619. "origin":"https://hunyuan.tencent.com",
  3620. "referer":`https://hunyuan.tencent.com/bot/chat`,
  3621. "t-userid": hunyuan_tUserId,
  3622. "x-requested-with": "XMLHttpRequest",
  3623. "x-source": "web"
  3624. },
  3625. data:null
  3626. })
  3627. let r = req1.responseText;
  3628. hunyuan_chatId = r;
  3629. if(hunyuan_chatId) hunyuan_isfirst = false;
  3630. console.error("hunyuan_chatId:",r)
  3631. }
  3632.  
  3633. /* fetch('https://yuanbao.tencent.com/api/chat/ca7b253f-a1a7-4e24-82ca-667cc0fbd98d', {
  3634. method: 'POST',
  3635. headers: {
  3636. 'authority': 'yuanbao.tencent.com',
  3637. 'accept': '*!/!*',
  3638. 'accept-language': 'zh-CN,zh;q=0.9',
  3639. 'cache-control': 'no-cache',
  3640. 'chat_version': 'v1',
  3641. 'content-type': 'text/plain;charset=UTF-8',
  3642. 'cookie': '_ga=GA1.2.1033776250.1698727525; _gcl_au=1.1.484286265.1713846526; hy_source=web; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2229491242%22%2C%22first_id%22%3A%2218b840cf7219d8-044a60801af8344-1f7e152e-1440000-18b840cf7229ea%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E5%BC%95%E8%8D%90%E6%B5%81%E9%87%8F%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMThiODQwY2Y3MjE5ZDgtMDQ0YTYwODAxYWY4MzQ0LTFmN2UxNTJlLTE0NDAwMDAtMThiODQwY2Y3MjI5ZWEiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyOTQ5MTI0MiJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%2229491242%22%7D%2C%22%24device_id%22%3A%2218b840cf7219d8-044a60801af8344-1f7e152e-1440000-18b840cf7229ea%22%7D; hy_user=Bcw9KJaWemFaQ9iL; hy_token=bP9sp/yaXedZmIELMZz0hGSfpb6zW8UN7hFQeec8RFQIVAhWHCHLbFxq0tF5U6pO',
  3643. 'origin': 'https://yuanbao.tencent.com',
  3644. 'pragma': 'no-cache',
  3645. 'referer': 'https://yuanbao.tencent.com/chat/naQivTmsDa',
  3646. 'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
  3647. 'sec-ch-ua-mobile': '?0',
  3648. 'sec-ch-ua-platform': '"Windows"',
  3649. 'sec-fetch-dest': 'empty',
  3650. 'sec-fetch-mode': 'cors',
  3651. 'sec-fetch-site': 'same-origin',
  3652. 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36',
  3653. 'x-requested-with': 'XMLHttpRequest',
  3654. 'x-source': 'web'
  3655. },
  3656. body: '{"model":"gpt_175B_0404","prompt":"你叫我什么","plugin":"Adaptive","displayPrompt":"你很牛吗","displayPromptType":1,"options":{},"multimedia":[],"agentId":"naQivTmsDa","version":"v2"}'
  3657. });
  3658. */
  3659. async function Hunyuan(mtag) {
  3660.  
  3661. showAnserAndHighlightCodeStr("请稍后...deepseek较慢。该线路为官网线路,请确保登录(不可用)[元宝](https://yuanbao.tencent.com/chat)")
  3662.  
  3663. if(!hunyuan_tUserId){
  3664. let req1 = await GM_fetch({
  3665. method: "GET",
  3666. url: `https://yuanbao.tencent.com/api/getuserinfo`,
  3667. headers: {
  3668. "accept": "application/json, text/plain, */*",
  3669. "origin":"https://yuanbao.tencent.com",
  3670. "referer":`https://yuanbao.tencent.com`
  3671. }
  3672. })
  3673. let r = req1.responseText;
  3674. hunyuan_tUserId = JSON.parse(r).userId
  3675. console.warn("hunyuan_tUserId:",hunyuan_tUserId)
  3676. if(!hunyuan_tUserId){
  3677. showAnserAndHighlightCodeStr("UserId获取失败,请登录(不可用)[元宝](https://yuanbao.tencent.com/chat)")
  3678. return
  3679. }
  3680.  
  3681. }
  3682.  
  3683. if(hunyuan_isfirst && !hunyuan_chatId){
  3684. await initHunyuan()
  3685. }
  3686.  
  3687. let payload = JSON.stringify({
  3688. "model": "gpt_175B_0404",
  3689. "prompt": your_qus,
  3690. "displayPrompt": your_qus,
  3691. "displayPromptType": 1,
  3692. "plugin": "Adaptive",
  3693. "isSkipHistory": false
  3694. })
  3695. //deepseek联网 2025.02
  3696. if(mtag === 'deepseek'){
  3697. payload = JSON.stringify({
  3698. "model": "gpt_175B_0404",
  3699. "prompt": your_qus,
  3700. "displayPrompt": your_qus,
  3701. "displayPromptType": 1,
  3702. "plugin": "Adaptive",
  3703. "isSkipHistory": false,
  3704. "chatModelId": "deep_seek",
  3705. "supportFunctions": [
  3706. "supportInternetSearch"
  3707. ]
  3708. })
  3709. }
  3710.  
  3711.  
  3712. GM_fetch({
  3713. method: 'POST',
  3714. url: `https://hunyuan.tencent.com/api/chat/${hunyuan_chatId}`,
  3715. headers: {
  3716. "origin":"https://hunyuan.tencent.com",
  3717. "referer":`https://hunyuan.tencent.com/bot/chat`,
  3718. "chat_version": "v1",
  3719. "content-type": "text/plain;charset=UTF-8",
  3720. "accept": "*/*",
  3721. "t-userid": hunyuan_tUserId,
  3722. "x-requested-with": "XMLHttpRequest",
  3723. "x-source": "web"
  3724. },
  3725. responseType: "stream",
  3726. data: payload
  3727. }).then((stream)=> {
  3728. let reader = stream.response.getReader()
  3729. let ans = []
  3730. reader.read().then(function processText({done, value}) {
  3731. if (done) {
  3732. console.log("===done==")
  3733. //console.log(de)
  3734. let result = ans.join("");
  3735. showAnserAndHighlightCodeStr(result)
  3736.  
  3737. return
  3738. }
  3739. let responseItem = new TextDecoder("utf-8").decode(value)
  3740. console.log(responseItem)
  3741. responseItem.split("\n").forEach(item=>{
  3742. try {
  3743. let ii = item.replace(/data:/gi,"").trim();
  3744. if(ii && ii !==""){
  3745. let chunk = ''
  3746. //de.push(item.replace(/data:/gi,"").trim())
  3747.  
  3748. //add deepseek 2025.02
  3749. if(mtag === 'deepseek'){
  3750. chunk = JSON.parse(ii).content
  3751. }else{
  3752. chunk = JSON.parse(ii).msg
  3753. }
  3754.  
  3755.  
  3756. ans.push(chunk)
  3757. showAnserAndHighlightCodeStr(ans.join(""))
  3758.  
  3759. }
  3760. }catch (ex){
  3761. console.error(item)
  3762. }
  3763. })
  3764.  
  3765. return reader.read().then(processText)
  3766. },function (reason) {
  3767. Toast.error("未知错误!")
  3768. console.log(reason)
  3769. }).catch((ex)=>{
  3770. Toast.error("未知错误!")
  3771. console.log(ex)
  3772. })
  3773. })
  3774.  
  3775. }
  3776.  
  3777.  
  3778.  
  3779. //腾讯混元 ----end-----
  3780.  
  3781.  
  3782. //ChatGLM相关 ----start-----
  3783. //https://chatglm.cn
  3784.  
  3785. let chatgml_token;
  3786. async function init_chatgml_token() {
  3787. if (location.href.includes("chatglm.cn")) {
  3788. chatgml_token = getCookieValue(document.cookie, "chatglm_token")
  3789. GM_setValue("chatgml_token", chatgml_token)
  3790. if (chatgml_token) {
  3791. console.log(`chatgml_token获取成功:${chatgml_token}`)
  3792. } else {
  3793. console.log('invite_Token获取失败,请再次刷新')
  3794. }
  3795.  
  3796. } else if(getGPTMode() === 'ChatGLM' || getGPTMode() === 'ChatGLM4') {
  3797. chatgml_token = await GM_getValue("chatgml_token")
  3798. console.log("chatgml_token:", chatgml_token)
  3799. }
  3800. }
  3801. setTimeout(()=>{
  3802. init_chatgml_token()
  3803. setInterval(init_chatgml_token,5000)
  3804. })
  3805.  
  3806. let chatgml_first = true;
  3807. let chatgml_task_id;
  3808. let chatgml_context_id;
  3809. async function ChatGLM() {
  3810. console.log("chatgml_token:",chatgml_token)
  3811. showAnserAndHighlightCodeStr("请稍后...该线路为官网线路,使用该线路,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3812.  
  3813. if(!chatgml_token){
  3814. setTimeout(init_chatgml_token)
  3815. showAnserAndHighlightCodeStr("init_chatgml_token为空,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3816. return
  3817. }
  3818. if (chatgml_first || !chatgml_task_id) {
  3819. let req1 = await GM_fetch({
  3820. method: "POST",
  3821. url: `https://chatglm.cn/chatglm/backend-api/v1/conversation`,
  3822. headers: {
  3823. "accept": "application/json, text/plain, */*",
  3824. "authorization": `Bearer ${chatgml_token}`,
  3825. "origin": "https://chatglm.cn",
  3826. "content-type": "application/json;charset=UTF-8",
  3827. "referer": `https://chatglm.cn/detail`
  3828. },
  3829. data: JSON.stringify({
  3830. "prompt": your_qus
  3831. })
  3832. })
  3833. let r = req1.responseText;
  3834. let jsonObj = JSON.parse(r);
  3835. try {
  3836. chatgml_task_id = jsonObj.result.task_id;
  3837. console.log("chatgml_task_id:",chatgml_task_id)
  3838. chatgml_first = false;
  3839. }catch (e) {
  3840. showAnserAndHighlightCodeStr("task_id出错了,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3841. return
  3842. }
  3843. }
  3844.  
  3845. let req1 = await GM_fetch({
  3846. method: "POST",
  3847. url: `https://chatglm.cn/chatglm/backend-api/v1/stream_context`,
  3848. headers: {
  3849. "accept": "application/json, text/plain, */*",
  3850. "authorization": `Bearer ${chatgml_token}`,
  3851. "origin": "https://chatglm.cn",
  3852. "content-type": "application/json;charset=UTF-8",
  3853. "referer": `https://chatglm.cn/detail`
  3854. },
  3855. data: JSON.stringify({
  3856. "prompt": your_qus,
  3857. "seed": 69809,
  3858. "max_tokens": 512,
  3859. "conversation_task_id": chatgml_task_id,
  3860. "retry": false,
  3861. "retry_history_task_id": null
  3862. })
  3863. })
  3864. let r = req1.responseText;
  3865. let jsonObj = JSON.parse(r);
  3866. try {
  3867. chatgml_context_id = jsonObj.result.context_id;
  3868. console.log("chatgml_context_id:",chatgml_task_id)
  3869. }catch (e) {
  3870. showAnserAndHighlightCodeStr("context_id出错了,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3871. return
  3872. }
  3873.  
  3874.  
  3875. GM_fetch({
  3876. method: "GET",
  3877. url: `https://chatglm.cn/chatglm/backend-api/v1/stream?context_id=${chatgml_context_id}`,
  3878. headers: {
  3879. "accept": "text/event-stream",
  3880. "origin": "https://chatglm.cn",
  3881. "referer": `https://chatglm.cn/detail`
  3882. },
  3883. responseType:"stream"
  3884. }).then((stream)=> {
  3885. let reader = stream.response.getReader()
  3886.  
  3887. reader.read().then(function processText({done, value}) {
  3888. if (done) {
  3889. return
  3890. }
  3891. let responseItem = new TextDecoder("utf-8").decode(value)
  3892. // console.error(responseItem)
  3893. responseItem = responseItem.split("\n\n");
  3894. console.warn(responseItem)
  3895. responseItem.forEach(item=>{
  3896. try {
  3897. if(item && item.startsWith("event:add") || item.startsWith("event:finish")){
  3898. let ii = item.replace(/data:/gi,"")
  3899. .replace(/event:add/gi,"")
  3900. .replace(/event:finish/gi,"")
  3901. .trim();
  3902. if(ii){
  3903. showAnserAndHighlightCodeStr(ii)
  3904. }
  3905. }
  3906.  
  3907. }catch (ex){
  3908. console.error(item)
  3909. }
  3910. })
  3911.  
  3912. return reader.read().then(processText)
  3913. },function (reason) {
  3914. Toast.error("未知错误!")
  3915. console.log(reason)
  3916. }).catch((ex)=>{
  3917. Toast.error("未知错误!")
  3918. console.log(ex)
  3919. })
  3920. })
  3921.  
  3922.  
  3923. }
  3924.  
  3925. let glm_conversation_id
  3926. async function ChatGLM4(){
  3927. console.log("chatgml_token:",chatgml_token)
  3928. showAnserAndHighlightCodeStr("请稍后...该线路为官网线路,使用该线路,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3929.  
  3930. if(!chatgml_token){
  3931. setTimeout(init_chatgml_token)
  3932. showAnserAndHighlightCodeStr("init_chatgml_token为空,请确保已经登录(不可用)并获取token,再刷新页面。[ChatGLM](https://chatglm.cn/)")
  3933. return
  3934. }
  3935.  
  3936. GM_fetch({
  3937. method: "POST",
  3938. url: `https://chatglm.cn/chatglm/backend-api/assistant/stream`,
  3939. headers: {
  3940. "authorization": `Bearer ${chatgml_token}`,
  3941. "accept": "text/event-stream",
  3942. "content-type": "application/json",
  3943. "origin": "https://chatglm.cn",
  3944. "referer": `https://chatglm.cn/main/alltoolsdetail`
  3945. },
  3946. data:JSON.stringify({
  3947. "assistant_id": "65940acff94777010aa6b796",
  3948. "conversation_id": glm_conversation_id ? glm_conversation_id : "",
  3949. "meta_data": {
  3950. "mention_conversation_id": "",
  3951. "is_test": false,
  3952. "input_question_type": "xxxx",
  3953. "channel": "",
  3954. "draft_id": ""
  3955. },
  3956. "messages": [
  3957. {
  3958. "role": "user",
  3959. "content": [
  3960. {
  3961. "type": "text",
  3962. "text": your_qus
  3963. }
  3964. ]
  3965. }
  3966. ]
  3967. }),
  3968. responseType:"stream"
  3969. }).then((stream)=> {
  3970. let reader = stream.response.getReader()
  3971. let res = []
  3972. reader.read().then(function processText({done, value}) {
  3973. if (done) {
  3974. return
  3975. }
  3976. let responseItem = new TextDecoder("utf-8").decode(value)
  3977. //console.error(responseItem)
  3978. responseItem = responseItem.split("\n\n");
  3979. console.warn(responseItem)
  3980. if(responseItem.length >= 2 && responseItem[responseItem.length - 2].includes("finish")){
  3981.  
  3982. responseItem.forEach(item=>{
  3983. try {
  3984. let resJson = JSON.parse(item.replace(/event:message\ndata:/gi,""))
  3985. let part = resJson.parts[0].content[0].text
  3986. if(resJson.parts[0].status == 'finish'){
  3987. res.push(part)
  3988. showAnserAndHighlightCodeStr(res.join(""))
  3989. }else if (resJson.parts[0].status == 'init'){
  3990. showAnserAndHighlightCodeStr(part)
  3991. }
  3992.  
  3993. if(resJson.conversation_id){
  3994. glm_conversation_id = resJson.conversation_id
  3995. }
  3996.  
  3997. }catch (ex){
  3998. console.error(item)
  3999. }
  4000. })
  4001. }
  4002.  
  4003.  
  4004. return reader.read().then(processText)
  4005. },function (reason) {
  4006. Toast.error("未知错误!")
  4007. console.log(reason)
  4008. }).catch((ex)=>{
  4009. Toast.error("未知错误!")
  4010. console.log(ex)
  4011. })
  4012. })
  4013. }
  4014.  
  4015.  
  4016. //ChatGLM相关 ----start-----
  4017.  
  4018.  
  4019. //智谱AI
  4020. let zhipuToken = '4056fc44f1474c1e85e976577f930e40.O6WKndzKWBjQJWcA';
  4021. let zhipuPrompt = []
  4022. let zhipu_apiKey = localStorage.getItem("ZhipuapiKey")
  4023.  
  4024. function base64UrlEncode(str) {
  4025. let encodedSource = CryptoJS.enc.Base64.stringify(str);
  4026. const reg = new RegExp('/', 'g');
  4027. encodedSource = encodedSource.replace(/=+$/,'').replace(/\+/g,'-').replace(reg,'_');
  4028. return encodedSource;
  4029. }
  4030. function generate_token(apikey, exp_seconds) {
  4031.  
  4032. const [id, secretKey] = apikey.split(".");
  4033. const payload = {
  4034. "api_key": id,
  4035. "exp": Date.now() + exp_seconds * 1000,
  4036. "timestamp": Date.now(),
  4037. // "exp": 1687878553567,
  4038. // "timestamp": 1687877553567
  4039. };
  4040.  
  4041. const encodedHeader = base64UrlEncode(CryptoJS.enc.Utf8.parse(JSON.stringify({ alg: 'HS256', sign_type: 'SIGN', typ: "JWT"})));
  4042. const encodedPayload = base64UrlEncode(CryptoJS.enc.Utf8.parse(JSON.stringify(payload)));
  4043.  
  4044. const signature = CryptoJS.HmacSHA256(encodedHeader + '.' + encodedPayload, secretKey);
  4045.  
  4046. console.log(signature)
  4047. //const encodedSignature = window.btoa(signature);
  4048.  
  4049. const jwt = encodedHeader + '.' + encodedPayload + '.' + base64UrlEncode(signature);
  4050.  
  4051. console.log(jwt);
  4052. return jwt;
  4053. }
  4054. function ZhipuAI(){
  4055. showAnserAndHighlightCodeStr("请稍后。未申请key的,请前往[智谱AI](https://open.bigmodel.cn/usercenter/apikeys)申请,然后点击设置里的更新key")
  4056. if(!localStorage.getItem("ZhipuapiKey")){
  4057. showAnserAndHighlightCodeStr("apikey不存在。请前往[智谱AI](https://open.bigmodel.cn/usercenter/apikeys)申请,然后点击设置里的更新key")
  4058. return
  4059. }
  4060. zhipu_apiKey = zhipu_apiKey || localStorage.getItem("ZhipuapiKey");
  4061. addMessageChain(zhipuPrompt, {"role": "user", "content": your_qus} , 10)
  4062. GM_fetch({
  4063. method: "POST",
  4064. url: `https://open.bigmodel.cn/api/paas/v3/model-api/chatglm_std/sse-invoke`,
  4065. headers: {
  4066. "accept": "text/event-stream",
  4067. "Content-Type":"application/json",
  4068. "Authorization": generate_token(zhipu_apiKey, 1000)
  4069. // "Authorization": 'eyJhbGciOiJIUzI1NiIsInNpZ25fdHlwZSI6IlNJR04iLCJ0eXAiOiJKV1QifQ.eyJhcGlfa2V5IjoiZjM3ZDVlMjFhZDk1NGJhOTM0NmYyOTgwMTgzNDJiMjciLCJleHAiOjE2ODc4Nzg1NTM1NjcsInRpbWVzdGFtcCI6MTY4Nzg3NzU1MzU2N30.e8SMjA0vBaUxXB-WrViFa0-C0qVLechNV5L5s2WoF8c'
  4070. },
  4071. data:JSON.stringify({
  4072. model:"chatglm_std",
  4073. prompt : zhipuPrompt,
  4074. temperature: 0.95,
  4075. top_p: 0.7,
  4076. incremental: true
  4077. }),
  4078. responseType:"stream"
  4079. }).then((stream)=> {
  4080. let reader = stream.response.getReader()
  4081. let ans = [];
  4082. reader.read().then(function processText({done, value}) {
  4083. if (done) {
  4084. if(ans.length > 0){
  4085. addMessageChain(zhipuPrompt, {"role": "assistant", "content": ans.join("")} , 10)
  4086. }
  4087. return
  4088. }
  4089. let responseItem = new TextDecoder("utf-8").decode(value)
  4090. console.error(responseItem)
  4091. responseItem = responseItem.split("\n");
  4092. console.warn(responseItem)
  4093. responseItem.forEach(item=>{
  4094. try {
  4095. if(item && item.startsWith("data:")){
  4096. let ii = item.replace(/data:/gi,"")
  4097. if(ii){
  4098. ans.push(ii)
  4099. showAnserAndHighlightCodeStr(ans.join(""))
  4100. }
  4101. }
  4102. }catch (ex){
  4103. console.error(item)
  4104. }
  4105. })
  4106. return reader.read().then(processText)
  4107. },function (reason) {
  4108. Toast.error("未知错误!")
  4109. console.log(reason)
  4110. }).catch((ex)=>{
  4111. Toast.error("未知错误!")
  4112. console.log(ex)
  4113. })
  4114. })
  4115. }
  4116.  
  4117.  
  4118.  
  4119.  
  4120. //360智脑 -------start------
  4121.  
  4122.  
  4123. let conversation_id;
  4124. async function Zhinao360(){
  4125. showAnserAndHighlightCodeStr("请稍后...该线路为官网线路,使用该线路,请确保已经登录(不可用)[360智脑](https://chat.360.cn/)")
  4126. const sendData = JSON.stringify({
  4127. "prompt": your_qus,
  4128. "conversation_id": conversation_id || "",
  4129. "source_type": "prophet_web",
  4130. "role": "00000001",
  4131. "is_regenerate": false,
  4132. "is_so": false
  4133. });
  4134. console.log(conversation_id)
  4135.  
  4136. GM_fetch({
  4137. method: "POST",
  4138. url: `https://chat.360.cn/backend-api/api/common/chat`,
  4139. headers: {
  4140. "accept": "text/event-stream",
  4141. "origin": "https://chat.360.cn",
  4142. "referer": `https://chat.360.cn/index`,
  4143. "content-type": "application/json",
  4144. },
  4145. data: sendData,
  4146. responseType:"stream"
  4147. }).then((stream)=> {
  4148. let reader = stream.response.getReader()
  4149. let result = []
  4150. reader.read().then(function processText({done, value}) {
  4151. if (done) {
  4152. return
  4153. }
  4154. let responseItem = new TextDecoder("utf-8").decode(value)
  4155. // console.error(responseItem)
  4156. console.warn(responseItem)
  4157. if(responseItem){
  4158. responseItem.split("\n").forEach(item=>{
  4159. try{
  4160. if(item.startsWith("data: CONVERSATIONID####")){
  4161. conversation_id = item.replace(/data: CONVERSATIONID####/gi,"")
  4162.  
  4163. }else if(item.startsWith("data: MESSAGEID####")){
  4164.  
  4165. }else if(item.startsWith("data")){
  4166. let i = item.replace(/data: /gi,"")
  4167. if(i){
  4168. result.push(i)
  4169. }else{
  4170. result.push("\n")
  4171. }
  4172. }
  4173. }catch (e) {}
  4174. })
  4175. showAnserAndHighlightCodeStr(result.join(""))
  4176. }
  4177.  
  4178. return reader.read().then(processText)
  4179. },function (reason) {
  4180. console.log(reason)
  4181. Toast.error("未知错误!")
  4182. }).catch((ex)=>{
  4183. Toast.error("未知错误!")
  4184. console.log(ex)
  4185. })
  4186. })
  4187.  
  4188. }
  4189.  
  4190. //360智脑 -------end------
  4191.  
  4192.  
  4193.  
  4194. //百川AI---start
  4195.  
  4196.  
  4197. function getEagleEyeSessionID() {
  4198. for (var e, t, r = 20, n = new Array(r), a = Date.now().toString(36).split(""); r-- > 0; )
  4199. t = (e = 36 * Math.random() | 0).toString(36),
  4200. n[r] = e % 3 ? t : t.toUpperCase();
  4201. for (var i = 0; i < 8; i++)
  4202. n.splice(3 * i + 2, 0, a[i]);
  4203. return n.join("")
  4204. }
  4205.  
  4206. let EagleEyeSessionID = getEagleEyeSessionID();
  4207.  
  4208. function getRandIP() {
  4209. for (var e = [], t = 0; t < 4; t++) {
  4210. var r = Math.floor(256 * Math.random());
  4211. e[t] = (r > 15 ? "" : "0") + r.toString(16)
  4212. }
  4213. return e.join("").replace(/^0/, "1")
  4214. }
  4215.  
  4216. function getEagleEyeTraceID() {
  4217. let e = getRandIP()
  4218. , t = Date.now()
  4219. , r = 1000
  4220. , a = e + t + r + "cced8";
  4221. return a
  4222. }
  4223.  
  4224. let EagleEyeTraceID = getEagleEyeTraceID()
  4225.  
  4226.  
  4227. let bc_session_id = generateRandomString(11)
  4228. let bc_messageId = generateRandomString(13)
  4229.  
  4230. let bc_userID;
  4231.  
  4232. async function getBCUserID() {
  4233. let rr = await GM_fetch({
  4234. method: "GET",
  4235. url: `https://www.baichuan-ai.com/api/auth/session`
  4236. });
  4237. if (rr.status === 200) {
  4238. console.log(rr)
  4239. let result = JSON.parse(rr.responseText);
  4240. bc_userID = result.user.id;
  4241. } else {
  4242. console.error(rr)
  4243. }
  4244. }
  4245.  
  4246. setTimeout(()=>{
  4247. if(getGPTMode()==="BAICHUAN"){
  4248. getBCUserID()
  4249. }
  4250. })
  4251.  
  4252.  
  4253. let bc_parent_id = 0
  4254. let bc_session_info_id
  4255.  
  4256. async function BAICHUAN() {
  4257. console.log("bc_parent_id",bc_parent_id)
  4258. showAnserAndHighlightCodeStr("请耐心等待,该线路为非流式传输较慢,第一次切换到该线路需要刷新页面,该线路为官网线路,使用前确保已经登录(不可用)[百川](https://www.baichuan-ai.com/chat)")
  4259. if(!bc_userID){
  4260. showAnserAndHighlightCodeStr("userid为空,请重试。。。使用前确保已经登录(不可用)[百川](https://www.baichuan-ai.com/chat)")
  4261. getBCUserID()
  4262. return
  4263. }
  4264.  
  4265. let now = Date.now()
  4266. GM_fetch({
  4267. method: "POST",
  4268. url: `https://www.baichuan-ai.com/api/chat/v1/chat`,
  4269. headers: {
  4270. 'Accept': '*/*',
  4271. 'Content-Type': 'application/json',
  4272. 'EagleEye-SessionID': EagleEyeSessionID,
  4273. 'EagleEye-TraceID': EagleEyeTraceID,
  4274. 'EagleEye-pAppName': 'bc7akk1cwt@b6e253f842cced8',
  4275. 'Origin': 'https://www.baichuan-ai.com',
  4276. 'Referer': 'https://www.baichuan-ai.com/chat',
  4277. 'x-requested-with': 'XMLHttpRequest'
  4278. },
  4279. data: JSON.stringify({
  4280. 'type': 'input',
  4281. 'request_id': uuidv4(),
  4282. 'stream': true,
  4283. 'prompt': {
  4284. 'id': null,
  4285. 'messageId': `Ub${generateRandomString(13)}`,
  4286. 'session_id': bc_session_id,
  4287. 'data': your_qus,
  4288. 'from': 0,
  4289. 'parent_id': bc_parent_id,
  4290. 'created_at': now,
  4291. 'attachments': []
  4292. },
  4293. 'app_info': {
  4294. 'id': 10001,
  4295. 'name': 'baichuan_web'
  4296. },
  4297. 'user_info': {
  4298. 'id': bc_userID,
  4299. 'status': 1
  4300. },
  4301. 'session_info': {
  4302. 'id': bc_session_info_id ? bc_session_info_id: null,
  4303. 'session_id': bc_session_id,
  4304. 'name': '\u65B0\u7684\u5BF9\u8BDD',
  4305. 'created_at': now
  4306. },
  4307. 'assistant_info': {},
  4308. 'parameters': {
  4309. 'repetition_penalty': -1,
  4310. 'temperature': -1,
  4311. 'top_k': -1,
  4312. 'top_p': -1,
  4313. 'max_new_tokens': -1,
  4314. 'do_sample': -1,
  4315. 'regenerate': 0,
  4316. 'wse': true
  4317. },
  4318. 'history': [],
  4319. 'assistant': {},
  4320. 'retry': 3
  4321. }),
  4322. // responseType:"stream"
  4323. }).then((stream)=>{
  4324. let responseText = stream.responseText
  4325. let result = []
  4326. //console.warn(responseText)
  4327. let arr = responseText.split("\n")
  4328. for (let i = 0; i < arr.length; i++) {
  4329. try {
  4330. result.push(JSON.parse(arr[i]).answer.data)
  4331. showAnserAndHighlightCodeStr(result.join(""))
  4332. }catch (e) { }
  4333. }
  4334. showAnserAndHighlightCodeStr(result.join(""))
  4335.  
  4336. // let result = []
  4337. // const reader = stream.response.getReader();
  4338. // reader.read().then(function processText({done, value}) {
  4339. // if (done) {
  4340. // return;
  4341. // }
  4342. // try {
  4343. // let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4344. // console.warn(d)
  4345. //
  4346. // try {
  4347. // result.push(JSON.parse(d).answer.data)
  4348. // showAnserAndHighlightCodeStr(result.join(""))
  4349. // }catch (e) {
  4350. // console.error(d)
  4351. // }
  4352. //
  4353. // try {
  4354. // let v = JSON.parse(d).rds
  4355. // bc_parent_id = v[v.length - 1].id
  4356. // bc_session_info_id = v[0].id
  4357. // }catch (e) {
  4358. // //console.error(d)
  4359. // }
  4360. //
  4361. //
  4362. //
  4363. // } catch (e) {
  4364. // console.log(e)
  4365. // }
  4366. //
  4367. // return reader.read().then(processText);
  4368. // });
  4369. },reason => {
  4370. console.log(reason)
  4371. Toast.error("未知错误!")
  4372. }).catch((ex)=>{
  4373. console.log(ex)
  4374. Toast.error("未知错误!")
  4375. })
  4376.  
  4377.  
  4378. }
  4379. //百川AI---end
  4380.  
  4381.  
  4382. let messageChain_chatforai = []
  4383. let chatforai_coverid = uuidv4()
  4384.  
  4385. const generateSignatureChatforai = async(t,e)=>{
  4386. const {t: a, m: r, id: o} = t
  4387. , s = `${o}:${a}:${r}:${e}`;
  4388. return await digestMessage(s)
  4389. }
  4390.  
  4391. function chatforai() {
  4392.  
  4393. let now = Date.now();
  4394.  
  4395. generateSignatureChatforai({
  4396. t: now,
  4397. m: your_qus,
  4398. id: chatforai_coverid
  4399. }, "D6D4X4g9").then(sign => {
  4400. addMessageChain(messageChain_chatforai, {role: "user", content: your_qus})//连续话
  4401. console.log(sign)
  4402. GM_fetch({
  4403. method: "POST",
  4404. url: "https://chatforai.store/api/handle/provider-openai",
  4405. headers: {
  4406. "Content-Type": "text/plain;charset=UTF-8",
  4407. "Referer": "https://chatforai.store",
  4408. "accept": "*/*",
  4409. "X-Forwarded-For": generateRandomIP(),
  4410. "X-Real-IP": generateRandomIP(),
  4411. "Origin": "https://chatforai.store",
  4412. },
  4413. data: JSON.stringify({
  4414. "conversationId": chatforai_coverid,
  4415. "conversationType": "chat_continuous",
  4416. "botId": "chat_continuous",
  4417. "globalSettings": {
  4418. "baseUrl": "https://api.openai.com",
  4419. "model": "gpt-3.5-turbo",
  4420. "maxTokens": 2048,
  4421. "messageHistorySize": 5,
  4422. "temperature": 0.7,
  4423. "top_p": 1
  4424. },
  4425. "prompt": your_qus,
  4426. "messages": messageChain_chatforai,
  4427. "sign": sign,
  4428. "timestamp": now
  4429. }),
  4430. responseType: "stream"
  4431. }).then((stream) => {
  4432. let result = [];
  4433. const reader = stream.response.getReader();
  4434. reader.read().then(function processText({done, value}) {
  4435. if (done) {
  4436. let finalResult = result.join("")
  4437. try {
  4438. console.log(finalResult)
  4439. addMessageChain(messageChain_chatforai, {
  4440. role: "assistant",
  4441. content: finalResult
  4442. })
  4443. showAnserAndHighlightCodeStr(finalResult)
  4444. } catch (e) {
  4445. console.log(e)
  4446. }
  4447. return;
  4448. }
  4449. try {
  4450. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4451. result.push(d)
  4452. showAnserAndHighlightCodeStr(result.join(""))
  4453. } catch (e) {
  4454. console.log(e)
  4455. }
  4456.  
  4457. return reader.read().then(processText);
  4458. });
  4459. },function (reason) {
  4460. console.log(reason)
  4461. Toast.error("未知错误!" + reason.message)
  4462.  
  4463. }).catch((ex)=>{
  4464. console.log(ex)
  4465. Toast.error("未知错误!" + ex.message)
  4466. });
  4467.  
  4468. });
  4469. }
  4470.  
  4471.  
  4472. async function MixerBox() {
  4473. GM_fetch({
  4474. method: "POST",
  4475. url: `https://chatai.mixerbox.com/api/chat/stream`,
  4476. headers: {
  4477. "Referer": "https://chatai.mixerbox.com/chat",
  4478. "origin": "https://chatai.mixerbox.com",
  4479. "accept": "*/*",
  4480. "content-type": "application/json",
  4481. "user-agent": "Mozilla/5.0 (Android 12; Mobile; rv:107.0) Gecko/107.0 Firefox/107.0"
  4482. },
  4483. data:JSON.stringify({
  4484. "prompt": [
  4485. {
  4486. "role": "user",
  4487. "content": your_qus
  4488. }
  4489. ],
  4490. "lang": "zh",
  4491. "model": "gpt-3.5-turbo",
  4492. "plugins": [],
  4493. "pluginSets": [],
  4494. "getRecommendQuestions": true,
  4495. "isSummarize": false,
  4496. "webVersion": "1.4.5",
  4497. "userAgent": "Mozilla/5.0 (Android 12; Mobile; rv:107.0) Gecko/107.0 Firefox/107.0",
  4498. "isExtension": false
  4499. }),
  4500. responseType:"stream"
  4501. }).then((stream)=>{
  4502. let result = []
  4503. const reader = stream.response.getReader();
  4504. reader.read().then(function processText({done, value}) {
  4505. if (done) {
  4506. return;
  4507. }
  4508. try {
  4509. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4510. console.warn(d)
  4511. d.split("\n").forEach(item=>{
  4512. try {
  4513. if(item.startsWith("data")){
  4514. result.push(item.replace(/data:/gi,""))
  4515. }
  4516. }catch (ex){
  4517.  
  4518. }
  4519. })
  4520. showAnserAndHighlightCodeStr(result.join("").
  4521. replace(/\[space\]/gi," ").
  4522. replace(/\[NEWLINE\]/gi,"\n").
  4523. replace(/message_donedone/gi,"\n").
  4524. replace(/\[DONE\]/gi,"\n"))
  4525.  
  4526. } catch (e) {
  4527. console.log(e)
  4528. }
  4529.  
  4530. return reader.read().then(processText);
  4531. });
  4532. },reason => {
  4533. console.log(reason)
  4534. Toast.error("未知错误!")
  4535. }).catch((ex)=>{
  4536. console.log(ex)
  4537. Toast.error("未知错误!")
  4538. })
  4539.  
  4540.  
  4541. }
  4542.  
  4543.  
  4544.  
  4545. let minimax_group_id = localStorage.getItem("minimax_group_id")//"172531245...";
  4546. let minimax_api_key = localStorage.getItem("minimax_api_key")// "eyJhbGciOi.....
  4547. let minimax_messageChain = [];
  4548. async function miniMax() {
  4549.  
  4550. if(!minimax_group_id || !minimax_api_key){
  4551. showAnserAndHighlightCodeStr("group_id或api_key不存在,请到[https://api.minimax.chat/](https://api.minimax.chat/)注册(不可用),申请。然后点击 设置-》更新秘钥")
  4552. }
  4553.  
  4554. addMessageChain(minimax_messageChain, {
  4555. "sender_type": "USER",
  4556. "sender_name": "用户",
  4557. "text": your_qus
  4558. },10)
  4559.  
  4560. let sendData = {
  4561. "model": "abab5.5-chat",
  4562. "tokens_to_generate": 1024,
  4563. "temperature": 0.9,
  4564. "top_p": 0.95,
  4565. "stream": false,
  4566. "reply_constraints": {
  4567. "sender_type": "BOT",
  4568. "sender_name": "MM智能助理"
  4569. },
  4570. "sample_messages": [],
  4571. "plugins": [],
  4572. "messages": minimax_messageChain,
  4573. "bot_setting": [
  4574. {
  4575. "bot_name": "MM智能助理",
  4576. "content": "MM智能助理是一款由MiniMax自研的,没有调用其他产品的接口的大型语言模型。MiniMax是一家中国科技公司,一直致力于进行大模型相关的研究。"
  4577. }
  4578. ]
  4579. }
  4580.  
  4581.  
  4582. GM_fetch({
  4583. method: "POST",
  4584. url:`https://api.minimax.chat/v1/text/chatcompletion_pro?GroupId=${minimax_group_id}`,
  4585. headers: {
  4586. "Content-Type": "application/json",
  4587. "Authorization": `Bearer ${minimax_api_key}`,
  4588. },
  4589. data: JSON.stringify(sendData),
  4590. responseType:"stream"
  4591. }).then((stream)=>{
  4592. let result = []
  4593. const reader = stream.response.getReader();
  4594. reader.read().then(function processText({done, value}) {
  4595. if (done) {
  4596.  
  4597. addMessageChain(minimax_messageChain,{
  4598. "sender_type": "BOT",
  4599. "sender_name": "MM智能助理",
  4600. "text": result.join("")
  4601. },10)
  4602. return;
  4603. }
  4604. try {
  4605. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4606. console.warn(d)
  4607. result.push(JSON.parse(d).reply)
  4608. showAnserAndHighlightCodeStr(result.join(""))
  4609.  
  4610. } catch (e) {
  4611. console.log(e)
  4612. }
  4613.  
  4614. return reader.read().then(processText);
  4615. });
  4616. },reason => {
  4617. console.log(reason)
  4618. Toast.error("未知错误!")
  4619. }).catch((ex)=>{
  4620. console.log(ex)
  4621. Toast.error("未知错误!")
  4622. })
  4623.  
  4624.  
  4625. }
  4626.  
  4627.  
  4628. //https://ai1.chagpt.fun/
  4629. function CVEOY() {
  4630.  
  4631. let baseURL = "https://free-api.cveoy.top/";
  4632. GM_xmlhttpRequest({
  4633. method: "POST",
  4634. url: baseURL + "v3/completions",
  4635. headers: {
  4636. "Content-Type": "application/json",
  4637. "origin": "https://ai1.chagpt.fun",
  4638. "Referer": baseURL
  4639. },
  4640. data: JSON.stringify({
  4641. prompt: your_qus
  4642. }),
  4643. onloadstart: (stream) => {
  4644. let result = [];
  4645. const reader = stream.response.getReader();
  4646. reader.read().then(function processText({done, value}) {
  4647. if (done) {
  4648.  
  4649. try {
  4650. let finalResult = result.join("")
  4651. console.log(finalResult)
  4652. showAnserAndHighlightCodeStr(finalResult)
  4653. } catch (e) {
  4654. console.log(e)
  4655. Toast.error("未知错误!")
  4656. }
  4657. return;
  4658. }
  4659. try {
  4660. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4661. if(d.match(/wxgpt@qq.com/gi)){
  4662. d = d.replace(/wxgpt@qq.com/gi,"")
  4663. }
  4664. result.push(d);
  4665. console.log(d)
  4666. showAnserAndHighlightCodeStr(result.join(""))
  4667. } catch (e) {
  4668. console.log(e)
  4669. }
  4670.  
  4671. return reader.read().then(processText);
  4672. });
  4673. },
  4674. responseType: "stream",
  4675. onerror: function (err) {
  4676. console.log(err)
  4677. Toast.error("未知错误!")
  4678. }
  4679. });
  4680.  
  4681. }
  4682.  
  4683.  
  4684.  
  4685. //获取A类网站key 2023年5月3日
  4686. async function setNormalKey(url) {
  4687. let response = await GM_fetch({
  4688. method: "GET",
  4689. url: url,
  4690. headers: {
  4691. "Referer": url+"/",
  4692. "origin": url,
  4693. "upgrade-insecure-requests":"1"
  4694. }
  4695. });
  4696. let resp = response.responseText;
  4697. if(!resp){
  4698. response = await GM_fetch({
  4699. method: "GET",
  4700. url: url,
  4701. headers: {
  4702. "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
  4703. "Referer": url+"/",
  4704. "origin": url,
  4705. "cookie":"_h=_1",
  4706. "upgrade-insecure-requests":"1"
  4707. }
  4708. });
  4709. resp = response.responseText;
  4710. }
  4711. let regex = /component-url="(.*?)"/i;
  4712. let match = resp.match(regex);
  4713. let jsurl = match[1];
  4714. console.log("js url:" + jsurl);
  4715. if (!jsurl) {
  4716. //错误
  4717. console.log(resp)
  4718. Toast.error("未知错误!")
  4719. return
  4720. }
  4721. let rr = await GM_fetch({
  4722. method: "GET",
  4723. url: url + jsurl,
  4724. headers: {
  4725. "Referer": url+"/",
  4726. "origin": url,
  4727. "cookie":"_h=_1"
  4728. }
  4729. });
  4730. resp = rr.responseText;
  4731. regex = /\`\$\{\w\}:\$\{\w\}:(.*?)\`/i;
  4732. match = resp.match(regex);
  4733. let key = match[1];
  4734. console.log(url+":key:",key)
  4735. return key
  4736. }
  4737.  
  4738.  
  4739.  
  4740.  
  4741. //https://s.aifree.site/
  4742. let messageChain_aifree = []
  4743. function AIFREE() {
  4744.  
  4745. let now = Date.now();
  4746. let Baseurl = `https://am.aifree.site/`
  4747. generateSignatureWithPkey({
  4748. t:now,
  4749. m: your_qus || "",
  4750. pkey: {}.PUBLIC_SECRET_KEY || ""
  4751. }).then(sign => {
  4752. addMessageChain(messageChain_aifree, {role: "user", content: your_qus})//连续话
  4753. console.log(sign)
  4754. GM_fetch({
  4755. method: "POST",
  4756. url: Baseurl + "api/generate",
  4757. headers: {
  4758. "Content-Type": "text/plain;charset=UTF-8",
  4759. "Referer": Baseurl,
  4760. "accept": "application/json, text/plain, */*"
  4761. },
  4762. data: JSON.stringify({
  4763. messages: messageChain_aifree,
  4764. time: now,
  4765. pass: null,
  4766. sign: sign
  4767. }),
  4768. responseType: "stream"
  4769. }).then((stream) => {
  4770. let result = [];
  4771. const reader = stream.response.getReader();
  4772. reader.read().then(function processText({done, value}) {
  4773. if (done) {
  4774. let finalResult = result.join("")
  4775. try {
  4776. console.log(finalResult)
  4777. addMessageChain(messageChain_aifree, {
  4778. role: "assistant",
  4779. content: finalResult
  4780. })
  4781. showAnserAndHighlightCodeStr(finalResult)
  4782. if(finalResult.includes("Invalid signature") || finalResult.includes("exceeded your current")){
  4783. Toast.error(`无效或过期,请到设置更新key`)
  4784. }
  4785. } catch (e) {
  4786. console.log(e)
  4787. }
  4788. return;
  4789. }
  4790. try {
  4791. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4792. result.push(d)
  4793. showAnserAndHighlightCodeStr(result.join(""))
  4794. } catch (e) {
  4795. console.log(e)
  4796. }
  4797.  
  4798. return reader.read().then(processText);
  4799. });
  4800. },function (reason) {
  4801. console.log(reason)
  4802. Toast.error("未知错误!" + reason.message)
  4803.  
  4804. }).catch((ex)=>{
  4805. console.log(ex)
  4806. Toast.error("未知错误!" + ex.message)
  4807. });
  4808.  
  4809. });
  4810. }
  4811.  
  4812.  
  4813.  
  4814. let formatTime = () => {
  4815. let padZero = (num) => {
  4816. // 如果数字小于 10,前面补一个 0
  4817. return num < 10 ? `0${num}` : num;
  4818. }
  4819. const now = new Date(); // 获取当前时间
  4820. const hours = now.getHours(); // 获取小时
  4821. const minutes = now.getMinutes(); // 获取分钟
  4822. const seconds = now.getSeconds(); // 获取秒数
  4823. // 格式化为 HH:MM:SS 的形式
  4824. return `${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`;
  4825. }
  4826.  
  4827.  
  4828.  
  4829.  
  4830. function TDCHAT(){
  4831. abortXml = GM_xmlhttpRequest({
  4832. method: "POST",
  4833. url: "http://7shi.zw7.lol/chat.php",
  4834. headers: {
  4835. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  4836. "Referer": "http://7shi.zw7.lol/",
  4837. "accept": "application/json, text/plain, */*"
  4838. },
  4839. data: `id=3.5&key=&role=&title=&text=${encodeURIComponent(your_qus).replace(/%/g, '‰')}&length=${your_qus.length}&stream=1`,
  4840. onloadstart: (stream) => {
  4841. let result = [];
  4842. let finalResult = [];
  4843. const reader = stream.response.getReader();
  4844. reader.read().then(function processText({done, value}) {
  4845. if (done) {
  4846. finalResult = result.join("")
  4847. showAnserAndHighlightCodeStr(finalResult.replace(/tdchat/gi,""))
  4848. return;
  4849. }
  4850.  
  4851. try {
  4852. let d = new TextDecoder("utf8").decode(new Uint8Array(value));
  4853. console.log("raw:",d)
  4854. let dd = d.replace(/data: /g, "").split("\n\n")
  4855. console.log("dd:",dd)
  4856. dd.forEach(item=>{
  4857. try {
  4858. let delta = JSON.parse(item).choices[0].delta.content
  4859. result.push(delta)
  4860. showAnserAndHighlightCodeStr(result.join("").replace(/tdchat/gi,""))
  4861. }catch (e) {
  4862.  
  4863. }
  4864. })
  4865. } catch (e) {
  4866. console.log(e)
  4867. }
  4868.  
  4869.  
  4870. return reader.read().then(processText);
  4871. });
  4872. },
  4873. responseType: "stream",
  4874. onerror: function (err) {
  4875. console.log(err)
  4876. Toast.error("未知错误!" + err.message)
  4877. }
  4878. })
  4879.  
  4880. }
  4881.  
  4882.  
  4883. //
  4884. //23-4-25
  4885. function TOYAML() {
  4886.  
  4887. GM_fetch({
  4888. method: "GET",
  4889. url: "https://toyaml.com/streams?q="+encodeURI(your_qus),
  4890. headers: {
  4891. "Referer": "https://toyaml.com/chat.html",
  4892. "accept": "*/*",
  4893. "x-requested-with": "XMLHttpRequest"
  4894.  
  4895. },
  4896. responseType: "stream"
  4897. }).then((stream) => {
  4898. let finalResult = [];
  4899. const reader = stream.response.getReader();
  4900. reader.read().then(function processText({done, value}) {
  4901. if (done) {
  4902. return;
  4903. }
  4904. try {
  4905. // console.log(normalArray)
  4906. let byteArray = new Uint8Array(value);
  4907. let decoder = new TextDecoder('utf-8');
  4908. let nowResult = decoder.decode(byteArray)
  4909. console.log(nowResult)
  4910. if(!nowResult.match(/答案来自/)){
  4911. finalResult.push(nowResult)
  4912. }
  4913. showAnserAndHighlightCodeStr(finalResult.join(""))
  4914.  
  4915. } catch (ex) {
  4916. console.log(ex)
  4917. }
  4918.  
  4919. return reader.read().then(processText);
  4920. });
  4921. }).catch((ex)=>{
  4922. console.log(ex)
  4923. Toast.error("未知错误!" + ex.message)
  4924. })
  4925.  
  4926.  
  4927.  
  4928.  
  4929. }
  4930.  
  4931.  
  4932.  
  4933.  
  4934. //默认设置
  4935. setTimeout(()=>{
  4936. if(localStorage.getItem('GPTMODE')){
  4937. const selectEl = document.getElementById('modeSelect');
  4938. let optionElements = selectEl.querySelectorAll("option");
  4939. for (let op in optionElements) {
  4940. if(optionElements[op].value === localStorage.getItem('GPTMODE')){
  4941. optionElements[op].setAttribute("selected", "selected");
  4942. break;
  4943. }
  4944. }
  4945. }
  4946.  
  4947. if(localStorage.getItem('gpt_font_size')){
  4948. document.querySelector("#gptDiv").style.fontSize = localStorage.getItem('gpt_font_size');
  4949. }
  4950.  
  4951. //禁用历史
  4952. if(localStorage.getItem('history_disable')){
  4953. let dis = localStorage.getItem('history_disable');
  4954. history_disable = (dis === 'true' ? true : false);
  4955. }
  4956.  
  4957. },1000)
  4958.  
  4959.  
  4960. })();

QingJ © 2025

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