聊天章鱼

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

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

QingJ © 2025

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