奇妙的一天

与ChatGPT度过的美好时光

目前为 2023-04-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Doozy
  3. // @namespace https://github.com/mefengl
  4. // @version 0.8.0
  5. // @description A wonderful day spent with ChatGPT
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  7. // @author mefengl
  8. // @match https://chat.openai.com/*
  9. // @match http://*/*
  10. // @match https://*/*
  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 Doozy
  21. // @description:en A wonderful day spent with ChatGPT
  22. // @name:zh-CN 奇妙的一天
  23. // @description:zh-CN 与ChatGPT度过的美好时光
  24. // @name:es Doozy
  25. // @description:es Un día maravilloso pasado con ChatGPT
  26. // @name:hi धमाकेदार
  27. // @description:hi चैट जीपीटी के साथ बिताए एक अद्भुत दिन
  28. // @name:ar دوزي
  29. // @description:ar يوم رائع قضيته مع ChatGPT
  30. // @name:pt Espetacular
  31. // @description:pt Um dia maravilhoso passado com o ChatGPT
  32. // @name:ru Блестящий
  33. // @description:ru Замечательный день, проведенный с ChatGPT
  34. // @name:ja ドゥーズィ
  35. // @description:ja ChatGPTと過ごす素晴らしい一日
  36. // @name:de Doozy
  37. // @description:de Ein wunderbarer Tag mit ChatGPT verbracht
  38. // @name:fr Doozy
  39. // @description:fr Une journée merveilleuse passée avec ChatGPT
  40. // ==/UserScript==
  41. "use strict";
  42. (() => {
  43. var __create = Object.create;
  44. var __defProp = Object.defineProperty;
  45. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  46. var __getOwnPropNames = Object.getOwnPropertyNames;
  47. var __getProtoOf = Object.getPrototypeOf;
  48. var __hasOwnProp = Object.prototype.hasOwnProperty;
  49. var __commonJS = (cb, mod) => function __require() {
  50. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  51. };
  52. var __copyProps = (to, from, except, desc) => {
  53. if (from && typeof from === "object" || typeof from === "function") {
  54. for (let key of __getOwnPropNames(from))
  55. if (!__hasOwnProp.call(to, key) && key !== except)
  56. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  57. }
  58. return to;
  59. };
  60. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  61. // If the importer is in node compatibility mode or this is not an ESM
  62. // file that has been converted to a CommonJS file using a Babel-
  63. // compatible transform (i.e. "__esModule" has not been set), then set
  64. // "default" to the CommonJS "module.exports" for node compatibility.
  65. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  66. mod
  67. ));
  68. var __async = (__this, __arguments, generator) => {
  69. return new Promise((resolve, reject) => {
  70. var fulfilled = (value) => {
  71. try {
  72. step(generator.next(value));
  73. } catch (e) {
  74. reject(e);
  75. }
  76. };
  77. var rejected = (value) => {
  78. try {
  79. step(generator.throw(value));
  80. } catch (e) {
  81. reject(e);
  82. }
  83. };
  84. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  85. step((generator = generator.apply(__this, __arguments)).next());
  86. });
  87. };
  88.  
  89. // ../../packages/chatkit/dist/chatgpt/index.js
  90. var require_chatgpt = __commonJS({
  91. "../../packages/chatkit/dist/chatgpt/index.js"(exports, module) {
  92. "use strict";
  93. var __defProp2 = Object.defineProperty;
  94. var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
  95. var __getOwnPropNames2 = Object.getOwnPropertyNames;
  96. var __hasOwnProp2 = Object.prototype.hasOwnProperty;
  97. var __export = (target, all) => {
  98. for (var name in all)
  99. __defProp2(target, name, { get: all[name], enumerable: true });
  100. };
  101. var __copyProps2 = (to, from, except, desc) => {
  102. if (from && typeof from === "object" || typeof from === "function") {
  103. for (let key of __getOwnPropNames2(from))
  104. if (!__hasOwnProp2.call(to, key) && key !== except)
  105. __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
  106. }
  107. return to;
  108. };
  109. var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
  110. var chatgpt_exports = {};
  111. __export(chatgpt_exports, {
  112. getConversation: () => getConversation,
  113. getLastResponse: () => getLastResponse,
  114. getLastResponseElement: () => getLastResponseElement,
  115. getModelSelectButton: () => getModelSelectButton,
  116. getRegenerateButton: () => getRegenerateButton2,
  117. getStopGeneratingButton: () => getStopGeneratingButton,
  118. getSubmitButton: () => getSubmitButton,
  119. getTextarea: () => getTextarea,
  120. getTextareaValue: () => getTextareaValue,
  121. isConversationStarted: () => isConversationStarted,
  122. isGenerating: () => isGenerating,
  123. isHorizontalConversation: () => isHorizontalConversation,
  124. onSend: () => onSend,
  125. regenerate: () => regenerate,
  126. send: () => send2,
  127. setHorizontalConversation: () => setHorizontalConversation,
  128. setPromptListener: () => setPromptListener,
  129. setPureConversation: () => setPureConversation,
  130. setTextarea: () => setTextarea,
  131. waitForIdle: () => waitForIdle
  132. });
  133. module.exports = __toCommonJS(chatgpt_exports);
  134. function getTextarea() {
  135. const form = document.querySelector("form");
  136. if (!form)
  137. return;
  138. const textareas = form.querySelectorAll("textarea");
  139. const result = textareas[0];
  140. return result;
  141. }
  142. function getSubmitButton() {
  143. const textarea = getTextarea();
  144. if (!textarea)
  145. return;
  146. return textarea.nextElementSibling;
  147. }
  148. function getRegenerateButton2() {
  149. const form = document.querySelector("form");
  150. if (!form)
  151. return;
  152. const buttons = form.querySelectorAll("button");
  153. const result = Array.from(buttons).find((button) => {
  154. var _a;
  155. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("regenerate");
  156. });
  157. return result;
  158. }
  159. function getStopGeneratingButton() {
  160. const form = document.querySelector("form");
  161. if (!form)
  162. return;
  163. const buttons = form.querySelectorAll("button");
  164. const result = Array.from(buttons).find((button) => {
  165. var _a;
  166. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("stop generating");
  167. });
  168. return result;
  169. }
  170. function getLastResponseElement() {
  171. const responseElements = document.querySelectorAll(".group.w-full");
  172. return responseElements[responseElements.length - 1];
  173. }
  174. function getLastResponse() {
  175. const lastResponseElement = getLastResponseElement();
  176. if (!lastResponseElement)
  177. return;
  178. const lastResponse = lastResponseElement.textContent;
  179. return lastResponse;
  180. }
  181. function getTextareaValue() {
  182. var _a;
  183. return ((_a = getTextarea()) == null ? void 0 : _a.value) || "";
  184. }
  185. function setTextarea(message) {
  186. const textarea = getTextarea();
  187. if (!textarea)
  188. return;
  189. textarea.value = message;
  190. textarea.dispatchEvent(new Event("input"));
  191. }
  192. function send2(message) {
  193. setTextarea(message);
  194. const textarea = getTextarea();
  195. if (!textarea)
  196. return;
  197. textarea.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
  198. }
  199. function regenerate() {
  200. const regenerateButton = getRegenerateButton2();
  201. if (!regenerateButton)
  202. return;
  203. regenerateButton.click();
  204. }
  205. function onSend(callback) {
  206. const textarea = getTextarea();
  207. if (!textarea)
  208. return;
  209. textarea.addEventListener("keydown", function(event) {
  210. if (event.key === "Enter" && !event.shiftKey) {
  211. callback();
  212. }
  213. });
  214. const sendButton = getSubmitButton();
  215. if (!sendButton)
  216. return;
  217. sendButton.addEventListener("mousedown", callback);
  218. }
  219. function isGenerating() {
  220. var _a, _b;
  221. return ((_b = (_a = getSubmitButton()) == null ? void 0 : _a.firstElementChild) == null ? void 0 : _b.childElementCount) === 3;
  222. }
  223. function waitForIdle() {
  224. return new Promise((resolve) => {
  225. const interval = setInterval(() => {
  226. if (!isGenerating()) {
  227. clearInterval(interval);
  228. resolve();
  229. }
  230. }, 1e3);
  231. });
  232. }
  233. function setPromptListener(key = "prompt_texts") {
  234. let last_trigger_time = +/* @__PURE__ */ new Date();
  235. if (location.href.includes("chat.openai")) {
  236. GM_addValueChangeListener(key, (name, old_value, new_value) => __async(this, null, function* () {
  237. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  238. return;
  239. }
  240. last_trigger_time = +/* @__PURE__ */ new Date();
  241. setTimeout(() => __async(this, null, function* () {
  242. const prompt_texts = new_value;
  243. if (prompt_texts.length > 0) {
  244. let firstTime = true;
  245. while (prompt_texts.length > 0) {
  246. if (!firstTime) {
  247. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  248. }
  249. if (!firstTime && isGenerating()) {
  250. continue;
  251. }
  252. firstTime = false;
  253. const prompt_text = prompt_texts.shift() || "";
  254. send2(prompt_text);
  255. }
  256. }
  257. }), 0);
  258. GM_setValue(key, []);
  259. }));
  260. }
  261. }
  262. function getConversation() {
  263. var _a, _b;
  264. return (_b = (_a = document.querySelector('div[class^="react-scroll-to-bottom"]')) == null ? void 0 : _a.firstChild) == null ? void 0 : _b.firstChild;
  265. }
  266. function getModelSelectButton() {
  267. const conversation = getConversation();
  268. if (!conversation)
  269. return;
  270. return Array.from(conversation.querySelectorAll("button")).find((button) => {
  271. var _a;
  272. return (_a = button.textContent) == null ? void 0 : _a.trim().toLowerCase().includes("model");
  273. });
  274. }
  275. function isConversationStarted() {
  276. return !getModelSelectButton();
  277. }
  278. function setPureConversation() {
  279. const conversation = getConversation();
  280. if (!conversation)
  281. return;
  282. const firstChild = conversation.firstChild;
  283. if (!firstChild)
  284. return;
  285. const newDiv = document.createElement("div");
  286. conversation.insertBefore(newDiv, firstChild.nextSibling);
  287. }
  288. function isHorizontalConversation() {
  289. const conversation = getConversation();
  290. if (!conversation)
  291. return true;
  292. if (!isConversationStarted())
  293. return true;
  294. return conversation.classList.contains("grid");
  295. }
  296. function setHorizontalConversation() {
  297. if (isHorizontalConversation())
  298. return;
  299. setPureConversation();
  300. const conversation = getConversation();
  301. if (!conversation)
  302. return;
  303. conversation.classList.remove("flex", "flex-col", "items-center");
  304. conversation.classList.add("grid", "grid-cols-2", "place-items-center");
  305. }
  306. }
  307. });
  308.  
  309. // ../../packages/chatkit/chatgpt.js
  310. var require_chatgpt2 = __commonJS({
  311. "../../packages/chatkit/chatgpt.js"(exports, module) {
  312. module.exports = require_chatgpt();
  313. }
  314. });
  315.  
  316. // src/index.js
  317. var import_chatgpt = __toESM(require_chatgpt2(), 1);
  318. (function() {
  319. "use strict";
  320. const default_menu_all = {};
  321. const menu_all = GM_getValue("menu_all", default_menu_all);
  322. const menus = [
  323. { checker: () => location.href.includes("book.douban"), name: "douban_book", value: true },
  324. { checker: () => location.href.includes("zhihu"), name: "zhihu", value: true },
  325. { checker: () => location.href.includes("news.ycombinator"), name: "hackernews", value: true },
  326. { checker: () => location.href.includes("github"), name: "github", value: true },
  327. { checker: () => location.href.includes("wikipedia"), name: "wikipedia", value: true },
  328. { checker: () => location.href.includes("nytimes.com"), name: "nytimes", value: true },
  329. { checker: () => location.href.includes("baidu.com"), name: "baidu", value: true },
  330. { checker: () => location.href.includes("reddit.com"), name: "reddit", value: true },
  331. { checker: () => location.href.includes("google.com"), name: "google", value: true },
  332. { checker: () => location.href.includes("youtube.com"), name: "youtube", value: true }
  333. ];
  334. menus.forEach((menu) => {
  335. $(() => menu.checker() && GM_setValue(menu.name, true) && console.log(`\u5F00\u542F ${menu.name} \u83DC\u5355`));
  336. if (GM_getValue(menu.name) == true) {
  337. default_menu_all[menu.name] = menu.value;
  338. }
  339. });
  340. for (let name in default_menu_all) {
  341. if (!(name in menu_all)) {
  342. menu_all[name] = default_menu_all[name];
  343. }
  344. }
  345. const menu_id = GM_getValue("menu_id", {});
  346. function registerMenuCommand(name, value) {
  347. const menuText = ` ${name}\uFF1A${value ? "\u2705" : "\u274C"}`;
  348. const commandCallback = () => {
  349. menu_all[name] = !menu_all[name];
  350. GM_setValue("menu_all", menu_all);
  351. update_menu();
  352. location.reload();
  353. };
  354. return GM_registerMenuCommand(menuText, commandCallback);
  355. }
  356. function update_menu() {
  357. for (let name in menu_all) {
  358. const value = menu_all[name];
  359. if (menu_id[name]) {
  360. GM_unregisterMenuCommand(menu_id[name]);
  361. }
  362. menu_id[name] = registerMenuCommand(name, value);
  363. }
  364. GM_setValue("menu_id", menu_id);
  365. }
  366. update_menu();
  367. const douban_book_prompts = [
  368. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u7684\u4E3B\u8981\u89C2\u70B9\u5217\u6210\u8868\u683C\u4F1A\u662F\uFF1A`,
  369. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u6BD4\u8F83\u91CD\u8981\u7684\u7AE0\u8282\u4F1A\u662F\uFF1A`,
  370. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u5728\u54EA\u4E9B\u65B9\u9762\u662F\u6709\u4E89\u8BAE\u7684\u4F1A\u662F\uFF1A`,
  371. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u5F53\u4EBA\u4EEC\u751F\u6D3B\u5728\u4E0D\u540C\u7684\u65F6\u4EE3\u65F6\uFF0C\u4F1A\u6709\u4EC0\u4E48\u4E0D\u540C\u7684\u89C2\u70B9\u4F1A\u662F\uFF1A`,
  372. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u7EFC\u5408Goodreads\u8BC4\u5206\u548C\u8C46\u74E3\u7B49\u5404\u79CD\u8BC4\u5206\u548C\u8BC4\u4EF7\u4F1A\u662F\uFF1A`,
  373. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u7684\u7C7B\u4F3C\u4E66\u7C4D\u6216\u6587\u7AE0\u548C\u5B83\u4EEC\u7684\u533A\u522B\u4F1A\u662F\uFF1A`,
  374. ({ title, author }) => `${author}\u7684\u300A${title}\u300B\u7684\u89C2\u70B9\u76F8\u53CD\u7684\u4E66\u7C4D\u6216\u6587\u7AE0\u548C\u5BF9\u5E94\u7684\u89C2\u70B9\u4F1A\u662F\uFF1A`
  375. ];
  376. const question_prompts = [
  377. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u6697\u542B\u7684\u89C2\u70B9\u662F\uFF1A`,
  378. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u5E94\u8BE5\u53BB\u53CD\u601D\uFF1A`,
  379. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u60F3\u8981\u6539\u8FDB\u6216\u89E3\u51B3\u5B83\uFF0C\u53EF\u4EE5\u4ECE\u8FD9\u4E9B\u65B9\u9762\u5165\u624B\uFF1A`,
  380. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u63D0\u95EE\u8005\u548C\u63D0\u95EE\u8005\u7684\u76EE\u7684\u662F\uFF1A`,
  381. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u95EE\u9898\u7684\u76F8\u5173\u5386\u53F2\u662F\uFF1A`,
  382. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u4E0D\u540C\u7684\u56FD\u5BB6\u5BF9\u8FD9\u4E2A\u95EE\u9898\u7684\u770B\u6CD5\u4F1A\u662F\uFF1A`,
  383. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u7C7B\u4F3C\u95EE\u9898\u548C\u5B83\u4EEC\u7684\u533A\u522B\u4F1A\u662F\uFF1A`,
  384. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u89C2\u70B9\u76F8\u53CD\u7684\u95EE\u9898\u548C\u5BF9\u5E94\u7684\u89C2\u70B9\u4F1A\u662F\uFF1A`,
  385. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u5E7D\u9ED8\u7684\u56DE\u7B54\u4F1A\u662F\uFF1A`,
  386. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u4E3B\u8981\u89C2\u70B9\u5217\u6210\u8868\u683C\u4F1A\u662F\uFF1A`,
  387. ({ question }) => `\u95EE\u9898\uFF1A${question}\uFF0C\u76F8\u5173\u4E66\u7C4D\u3001\u6587\u7AE0\u3001\u89C6\u9891\u6216\u7F51\u7AD9\u4F1A\u662F\uFF1A`,
  388. ({ question }) => `\u4ECE\u8FD9\u4E2A\u95EE\u9898\uFF1A${question}\uFF0C\u53EF\u4EE5\u5F15\u7533\u51FA\u8FD9\u4E9B\u95EE\u9898\uFF1A`
  389. ];
  390. const github_prompts = [
  391. ({ website }) => `${website}\u7684\u6700\u4F73\u5B9E\u8DF5\u662F\uFF1A`,
  392. ({ website }) => `${website}\u7684\u7C7B\u4F3C\u9879\u76EE\u662F\uFF1A`,
  393. ({ website }) => `${website}\u7684\u76F8\u5173\u4E66\u7C4D\u3001\u6587\u7AE0\u3001\u89C6\u9891\u6216\u7F51\u7AD9\u662F\uFF1A`
  394. ];
  395. function chatgpt_trigger(prompt_prepare, prompts) {
  396. const prepare_data = prompt_prepare();
  397. const prompt_texts = prompts.map((prompt) => prompt(prepare_data));
  398. GM_setValue("prompt_texts", prompt_texts);
  399. }
  400. const triggers = [
  401. {
  402. checker: () => menu_all.douban_book && location.href.includes("book.douban.com/subject"),
  403. prepare: () => {
  404. const title = $("meta[property='og:title']").attr("content");
  405. const author = $("meta[property='book:author']").attr("content");
  406. return { title, author };
  407. },
  408. prompts: douban_book_prompts
  409. },
  410. {
  411. checker: () => menu_all.zhihu && location.href.includes("zhihu.com/question"),
  412. prepare: () => {
  413. const question = $('meta[itemprop="name"]').attr("content");
  414. return { question };
  415. },
  416. prompts: [...question_prompts]
  417. },
  418. {
  419. checker: () => menu_all.hackernews && location.href.includes("news.ycombinator.com/item"),
  420. prepare: () => {
  421. const question = $("td.title > span.titleline > a").text();
  422. return { question };
  423. },
  424. prompts: [...question_prompts]
  425. },
  426. {
  427. checker: () => menu_all.github && location.href.includes("github.com"),
  428. prepare: () => {
  429. const parts = location.href.split("/");
  430. if (parts.length >= 5 && parts[parts.length - 2] && parts[parts.length - 1]) {
  431. const website = parts[parts.length - 2] + "/" + parts[parts.length - 1];
  432. return { website };
  433. }
  434. },
  435. prompts: github_prompts
  436. },
  437. {
  438. checker: () => menu_all.wikipedia && location.href.includes("wikipedia.org/wiki/"),
  439. prepare: () => {
  440. const title = $("h1#firstHeading").text();
  441. const summary = $("div.mw-parser-output p").first().text();
  442. return { title, summary };
  443. },
  444. prompts: [
  445. ({ title }) => `${title}\u7684\u5386\u53F2\u548C\u91CD\u8981\u4E8B\u4EF6\u6709\u54EA\u4E9B\uFF1F`,
  446. ({ title }) => `${title}\u4E0E\u5176\u4ED6\u76F8\u5173\u4E3B\u9898\u7684\u6BD4\u8F83\u548C\u5BF9\u6BD4\u4F1A\u662F\uFF1A`,
  447. ({ title }) => `${title}\u7684\u4E3B\u8981\u89C2\u70B9\u5217\u6210\u8868\u683C\u4F1A\u662F\uFF1A`,
  448. ({ title }) => `${title}\u7684\u5173\u952E\u6982\u5FF5\u548C\u672F\u8BED\u662F\u4EC0\u4E48\uFF1F`,
  449. ({ title }) => `${title}\u7684\u7C7B\u4F3C\u8BCD\u6761\u6216\u76F8\u5173\u7814\u7A76\u548C\u5B83\u4EEC\u7684\u533A\u522B\u4F1A\u662F\uFF1A`
  450. ]
  451. },
  452. {
  453. checker: () => menu_all.nytimes && location.href.includes("nytimes.com"),
  454. prepare: () => {
  455. const articleTitle = $("h1").text();
  456. return { question: articleTitle };
  457. },
  458. prompts: [...question_prompts]
  459. },
  460. {
  461. checker: () => menu_all.baidu && location.href.includes("www.baidu.com/s"),
  462. prepare: () => {
  463. const keyword = $("input#kw").val();
  464. return { keyword };
  465. },
  466. prompts: [
  467. ({ keyword }) => `\u5173\u4E8E"${keyword}"\u7684\u6700\u65B0\u65B0\u95FB\u6709\u54EA\u4E9B\uFF1F`,
  468. ({ keyword }) => `"${keyword}"\u7684\u5B9A\u4E49\u548C\u89E3\u91CA\u662F\u4EC0\u4E48\uFF1F`,
  469. ({ keyword }) => `\u5BF9\u4E8E"${keyword}"\u8FD9\u4E2A\u8BDD\u9898\uFF0C\u4F60\u6709\u4EC0\u4E48\u89C2\u70B9\u6216\u770B\u6CD5\uFF1F`,
  470. ({ keyword }) => `\u8DDF"${keyword}"\u76F8\u5173\u7684\u4EBA\u7269\u6216\u4E8B\u4EF6\u6709\u54EA\u4E9B\uFF1F`,
  471. ({ keyword }) => `\u6700\u8FD1\u8DDF"${keyword}"\u76F8\u5173\u7684\u70ED\u95E8\u8BDD\u9898\u662F\u4EC0\u4E48\uFF1F`
  472. ]
  473. },
  474. {
  475. checker: () => menu_all.reddit && location.href.includes("reddit.com"),
  476. prepare: () => {
  477. const postTitle = $("h1._eYtD2XCVieq6emjKBH3m").text();
  478. const postContent = $("div._3W_31WoaKsKsZfNldTiz5M").first().text();
  479. return { postTitle, postContent };
  480. },
  481. prompts: [
  482. ({ postTitle }) => `\u5173\u4E8E"${postTitle}"\uFF0C\u4F60\u6709\u4EC0\u4E48\u60F3\u6CD5\u6216\u8BC4\u8BBA\uFF1F`,
  483. ({ postTitle }) => `\u80FD\u7ED9\u5927\u5BB6\u5206\u4EAB\u4E00\u4E9B"${postTitle}"\u7684\u76F8\u5173\u4FE1\u606F\u5417\uFF1F`,
  484. ({ postTitle }) => `\u5728"${postTitle}"\u7684\u8BA8\u8BBA\u4E2D\uFF0C\u6709\u54EA\u4E9B\u89C2\u70B9\u6216\u610F\u89C1\u6700\u503C\u5F97\u5173\u6CE8\uFF1F`,
  485. ({ postTitle }) => `\u5BF9\u4E8E"${postTitle}"\uFF0C\u4F60\u7684\u770B\u6CD5\u662F\u5426\u4E0E\u5176\u4ED6\u4EBA\u4E0D\u540C\uFF1F`,
  486. ({ postTitle }) => `\u8BF7\u7B80\u8981\u4ECB\u7ECD\u4E00\u4E0B"${postTitle}"\u7684\u4E3B\u8981\u5185\u5BB9\u548C\u80CC\u666F\u3002`
  487. ]
  488. },
  489. {
  490. checker: () => menu_all.google && location.href.includes("google.com/search?q="),
  491. prepare: () => {
  492. const keyword = $("input[name='q']").val();
  493. return { keyword };
  494. },
  495. prompts: [
  496. ({ keyword }) => `\u5173\u4E8E"${keyword}"\u7684\u6700\u65B0\u641C\u7D22\u7ED3\u679C\u6709\u54EA\u4E9B\uFF1F`,
  497. ({ keyword }) => `\u5BF9\u4E8E"${keyword}"\u8FD9\u4E2A\u8BDD\u9898\uFF0C\u4F60\u6709\u4EC0\u4E48\u89C2\u70B9\u6216\u770B\u6CD5\uFF1F`,
  498. ({ keyword }) => `\u8DDF"${keyword}"\u76F8\u5173\u7684\u4EBA\u7269\u6216\u4E8B\u4EF6\u6709\u54EA\u4E9B\uFF1F`,
  499. ({ keyword }) => `\u6700\u8FD1\u8DDF"${keyword}"\u76F8\u5173\u7684\u70ED\u95E8\u8BDD\u9898\u662F\u4EC0\u4E48\uFF1F`
  500. ]
  501. },
  502. {
  503. checker: () => menu_all.youtube && location.href.includes("youtube.com/watch"),
  504. prepare: () => {
  505. const metaTitle = $('meta[name="title"]').attr("content");
  506. return { metaTitle };
  507. },
  508. prompts: [
  509. ({ metaTitle }) => `\u5173\u4E8E"${metaTitle}"\u7684\u89C2\u70B9\u6216\u8BC4\u8BBA\u6709\u54EA\u4E9B\uFF1F`,
  510. ({ metaTitle }) => `\u80FD\u7ED9\u5927\u5BB6\u5206\u4EAB\u4E00\u4E9B\u5173\u4E8E"${metaTitle}"\u7684\u76F8\u5173\u4FE1\u606F\u5417\uFF1F`,
  511. ({ metaTitle }) => `\u5728"${metaTitle}"\u7684\u8BA8\u8BBA\u4E2D\uFF0C\u6709\u54EA\u4E9B\u89C2\u70B9\u6216\u610F\u89C1\u6700\u503C\u5F97\u5173\u6CE8\uFF1F`,
  512. ({ metaTitle }) => `\u5BF9\u4E8E"${metaTitle}"\uFF0C\u4F60\u7684\u770B\u6CD5\u662F\u5426\u4E0E\u5176\u4ED6\u4EBA\u4E0D\u540C\uFF1F`,
  513. ({ metaTitle }) => `\u8BF7\u7B80\u8981\u4ECB\u7ECD\u4E00\u4E0B"${metaTitle}"\u7684\u4E3B\u8981\u5185\u5BB9\u548C\u80CC\u666F\u3002`
  514. ]
  515. }
  516. ];
  517. triggers.forEach((trigger) => {
  518. trigger.checker() && chatgpt_trigger(trigger.prepare, trigger.prompts);
  519. });
  520. let last_trigger_time = +/* @__PURE__ */ new Date();
  521. $(() => {
  522. if (location.href.includes("chat.openai")) {
  523. GM_addValueChangeListener("prompt_texts", (name, old_value, new_value) => {
  524. if (+/* @__PURE__ */ new Date() - last_trigger_time < 500) {
  525. return;
  526. }
  527. last_trigger_time = +/* @__PURE__ */ new Date();
  528. setTimeout(() => __async(this, null, function* () {
  529. const prompt_texts = new_value;
  530. if (prompt_texts.length > 0) {
  531. let firstTime = true;
  532. while (prompt_texts.length > 0) {
  533. if (!firstTime) {
  534. yield new Promise((resolve) => setTimeout(resolve, 2e3));
  535. }
  536. if (!firstTime && (0, import_chatgpt.getRegenerateButton)() == void 0) {
  537. continue;
  538. }
  539. firstTime = false;
  540. const prompt_text = prompt_texts.shift();
  541. (0, import_chatgpt.send)(prompt_text);
  542. }
  543. }
  544. }), 0);
  545. GM_setValue("prompt_texts", []);
  546. });
  547. }
  548. });
  549. })();
  550. })();