聊天章鱼

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

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

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

QingJ © 2025

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