聊天章鱼

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

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

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