Greasy Fork镜像 支持简体中文。

ChatGPT Monitor

Monitor whether the answer is complete, if not, automatically send a continue command.

  1. // ==UserScript==
  2. // @name ChatGPT Monitor
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Monitor whether the answer is complete, if not, automatically send a continue command.
  6. // @author CyberSexy
  7. // @match https://chat.openai.com/*
  8. // @require https://code.jquery.com/jquery-3.6.0.min.js
  9. // @run-at document-end
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. window.addEventListener('loadMonitor', function() {
  18. const element = document.querySelector('.text-2xl');
  19. console.log("MyScript1: " + element);
  20. // 这个地方用来判断是否正在返回数据,利用text-2xl的这个类。这个类只在获取数据时候出现。
  21. if (!element) {
  22. // Get the last element with class name "markdown"
  23. var latest = document.getElementsByClassName('markdown')[document.getElementsByClassName('markdown').length - 1];
  24.  
  25. // Store the latest element's content in a variable
  26. var dataZ = latest.innerHTML;
  27. //console.log("MyScriptFull: " + dataZ);
  28. // Remove <p> tags from the content
  29. dataZ = dataZ.replace(/<\/?p>/g, '');
  30. // Check if the content ends with ".", ";" or "。"or"</pre>"
  31. // 你根据情况判断是否还要加,例如有的时候是问号。
  32. var endsWithPunctuation = /[.;!!。]$/.test(dataZ) || dataZ.endsWith("</pre>");
  33.  
  34. console.log("MyScript2: " + endsWithPunctuation);
  35.  
  36. //Extract the last 20 characters
  37. var last20 = dataZ.substr(dataZ.length - 20, 20);
  38. console.log("MyScript3: " + last20);
  39.  
  40. if (!endsWithPunctuation) {
  41. var input=document.querySelector('textarea');
  42. input.value="继续";
  43. input.dispatchEvent(new Event("input", { bubbles: true }));
  44. input.form.dispatchEvent(new Event("submit", { bubbles: true }));
  45. };
  46. }
  47. }
  48. )
  49.  
  50. setInterval(function() {
  51. window.dispatchEvent(new Event('loadMonitor'));
  52. }, 5000);
  53.  
  54. })();

QingJ © 2025

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