chat-octopus

🐙 let octopus send multiple messages for you

目前為 2023-05-29 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name chat-octopus
  3. // @namespace https://github.com/mefengl
  4. // @version 0.2.17
  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-4HXFAWD7.mjs
  72. var chatgpt_exports = {};
  73. __export(chatgpt_exports, {
  74. getContinueGeneratingButton: () => getContinueGeneratingButton,
  75. getConversation: () => getConversation,
  76. getHistoryBlockTitle: () => getHistoryBlockTitle,
  77. getHistoryBlocks: () => getHistoryBlocks,
  78. getHistoryBlocksWithTitle: () => getHistoryBlocksWithTitle,
  79. getLastResponse: () => getLastResponse,
  80. getLastResponseElement: () => getLastResponseElement,
  81. getModelSelectButton: () => getModelSelectButton,
  82. getNav: () => getNav,
  83. getNewModelSelectButtons: () => getNewModelSelectButtons,
  84. getRegenerateButton: () => getRegenerateButton,
  85. getStopGeneratingButton: () => getStopGeneratingButton,
  86. getSubmitButton: () => getSubmitButton,
  87. getTextarea: () => getTextarea,
  88. getTextareaValue: () => getTextareaValue,
  89. hasNewModelSelectButtons: () => hasNewModelSelectButtons,
  90. isConversationStarted: () => isConversationStarted,
  91. isGenerating: () => isGenerating,
  92. isHorizontalConversation: () => isHorizontalConversation,
  93. onSend: () => onSend,
  94. regenerate: () => regenerate,
  95. send: () => send,
  96. setHorizontalConversation: () => setHorizontalConversation,
  97. setPromptListener: () => setPromptListener,
  98. setPureConversation: () => setPureConversation,
  99. setTextarea: () => setTextarea,
  100. waitForIdle: () => waitForIdle
  101. });
  102. function getNav() {
  103. return document.querySelector("nav");
  104. }
  105. function getHistoryBlocks() {
  106. const nav = getNav();
  107. if (!nav)
  108. return [];
  109. const result = Array.from(nav.querySelectorAll("ol")).map((ol) => ol.parentElement);
  110. return result;
  111. }
  112. function getHistoryBlockTitle(historyBlock) {
  113. var _a;
  114. return ((_a = historyBlock.querySelector("h3")) == null ? void 0 : _a.textContent) || "";
  115. }
  116. function getHistoryBlocksWithTitle() {
  117. const historyBlocks = getHistoryBlocks();
  118. const result = historyBlocks.map((historyBlock) => ({
  119. block: historyBlock,
  120. title: getHistoryBlockTitle(historyBlock)
  121. }));
  122. return result;
  123. }
  124. function getTextarea() {
  125. const form = document.querySelector("form");
  126. if (!form)
  127. return;
  128. const textareas = form.querySelectorAll("textarea");
  129. const result = textareas[0];
  130. return result;
  131. }
  132. function getSubmitButton() {
  133. const textarea = getTextarea();
  134. if (!textarea)
  135. return;
  136. return textarea.nextElementSibling;
  137. }
  138. function getRegenerateButton() {
  139. const form = document.querySelector("form");
  140. if (!form)
  141. return;
  142. const buttons = form.querySelectorAll("button");
  143. const result = Array.from(buttons).find((button) => {
  144. var _a;
  145. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("regenerate");
  146. });
  147. return result;
  148. }
  149. function getContinueGeneratingButton() {
  150. const form = document.querySelector("form");
  151. if (!form)
  152. return;
  153. const buttons = form.querySelectorAll("button");
  154. const result = Array.from(buttons).find((button) => {
  155. var _a;
  156. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("continue generating");
  157. });
  158. return result;
  159. }
  160. function getStopGeneratingButton() {
  161. const form = document.querySelector("form");
  162. if (!form)
  163. return;
  164. const buttons = form.querySelectorAll("button");
  165. const result = Array.from(buttons).find((button) => {
  166. var _a;
  167. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("stop generating");
  168. });
  169. return result;
  170. }
  171. function getLastResponseElement() {
  172. const responseElements = document.querySelectorAll(".group.w-full");
  173. return responseElements[responseElements.length - 1];
  174. }
  175. function getLastResponse() {
  176. const lastResponseElement = getLastResponseElement();
  177. if (!lastResponseElement)
  178. return;
  179. const lastResponse = lastResponseElement.textContent;
  180. return lastResponse;
  181. }
  182. function getTextareaValue() {
  183. var _a;
  184. return ((_a = getTextarea()) == null ? void 0 : _a.value) || "";
  185. }
  186. function setTextarea(message) {
  187. const textarea = getTextarea();
  188. if (!textarea)
  189. return;
  190. textarea.value = message;
  191. textarea.dispatchEvent(new Event("input"));
  192. }
  193. function send(message) {
  194. setTextarea(message);
  195. const textarea = getTextarea();
  196. if (!textarea)
  197. return;
  198. textarea.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
  199. }
  200. function regenerate() {
  201. const regenerateButton = getRegenerateButton();
  202. if (!regenerateButton)
  203. return;
  204. regenerateButton.click();
  205. }
  206. function onSend(callback) {
  207. const textarea = getTextarea();
  208. if (!textarea)
  209. return;
  210. textarea.addEventListener("keydown", function(event) {
  211. if (event.key === "Enter" && !event.shiftKey) {
  212. callback();
  213. }
  214. });
  215. const sendButton = getSubmitButton();
  216. if (!sendButton)
  217. return;
  218. sendButton.addEventListener("mousedown", callback);
  219. }
  220. function isGenerating() {
  221. var _a, _b;
  222. return ((_b = (_a = getSubmitButton()) == null ? void 0 : _a.firstElementChild) == null ? void 0 : _b.childElementCount) === 3;
  223. }
  224. function waitForIdle() {
  225. return new Promise((resolve) => {
  226. const interval = setInterval(() => {
  227. if (!isGenerating()) {
  228. clearInterval(interval);
  229. resolve();
  230. }
  231. }, 1e3);
  232. });
  233. }
  234. function setPromptListener(key = "prompt_texts") {
  235. let last_trigger_time = +/* @__PURE__ */ new Date();
  236. if (location.href.includes("chat.openai")) {
  237. GM_addValueChangeListener(key, (name, old_value, new_value) => __async(this, null, function* () {
  238. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  239. return;
  240. }
  241. last_trigger_time = +/* @__PURE__ */ new Date();
  242. setTimeout(() => __async(this, null, function* () {
  243. const prompt_texts = new_value;
  244. if (prompt_texts.length > 0) {
  245. let firstTime = true;
  246. while (prompt_texts.length > 0) {
  247. if (!firstTime) {
  248. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  249. }
  250. if (!firstTime && isGenerating()) {
  251. continue;
  252. }
  253. firstTime = false;
  254. const prompt_text = prompt_texts.shift() || "";
  255. send(prompt_text);
  256. }
  257. }
  258. }), 0);
  259. GM_setValue(key, []);
  260. }));
  261. }
  262. }
  263. function getConversation() {
  264. var _a, _b;
  265. return (_b = (_a = document.querySelector('div[class^="react-scroll-to-bottom"]')) == null ? void 0 : _a.firstChild) == null ? void 0 : _b.firstChild;
  266. }
  267. function getModelSelectButton() {
  268. const conversation = getConversation();
  269. if (!conversation)
  270. return;
  271. return Array.from(conversation.querySelectorAll("button")).find((button) => {
  272. var _a;
  273. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("model");
  274. });
  275. }
  276. function getNewModelSelectButtons() {
  277. return Array.from(document.querySelectorAll("[class^='group/button']"));
  278. }
  279. function hasNewModelSelectButtons() {
  280. return getNewModelSelectButtons().length > 0;
  281. }
  282. function isConversationStarted() {
  283. return !getModelSelectButton();
  284. }
  285. function setPureConversation() {
  286. const conversation = getConversation();
  287. if (!conversation)
  288. return;
  289. const firstChild = conversation.firstChild;
  290. if (!firstChild)
  291. return;
  292. const newDiv = document.createElement("div");
  293. conversation.insertBefore(newDiv, firstChild.nextSibling);
  294. }
  295. function isHorizontalConversation() {
  296. const conversation = getConversation();
  297. if (!conversation)
  298. return true;
  299. if (!isConversationStarted())
  300. return true;
  301. return conversation.classList.contains("grid");
  302. }
  303. function setHorizontalConversation() {
  304. if (isHorizontalConversation())
  305. return;
  306. setPureConversation();
  307. const conversation = getConversation();
  308. if (!conversation)
  309. return;
  310. conversation.classList.remove("flex", "flex-col", "items-center");
  311. conversation.classList.add("grid", "grid-cols-2", "place-items-center");
  312. }
  313.  
  314. // ../../packages/chatkit/dist/chunk-SIBHE5N3.mjs
  315. var bing_exports = {};
  316. __export(bing_exports, {
  317. getActionBar: () => getActionBar,
  318. getChatTurns: () => getChatTurns,
  319. getConversation: () => getConversation2,
  320. getLastChatTurn: () => getLastChatTurn,
  321. getLastResponse: () => getLastResponse2,
  322. getLastResponseText: () => getLastResponseText,
  323. getNewChatButton: () => getNewChatButton,
  324. getRegenerateButton: () => getRegenerateButton2,
  325. getStopGeneratingButton: () => getStopGeneratingButton2,
  326. getSubmitButton: () => getSubmitButton2,
  327. getSuggestionBar: () => getSuggestionBar,
  328. getSuggestionBarButtons: () => getSuggestionBarButtons,
  329. getTextarea: () => getTextarea2,
  330. onSend: () => onSend2,
  331. send: () => send2
  332. });
  333. function getActionBar() {
  334. var _a, _b, _c;
  335. 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;
  336. }
  337. function getSubmitButton2() {
  338. const actionBar = getActionBar();
  339. if (!actionBar) {
  340. return null;
  341. }
  342. return actionBar.querySelector('button[aria-label="Submit"]');
  343. }
  344. function getTextarea2() {
  345. const actionBar = getActionBar();
  346. if (!actionBar) {
  347. return null;
  348. }
  349. return actionBar.querySelector("textarea");
  350. }
  351. function getStopGeneratingButton2() {
  352. var _a, _b;
  353. const actionBar = getActionBar();
  354. if (!actionBar) {
  355. return null;
  356. }
  357. const stopGeneratingButton = (_b = (_a = actionBar.querySelector("cib-typing-indicator")) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelector('button[aria-label="Stop Responding"]');
  358. if (!stopGeneratingButton) {
  359. return null;
  360. }
  361. if (stopGeneratingButton.disabled) {
  362. return null;
  363. }
  364. return stopGeneratingButton;
  365. }
  366. function getNewChatButton() {
  367. const actionBar = getActionBar();
  368. if (!actionBar) {
  369. return null;
  370. }
  371. return actionBar.querySelector('button[aria-label="New topic"]');
  372. }
  373. function getConversation2() {
  374. var _a, _b, _c;
  375. 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;
  376. }
  377. function getChatTurns() {
  378. const conversation = getConversation2();
  379. if (!conversation) {
  380. return null;
  381. }
  382. return Array.from(conversation.querySelectorAll("cib-chat-turn")).map((t) => t.shadowRoot);
  383. }
  384. function getSuggestionBar() {
  385. var _a;
  386. const conversation = getConversation2();
  387. if (!conversation) {
  388. return null;
  389. }
  390. return ((_a = conversation.querySelector("cib-suggestion-bar")) == null ? void 0 : _a.shadowRoot) || null;
  391. }
  392. function getSuggestionBarButtons() {
  393. const suggestionBar = getSuggestionBar();
  394. if (!suggestionBar) {
  395. return [];
  396. }
  397. const suggestionItems = Array.from(suggestionBar.querySelectorAll("cib-suggestion-item"));
  398. return suggestionItems.map((i) => {
  399. var _a;
  400. return (_a = i.shadowRoot) == null ? void 0 : _a.querySelector("button");
  401. });
  402. }
  403. function getRegenerateButton2() {
  404. const suggestionBarButtons = getSuggestionBarButtons();
  405. if (!suggestionBarButtons.length) {
  406. return null;
  407. }
  408. return suggestionBarButtons[0];
  409. }
  410. function getLastChatTurn() {
  411. const chatTurns = getChatTurns();
  412. if (!chatTurns) {
  413. return null;
  414. }
  415. return chatTurns[chatTurns.length - 1];
  416. }
  417. function getLastResponse2() {
  418. var _a;
  419. const lastChatTurn = getLastChatTurn();
  420. if (!lastChatTurn) {
  421. return null;
  422. }
  423. return ((_a = lastChatTurn.querySelectorAll("cib-message-group")[1]) == null ? void 0 : _a.shadowRoot) || null;
  424. }
  425. function getLastResponseText() {
  426. var _a;
  427. const lastResponse = getLastResponse2();
  428. if (!lastResponse) {
  429. return null;
  430. }
  431. const message = Array.from(lastResponse.querySelectorAll("cib-message")).map((m) => m.shadowRoot).find((m) => m == null ? void 0 : m.querySelector("cib-shared"));
  432. return ((_a = message == null ? void 0 : message.textContent) == null ? void 0 : _a.trim()) || null;
  433. }
  434. function send2(text) {
  435. const textarea = getTextarea2();
  436. if (!textarea) {
  437. return;
  438. }
  439. textarea.value = text;
  440. textarea.dispatchEvent(new Event("input"));
  441. const submitButton = getSubmitButton2();
  442. if (!submitButton) {
  443. return;
  444. }
  445. submitButton.click();
  446. }
  447. function onSend2(callback) {
  448. const textarea = getTextarea2();
  449. if (!textarea)
  450. return;
  451. textarea.addEventListener("keydown", function(event) {
  452. if (event.key === "Enter" && !event.shiftKey) {
  453. callback();
  454. }
  455. });
  456. const sendButton = getSubmitButton2();
  457. if (!sendButton)
  458. return;
  459. sendButton.addEventListener("mousedown", callback);
  460. }
  461.  
  462. // ../../packages/chatkit/dist/chunk-ABU253YF.mjs
  463. var bard_exports = {};
  464. __export(bard_exports, {
  465. getInputArea: () => getInputArea,
  466. getLastPrompt: () => getLastPrompt,
  467. getLatestPromptText: () => getLatestPromptText,
  468. getRegenerateButton: () => getRegenerateButton3,
  469. getSubmitButton: () => getSubmitButton3,
  470. getTextarea: () => getTextarea3,
  471. onSend: () => onSend3,
  472. send: () => send3
  473. });
  474. function getSubmitButton3() {
  475. return document.querySelector('button[aria-label="Send message"]');
  476. }
  477. function getInputArea() {
  478. return document.querySelector(".input-area");
  479. }
  480. function getTextarea3() {
  481. const inputArea = getInputArea();
  482. return inputArea ? inputArea.querySelector("textarea") : null;
  483. }
  484. function getRegenerateButton3() {
  485. return document.querySelector('button[aria-label="Retry"]');
  486. }
  487. function getLastPrompt() {
  488. const promptElements = document.querySelectorAll(".query-text");
  489. const lastPrompt = promptElements[promptElements.length - 1];
  490. return lastPrompt;
  491. }
  492. function getLatestPromptText() {
  493. const lastPrompt = getLastPrompt();
  494. if (!lastPrompt)
  495. return "";
  496. const lastPromptText = lastPrompt.textContent;
  497. return lastPromptText || "";
  498. }
  499. function send3(text) {
  500. const textarea = getTextarea3();
  501. if (!textarea)
  502. return;
  503. textarea.value = text;
  504. textarea.dispatchEvent(new Event("input"));
  505. const submitButton = getSubmitButton3();
  506. if (!submitButton)
  507. return;
  508. submitButton.click();
  509. }
  510. function onSend3(callback) {
  511. const textarea = getTextarea3();
  512. if (!textarea)
  513. return;
  514. textarea.addEventListener("keydown", function(event) {
  515. if (event.key === "Enter" && !event.shiftKey) {
  516. callback();
  517. }
  518. });
  519. const sendButton = getSubmitButton3();
  520. if (!sendButton)
  521. return;
  522. sendButton.addEventListener("mousedown", callback);
  523. }
  524.  
  525. // src/index.js
  526. (function() {
  527. "use strict";
  528. const default_menu_all = {};
  529. const menu_all = GM_getValue("menu_all", default_menu_all);
  530. const menus = [
  531. { checker: () => location.href.includes("chat.openai"), name: "openai", value: true },
  532. { checker: () => location.href.includes("bard.google"), name: "bard", value: true },
  533. { checker: () => location.href.includes("Bing+AI"), name: "bing", value: true }
  534. ];
  535. menus.forEach((menu) => {
  536. $(() => menu.checker() && GM_setValue(menu.name, true));
  537. if (GM_getValue(menu.name) == true) {
  538. default_menu_all[menu.name] = menu.value;
  539. }
  540. });
  541. for (let name in default_menu_all) {
  542. if (!(name in menu_all)) {
  543. menu_all[name] = default_menu_all[name];
  544. }
  545. }
  546. const menu_id = GM_getValue("menu_id", {});
  547. function registerMenuCommand(name, value) {
  548. const menuText = ` ${name}\uFF1A${value ? "\u2705" : "\u274C"}`;
  549. const commandCallback = () => {
  550. menu_all[name] = !menu_all[name];
  551. GM_setValue("menu_all", menu_all);
  552. update_menu();
  553. location.reload();
  554. };
  555. return GM_registerMenuCommand(menuText, commandCallback);
  556. }
  557. function update_menu() {
  558. for (let name in menu_all) {
  559. const value = menu_all[name];
  560. if (menu_id[name]) {
  561. GM_unregisterMenuCommand(menu_id[name]);
  562. }
  563. menu_id[name] = registerMenuCommand(name, value);
  564. }
  565. GM_setValue("menu_id", menu_id);
  566. }
  567. update_menu();
  568. let chatgpt_last_prompt = "";
  569. $(() => {
  570. if (menu_all.openai && location.href.includes("chat.openai")) {
  571. chatgpt_exports.onSend(() => {
  572. const textarea = chatgpt_exports.getTextarea();
  573. if (!textarea) {
  574. return;
  575. }
  576. const prompt = textarea.value;
  577. chatgpt_last_prompt = prompt;
  578. GM_setValue("bard_prompt_texts", [prompt]);
  579. GM_setValue("bing_prompt_texts", [prompt]);
  580. });
  581. }
  582. });
  583. let last_trigger_time = +/* @__PURE__ */ new Date();
  584. $(() => {
  585. if (location.href.includes("chat.openai")) {
  586. GM_addValueChangeListener("chatgpt_prompt_texts", (name, old_value, new_value) => {
  587. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  588. return;
  589. }
  590. last_trigger_time = +/* @__PURE__ */ new Date();
  591. setTimeout(() => __async(this, null, function* () {
  592. const prompt_texts = new_value;
  593. if (prompt_texts.length > 0) {
  594. let firstTime = true;
  595. while (prompt_texts.length > 0) {
  596. if (!firstTime) {
  597. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  598. }
  599. if (!firstTime && chatgpt_exports.getRegenerateButton() == void 0) {
  600. continue;
  601. }
  602. firstTime = false;
  603. const prompt_text = prompt_texts.shift();
  604. if (prompt_text === chatgpt_last_prompt) {
  605. continue;
  606. }
  607. chatgpt_exports.send(prompt_text);
  608. }
  609. }
  610. }), 0);
  611. GM_setValue("chatgpt_prompt_texts", []);
  612. });
  613. }
  614. });
  615. let bard_last_prompt = "";
  616. $(() => __async(this, null, function* () {
  617. if (menu_all.bard && location.href.includes("bard.google")) {
  618. while (!bard_exports.getSubmitButton()) {
  619. yield new Promise((resolve) => setTimeout(resolve, 500));
  620. }
  621. bard_exports.onSend(() => {
  622. const textarea = bard_exports.getTextarea();
  623. if (!textarea) {
  624. return;
  625. }
  626. let prompt = textarea.value;
  627. if (!prompt) {
  628. prompt = bard_exports.getLatestPromptText();
  629. }
  630. bard_last_prompt = prompt;
  631. GM_setValue("chatgpt_prompt_texts", [prompt]);
  632. GM_setValue("bing_prompt_texts", [prompt]);
  633. });
  634. }
  635. }));
  636. let lastTriggerTime = +/* @__PURE__ */ new Date();
  637. if (location.href.includes("bard.google")) {
  638. GM_addValueChangeListener("bard_prompt_texts", (name, old_value, new_value) => {
  639. if (+/* @__PURE__ */ new Date() - lastTriggerTime < 500) {
  640. return;
  641. }
  642. lastTriggerTime = +/* @__PURE__ */ new Date();
  643. setTimeout(() => __async(this, null, function* () {
  644. const promptTexts = new_value;
  645. if (promptTexts.length > 0) {
  646. let firstTime = true;
  647. while (promptTexts.length > 0) {
  648. if (!firstTime) {
  649. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  650. }
  651. if (!firstTime && bard_exports.getRegenerateButton() == void 0) {
  652. continue;
  653. }
  654. firstTime = false;
  655. const promptText = promptTexts.shift();
  656. if (promptText === bard_last_prompt) {
  657. continue;
  658. }
  659. bard_exports.send(promptText);
  660. }
  661. }
  662. }), 0);
  663. GM_setValue("bard_prompt_texts", []);
  664. });
  665. }
  666. let bing_last_prompt = "";
  667. $(() => __async(this, null, function* () {
  668. if (menu_all.bing && location.href.includes("Bing+AI")) {
  669. while (!bing_exports.getSubmitButton()) {
  670. yield new Promise((resolve) => setTimeout(resolve, 500));
  671. }
  672. bing_exports.onSend(() => {
  673. const textarea = bing_exports.getTextarea();
  674. if (!textarea) {
  675. return;
  676. }
  677. const prompt = textarea.value;
  678. bing_last_prompt = prompt;
  679. GM_setValue("chatgpt_prompt_texts", [prompt]);
  680. GM_setValue("bard_prompt_texts", [prompt]);
  681. });
  682. }
  683. }));
  684. let last_trigger_time_bing = +/* @__PURE__ */ new Date();
  685. if (location.href.includes("Bing+AI")) {
  686. GM_addValueChangeListener("bing_prompt_texts", (name, old_value, new_value) => {
  687. if (+/* @__PURE__ */ new Date() - last_trigger_time_bing < 500) {
  688. return;
  689. }
  690. last_trigger_time_bing = +/* @__PURE__ */ new Date();
  691. setTimeout(() => __async(this, null, function* () {
  692. const prompt_texts = new_value;
  693. if (prompt_texts.length > 0) {
  694. let firstTime = true;
  695. while (prompt_texts.length > 0) {
  696. if (!firstTime) {
  697. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  698. }
  699. if (!firstTime && bing_exports.getStopGeneratingButton() != void 0) {
  700. continue;
  701. }
  702. firstTime = false;
  703. const prompt_text = prompt_texts.shift();
  704. if (prompt_text === bing_last_prompt) {
  705. continue;
  706. }
  707. bing_exports.send(prompt_text);
  708. }
  709. }
  710. }), 0);
  711. GM_setValue("bing_prompt_texts", []);
  712. });
  713. }
  714. })();
  715. })();