聊天章鱼

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

当前为 2023-07-01 提交的版本,查看 最新版本

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

QingJ © 2025

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