聊天章鱼

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

当前为 2023-08-04 提交的版本,查看 最新版本

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

QingJ © 2025

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