聊天章鱼

🐙 让章鱼为您发送多条信息

当前为 2023-05-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name chat-octopus
  3. // @namespace https://github.com/mefengl
  4. // @version 0.2.16
  5. // @description 🐙 let octopus send multiple messages for you
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  7. // @author mefengl
  8. // @match https://chat.openai.com/*
  9. // @match https://bard.google.com/*
  10. // @match https://www.bing.com/search?q=Bing+AI*
  11. // @require https://cdn.staticfile.org/jquery/3.6.1/jquery.min.js
  12. // @grant GM_openInTab
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_unregisterMenuCommand
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @grant GM_addValueChangeListener
  18. // @license MIT
  19.  
  20. // @name:en Chat Octopus
  21. // @description:en 🐙 let octopus send multiple messages for you
  22. // @name:zh-CN 聊天章鱼
  23. // @description:zh-CN 🐙 让章鱼为您发送多条信息
  24. // @name:es Chat Pulpo
  25. // @description:es 🐙 deja que el pulpo envíe múltiples mensajes por ti
  26. // @name:hi चैट ऑक्टोपस
  27. // @description:hi 🐙 आपके लिए कई संदेश भेजने के लिए ऑक्टोपस की अनुमति दें
  28. // @name:ar أخطبوط الدردشة
  29. // @description:ar 🐙 دع الأخطبوط يرسل رسائل متعددة نيابة عنك
  30. // @name:pt Chat Polvo
  31. // @description:pt 🐙 deixe o polvo enviar várias mensagens para você
  32. // @name:ru Чат-осьминог
  33. // @description:ru 🐙 позвольте осьминогу отправлять несколько сообщений за вас
  34. // @name:ja チャットオクトパス
  35. // @description:ja 🐙 タコがあなたに代わって複数のメッセージを送る
  36. // @name:de Chat-Oktopus
  37. // @description:de 🐙 Lassen Sie den Oktopus mehrere Nachrichten für Sie senden
  38. // @name:fr Chat Poulpe
  39. // @description:fr 🐙 laissez la pieuvre envoyer plusieurs messages pour vous
  40. // ==/UserScript==
  41. "use strict";
  42. (() => {
  43. var __async = (__this, __arguments, generator) => {
  44. return new Promise((resolve, reject) => {
  45. var fulfilled = (value) => {
  46. try {
  47. step(generator.next(value));
  48. } catch (e) {
  49. reject(e);
  50. }
  51. };
  52. var rejected = (value) => {
  53. try {
  54. step(generator.throw(value));
  55. } catch (e) {
  56. reject(e);
  57. }
  58. };
  59. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  60. step((generator = generator.apply(__this, __arguments)).next());
  61. });
  62. };
  63.  
  64. // ../../packages/chatkit/dist/chunk-QXAXOUZS.mjs
  65. var __defProp = Object.defineProperty;
  66. var __export = (target, all) => {
  67. for (var name in all)
  68. __defProp(target, name, { get: all[name], enumerable: true });
  69. };
  70.  
  71. // ../../packages/chatkit/dist/chunk-75IWQF6O.mjs
  72. var chatgpt_exports = {};
  73. __export(chatgpt_exports, {
  74. getContinueGeneratingButton: () => getContinueGeneratingButton,
  75. getConversation: () => getConversation,
  76. getLastResponse: () => getLastResponse,
  77. getLastResponseElement: () => getLastResponseElement,
  78. getModelSelectButton: () => getModelSelectButton,
  79. getNewModelSelectButtons: () => getNewModelSelectButtons,
  80. getRegenerateButton: () => getRegenerateButton,
  81. getStopGeneratingButton: () => getStopGeneratingButton,
  82. getSubmitButton: () => getSubmitButton,
  83. getTextarea: () => getTextarea,
  84. getTextareaValue: () => getTextareaValue,
  85. hasNewModelSelectButtons: () => hasNewModelSelectButtons,
  86. isConversationStarted: () => isConversationStarted,
  87. isGenerating: () => isGenerating,
  88. isHorizontalConversation: () => isHorizontalConversation,
  89. onSend: () => onSend,
  90. regenerate: () => regenerate,
  91. send: () => send,
  92. setHorizontalConversation: () => setHorizontalConversation,
  93. setPromptListener: () => setPromptListener,
  94. setPureConversation: () => setPureConversation,
  95. setTextarea: () => setTextarea,
  96. waitForIdle: () => waitForIdle
  97. });
  98. function getTextarea() {
  99. const form = document.querySelector("form");
  100. if (!form)
  101. return;
  102. const textareas = form.querySelectorAll("textarea");
  103. const result = textareas[0];
  104. return result;
  105. }
  106. function getSubmitButton() {
  107. const textarea = getTextarea();
  108. if (!textarea)
  109. return;
  110. return textarea.nextElementSibling;
  111. }
  112. function getRegenerateButton() {
  113. const form = document.querySelector("form");
  114. if (!form)
  115. return;
  116. const buttons = form.querySelectorAll("button");
  117. const result = Array.from(buttons).find((button) => {
  118. var _a;
  119. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("regenerate");
  120. });
  121. return result;
  122. }
  123. function getContinueGeneratingButton() {
  124. const form = document.querySelector("form");
  125. if (!form)
  126. return;
  127. const buttons = form.querySelectorAll("button");
  128. const result = Array.from(buttons).find((button) => {
  129. var _a;
  130. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("continue generating");
  131. });
  132. return result;
  133. }
  134. function getStopGeneratingButton() {
  135. const form = document.querySelector("form");
  136. if (!form)
  137. return;
  138. const buttons = form.querySelectorAll("button");
  139. const result = Array.from(buttons).find((button) => {
  140. var _a;
  141. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("stop generating");
  142. });
  143. return result;
  144. }
  145. function getLastResponseElement() {
  146. const responseElements = document.querySelectorAll(".group.w-full");
  147. return responseElements[responseElements.length - 1];
  148. }
  149. function getLastResponse() {
  150. const lastResponseElement = getLastResponseElement();
  151. if (!lastResponseElement)
  152. return;
  153. const lastResponse = lastResponseElement.textContent;
  154. return lastResponse;
  155. }
  156. function getTextareaValue() {
  157. var _a;
  158. return ((_a = getTextarea()) == null ? void 0 : _a.value) || "";
  159. }
  160. function setTextarea(message) {
  161. const textarea = getTextarea();
  162. if (!textarea)
  163. return;
  164. textarea.value = message;
  165. textarea.dispatchEvent(new Event("input"));
  166. }
  167. function send(message) {
  168. setTextarea(message);
  169. const textarea = getTextarea();
  170. if (!textarea)
  171. return;
  172. textarea.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
  173. }
  174. function regenerate() {
  175. const regenerateButton = getRegenerateButton();
  176. if (!regenerateButton)
  177. return;
  178. regenerateButton.click();
  179. }
  180. function onSend(callback) {
  181. const textarea = getTextarea();
  182. if (!textarea)
  183. return;
  184. textarea.addEventListener("keydown", function(event) {
  185. if (event.key === "Enter" && !event.shiftKey) {
  186. callback();
  187. }
  188. });
  189. const sendButton = getSubmitButton();
  190. if (!sendButton)
  191. return;
  192. sendButton.addEventListener("mousedown", callback);
  193. }
  194. function isGenerating() {
  195. var _a, _b;
  196. return ((_b = (_a = getSubmitButton()) == null ? void 0 : _a.firstElementChild) == null ? void 0 : _b.childElementCount) === 3;
  197. }
  198. function waitForIdle() {
  199. return new Promise((resolve) => {
  200. const interval = setInterval(() => {
  201. if (!isGenerating()) {
  202. clearInterval(interval);
  203. resolve();
  204. }
  205. }, 1e3);
  206. });
  207. }
  208. function setPromptListener(key = "prompt_texts") {
  209. let last_trigger_time = +/* @__PURE__ */ new Date();
  210. if (location.href.includes("chat.openai")) {
  211. GM_addValueChangeListener(key, (name, old_value, new_value) => __async(this, null, function* () {
  212. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  213. return;
  214. }
  215. last_trigger_time = +/* @__PURE__ */ new Date();
  216. setTimeout(() => __async(this, null, function* () {
  217. const prompt_texts = new_value;
  218. if (prompt_texts.length > 0) {
  219. let firstTime = true;
  220. while (prompt_texts.length > 0) {
  221. if (!firstTime) {
  222. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  223. }
  224. if (!firstTime && isGenerating()) {
  225. continue;
  226. }
  227. firstTime = false;
  228. const prompt_text = prompt_texts.shift() || "";
  229. send(prompt_text);
  230. }
  231. }
  232. }), 0);
  233. GM_setValue(key, []);
  234. }));
  235. }
  236. }
  237. function getConversation() {
  238. var _a, _b;
  239. return (_b = (_a = document.querySelector('div[class^="react-scroll-to-bottom"]')) == null ? void 0 : _a.firstChild) == null ? void 0 : _b.firstChild;
  240. }
  241. function getModelSelectButton() {
  242. const conversation = getConversation();
  243. if (!conversation)
  244. return;
  245. return Array.from(conversation.querySelectorAll("button")).find((button) => {
  246. var _a;
  247. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("model");
  248. });
  249. }
  250. function getNewModelSelectButtons() {
  251. return Array.from(document.querySelectorAll("[class^='group/button']"));
  252. }
  253. function hasNewModelSelectButtons() {
  254. return getNewModelSelectButtons().length > 0;
  255. }
  256. function isConversationStarted() {
  257. return !getModelSelectButton();
  258. }
  259. function setPureConversation() {
  260. const conversation = getConversation();
  261. if (!conversation)
  262. return;
  263. const firstChild = conversation.firstChild;
  264. if (!firstChild)
  265. return;
  266. const newDiv = document.createElement("div");
  267. conversation.insertBefore(newDiv, firstChild.nextSibling);
  268. }
  269. function isHorizontalConversation() {
  270. const conversation = getConversation();
  271. if (!conversation)
  272. return true;
  273. if (!isConversationStarted())
  274. return true;
  275. return conversation.classList.contains("grid");
  276. }
  277. function setHorizontalConversation() {
  278. if (isHorizontalConversation())
  279. return;
  280. setPureConversation();
  281. const conversation = getConversation();
  282. if (!conversation)
  283. return;
  284. conversation.classList.remove("flex", "flex-col", "items-center");
  285. conversation.classList.add("grid", "grid-cols-2", "place-items-center");
  286. }
  287.  
  288. // ../../packages/chatkit/dist/chunk-SIBHE5N3.mjs
  289. var bing_exports = {};
  290. __export(bing_exports, {
  291. getActionBar: () => getActionBar,
  292. getChatTurns: () => getChatTurns,
  293. getConversation: () => getConversation2,
  294. getLastChatTurn: () => getLastChatTurn,
  295. getLastResponse: () => getLastResponse2,
  296. getLastResponseText: () => getLastResponseText,
  297. getNewChatButton: () => getNewChatButton,
  298. getRegenerateButton: () => getRegenerateButton2,
  299. getStopGeneratingButton: () => getStopGeneratingButton2,
  300. getSubmitButton: () => getSubmitButton2,
  301. getSuggestionBar: () => getSuggestionBar,
  302. getSuggestionBarButtons: () => getSuggestionBarButtons,
  303. getTextarea: () => getTextarea2,
  304. onSend: () => onSend2,
  305. send: () => send2
  306. });
  307. function getActionBar() {
  308. var _a, _b, _c;
  309. return ((_c = (_b = (_a = document.querySelector("cib-serp")) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelector("cib-action-bar")) == null ? void 0 : _c.shadowRoot) || null;
  310. }
  311. function getSubmitButton2() {
  312. const actionBar = getActionBar();
  313. if (!actionBar) {
  314. return null;
  315. }
  316. return actionBar.querySelector('button[aria-label="Submit"]');
  317. }
  318. function getTextarea2() {
  319. const actionBar = getActionBar();
  320. if (!actionBar) {
  321. return null;
  322. }
  323. return actionBar.querySelector("textarea");
  324. }
  325. function getStopGeneratingButton2() {
  326. var _a, _b;
  327. const actionBar = getActionBar();
  328. if (!actionBar) {
  329. return null;
  330. }
  331. const stopGeneratingButton = (_b = (_a = actionBar.querySelector("cib-typing-indicator")) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelector('button[aria-label="Stop Responding"]');
  332. if (!stopGeneratingButton) {
  333. return null;
  334. }
  335. if (stopGeneratingButton.disabled) {
  336. return null;
  337. }
  338. return stopGeneratingButton;
  339. }
  340. function getNewChatButton() {
  341. const actionBar = getActionBar();
  342. if (!actionBar) {
  343. return null;
  344. }
  345. return actionBar.querySelector('button[aria-label="New topic"]');
  346. }
  347. function getConversation2() {
  348. var _a, _b, _c;
  349. return ((_c = (_b = (_a = document.querySelector("cib-serp")) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelector("cib-conversation")) == null ? void 0 : _c.shadowRoot) || null;
  350. }
  351. function getChatTurns() {
  352. const conversation = getConversation2();
  353. if (!conversation) {
  354. return null;
  355. }
  356. return Array.from(conversation.querySelectorAll("cib-chat-turn")).map((t) => t.shadowRoot);
  357. }
  358. function getSuggestionBar() {
  359. var _a;
  360. const conversation = getConversation2();
  361. if (!conversation) {
  362. return null;
  363. }
  364. return ((_a = conversation.querySelector("cib-suggestion-bar")) == null ? void 0 : _a.shadowRoot) || null;
  365. }
  366. function getSuggestionBarButtons() {
  367. const suggestionBar = getSuggestionBar();
  368. if (!suggestionBar) {
  369. return [];
  370. }
  371. const suggestionItems = Array.from(suggestionBar.querySelectorAll("cib-suggestion-item"));
  372. return suggestionItems.map((i) => {
  373. var _a;
  374. return (_a = i.shadowRoot) == null ? void 0 : _a.querySelector("button");
  375. });
  376. }
  377. function getRegenerateButton2() {
  378. const suggestionBarButtons = getSuggestionBarButtons();
  379. if (!suggestionBarButtons.length) {
  380. return null;
  381. }
  382. return suggestionBarButtons[0];
  383. }
  384. function getLastChatTurn() {
  385. const chatTurns = getChatTurns();
  386. if (!chatTurns) {
  387. return null;
  388. }
  389. return chatTurns[chatTurns.length - 1];
  390. }
  391. function getLastResponse2() {
  392. var _a;
  393. const lastChatTurn = getLastChatTurn();
  394. if (!lastChatTurn) {
  395. return null;
  396. }
  397. return ((_a = lastChatTurn.querySelectorAll("cib-message-group")[1]) == null ? void 0 : _a.shadowRoot) || null;
  398. }
  399. function getLastResponseText() {
  400. var _a;
  401. const lastResponse = getLastResponse2();
  402. if (!lastResponse) {
  403. return null;
  404. }
  405. const message = Array.from(lastResponse.querySelectorAll("cib-message")).map((m) => m.shadowRoot).find((m) => m == null ? void 0 : m.querySelector("cib-shared"));
  406. return ((_a = message == null ? void 0 : message.textContent) == null ? void 0 : _a.trim()) || null;
  407. }
  408. function send2(text) {
  409. const textarea = getTextarea2();
  410. if (!textarea) {
  411. return;
  412. }
  413. textarea.value = text;
  414. textarea.dispatchEvent(new Event("input"));
  415. const submitButton = getSubmitButton2();
  416. if (!submitButton) {
  417. return;
  418. }
  419. submitButton.click();
  420. }
  421. function onSend2(callback) {
  422. const textarea = getTextarea2();
  423. if (!textarea)
  424. return;
  425. textarea.addEventListener("keydown", function(event) {
  426. if (event.key === "Enter" && !event.shiftKey) {
  427. callback();
  428. }
  429. });
  430. const sendButton = getSubmitButton2();
  431. if (!sendButton)
  432. return;
  433. sendButton.addEventListener("mousedown", callback);
  434. }
  435.  
  436. // ../../packages/chatkit/dist/chunk-ABU253YF.mjs
  437. var bard_exports = {};
  438. __export(bard_exports, {
  439. getInputArea: () => getInputArea,
  440. getLastPrompt: () => getLastPrompt,
  441. getLatestPromptText: () => getLatestPromptText,
  442. getRegenerateButton: () => getRegenerateButton3,
  443. getSubmitButton: () => getSubmitButton3,
  444. getTextarea: () => getTextarea3,
  445. onSend: () => onSend3,
  446. send: () => send3
  447. });
  448. function getSubmitButton3() {
  449. return document.querySelector('button[aria-label="Send message"]');
  450. }
  451. function getInputArea() {
  452. return document.querySelector(".input-area");
  453. }
  454. function getTextarea3() {
  455. const inputArea = getInputArea();
  456. return inputArea ? inputArea.querySelector("textarea") : null;
  457. }
  458. function getRegenerateButton3() {
  459. return document.querySelector('button[aria-label="Retry"]');
  460. }
  461. function getLastPrompt() {
  462. const promptElements = document.querySelectorAll(".query-text");
  463. const lastPrompt = promptElements[promptElements.length - 1];
  464. return lastPrompt;
  465. }
  466. function getLatestPromptText() {
  467. const lastPrompt = getLastPrompt();
  468. if (!lastPrompt)
  469. return "";
  470. const lastPromptText = lastPrompt.textContent;
  471. return lastPromptText || "";
  472. }
  473. function send3(text) {
  474. const textarea = getTextarea3();
  475. if (!textarea)
  476. return;
  477. textarea.value = text;
  478. textarea.dispatchEvent(new Event("input"));
  479. const submitButton = getSubmitButton3();
  480. if (!submitButton)
  481. return;
  482. submitButton.click();
  483. }
  484. function onSend3(callback) {
  485. const textarea = getTextarea3();
  486. if (!textarea)
  487. return;
  488. textarea.addEventListener("keydown", function(event) {
  489. if (event.key === "Enter" && !event.shiftKey) {
  490. callback();
  491. }
  492. });
  493. const sendButton = getSubmitButton3();
  494. if (!sendButton)
  495. return;
  496. sendButton.addEventListener("mousedown", callback);
  497. }
  498.  
  499. // src/index.js
  500. (function() {
  501. "use strict";
  502. const default_menu_all = {};
  503. const menu_all = GM_getValue("menu_all", default_menu_all);
  504. const menus = [
  505. { checker: () => location.href.includes("chat.openai"), name: "openai", value: true },
  506. { checker: () => location.href.includes("bard.google"), name: "bard", value: true },
  507. { checker: () => location.href.includes("Bing+AI"), name: "bing", value: true }
  508. ];
  509. menus.forEach((menu) => {
  510. $(() => menu.checker() && GM_setValue(menu.name, true));
  511. if (GM_getValue(menu.name) == true) {
  512. default_menu_all[menu.name] = menu.value;
  513. }
  514. });
  515. for (let name in default_menu_all) {
  516. if (!(name in menu_all)) {
  517. menu_all[name] = default_menu_all[name];
  518. }
  519. }
  520. const menu_id = GM_getValue("menu_id", {});
  521. function registerMenuCommand(name, value) {
  522. const menuText = ` ${name}\uFF1A${value ? "\u2705" : "\u274C"}`;
  523. const commandCallback = () => {
  524. menu_all[name] = !menu_all[name];
  525. GM_setValue("menu_all", menu_all);
  526. update_menu();
  527. location.reload();
  528. };
  529. return GM_registerMenuCommand(menuText, commandCallback);
  530. }
  531. function update_menu() {
  532. for (let name in menu_all) {
  533. const value = menu_all[name];
  534. if (menu_id[name]) {
  535. GM_unregisterMenuCommand(menu_id[name]);
  536. }
  537. menu_id[name] = registerMenuCommand(name, value);
  538. }
  539. GM_setValue("menu_id", menu_id);
  540. }
  541. update_menu();
  542. let chatgpt_last_prompt = "";
  543. $(() => {
  544. if (menu_all.openai && location.href.includes("chat.openai")) {
  545. chatgpt_exports.onSend(() => {
  546. const textarea = chatgpt_exports.getTextarea();
  547. if (!textarea) {
  548. return;
  549. }
  550. const prompt = textarea.value;
  551. chatgpt_last_prompt = prompt;
  552. GM_setValue("bard_prompt_texts", [prompt]);
  553. GM_setValue("bing_prompt_texts", [prompt]);
  554. });
  555. }
  556. });
  557. let last_trigger_time = +/* @__PURE__ */ new Date();
  558. $(() => {
  559. if (location.href.includes("chat.openai")) {
  560. GM_addValueChangeListener("chatgpt_prompt_texts", (name, old_value, new_value) => {
  561. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  562. return;
  563. }
  564. last_trigger_time = +/* @__PURE__ */ new Date();
  565. setTimeout(() => __async(this, null, function* () {
  566. const prompt_texts = new_value;
  567. if (prompt_texts.length > 0) {
  568. let firstTime = true;
  569. while (prompt_texts.length > 0) {
  570. if (!firstTime) {
  571. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  572. }
  573. if (!firstTime && chatgpt_exports.getRegenerateButton() == void 0) {
  574. continue;
  575. }
  576. firstTime = false;
  577. const prompt_text = prompt_texts.shift();
  578. if (prompt_text === chatgpt_last_prompt) {
  579. continue;
  580. }
  581. chatgpt_exports.send(prompt_text);
  582. }
  583. }
  584. }), 0);
  585. GM_setValue("chatgpt_prompt_texts", []);
  586. });
  587. }
  588. });
  589. let bard_last_prompt = "";
  590. $(() => __async(this, null, function* () {
  591. if (menu_all.bard && location.href.includes("bard.google")) {
  592. while (!bard_exports.getSubmitButton()) {
  593. yield new Promise((resolve) => setTimeout(resolve, 500));
  594. }
  595. bard_exports.onSend(() => {
  596. const textarea = bard_exports.getTextarea();
  597. if (!textarea) {
  598. return;
  599. }
  600. let prompt = textarea.value;
  601. if (!prompt) {
  602. prompt = bard_exports.getLatestPromptText();
  603. }
  604. bard_last_prompt = prompt;
  605. GM_setValue("chatgpt_prompt_texts", [prompt]);
  606. GM_setValue("bing_prompt_texts", [prompt]);
  607. });
  608. }
  609. }));
  610. let lastTriggerTime = +/* @__PURE__ */ new Date();
  611. if (location.href.includes("bard.google")) {
  612. GM_addValueChangeListener("bard_prompt_texts", (name, old_value, new_value) => {
  613. if (+/* @__PURE__ */ new Date() - lastTriggerTime < 500) {
  614. return;
  615. }
  616. lastTriggerTime = +/* @__PURE__ */ new Date();
  617. setTimeout(() => __async(this, null, function* () {
  618. const promptTexts = new_value;
  619. if (promptTexts.length > 0) {
  620. let firstTime = true;
  621. while (promptTexts.length > 0) {
  622. if (!firstTime) {
  623. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  624. }
  625. if (!firstTime && bard_exports.getRegenerateButton() == void 0) {
  626. continue;
  627. }
  628. firstTime = false;
  629. const promptText = promptTexts.shift();
  630. if (promptText === bard_last_prompt) {
  631. continue;
  632. }
  633. bard_exports.send(promptText);
  634. }
  635. }
  636. }), 0);
  637. GM_setValue("bard_prompt_texts", []);
  638. });
  639. }
  640. let bing_last_prompt = "";
  641. $(() => __async(this, null, function* () {
  642. if (menu_all.bing && location.href.includes("Bing+AI")) {
  643. while (!bing_exports.getSubmitButton()) {
  644. yield new Promise((resolve) => setTimeout(resolve, 500));
  645. }
  646. bing_exports.onSend(() => {
  647. const textarea = bing_exports.getTextarea();
  648. if (!textarea) {
  649. return;
  650. }
  651. const prompt = textarea.value;
  652. bing_last_prompt = prompt;
  653. GM_setValue("chatgpt_prompt_texts", [prompt]);
  654. GM_setValue("bard_prompt_texts", [prompt]);
  655. });
  656. }
  657. }));
  658. let last_trigger_time_bing = +/* @__PURE__ */ new Date();
  659. if (location.href.includes("Bing+AI")) {
  660. GM_addValueChangeListener("bing_prompt_texts", (name, old_value, new_value) => {
  661. if (+/* @__PURE__ */ new Date() - last_trigger_time_bing < 500) {
  662. return;
  663. }
  664. last_trigger_time_bing = +/* @__PURE__ */ new Date();
  665. setTimeout(() => __async(this, null, function* () {
  666. const prompt_texts = new_value;
  667. if (prompt_texts.length > 0) {
  668. let firstTime = true;
  669. while (prompt_texts.length > 0) {
  670. if (!firstTime) {
  671. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  672. }
  673. if (!firstTime && bing_exports.getStopGeneratingButton() != void 0) {
  674. continue;
  675. }
  676. firstTime = false;
  677. const prompt_text = prompt_texts.shift();
  678. if (prompt_text === bing_last_prompt) {
  679. continue;
  680. }
  681. bing_exports.send(prompt_text);
  682. }
  683. }
  684. }), 0);
  685. GM_setValue("bing_prompt_texts", []);
  686. });
  687. }
  688. })();
  689. })();

QingJ © 2025

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