GPT互动脚本

GPT互动脚本,避免gpt断开连接,导致需要反复刷新验证

  1. // ==UserScript==
  2. // @name GPT互动脚本
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description GPT互动脚本,避免gpt断开连接,导致需要反复刷新验证
  6. // @author zhanjunxiang
  7. // @match https://chatgpt.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=chatgpt.com
  9. // @grant zhanjunxiang
  10. // @license All Rights Reserved
  11.  
  12. // ==/UserScript==
  13.  
  14. function simulateInput() {
  15. const sendButton = document.querySelector('[data-testid*="stop"]'); // 查找包含 "stop" 的 data-testid 属性的按钮
  16. if (sendButton) {
  17. return;
  18. }
  19.  
  20. const inputBox = document.getElementById('prompt-textarea'); // 替换为实际的输入框ID
  21. if (inputBox && inputBox.value.trim() === '') {
  22. inputBox.value = '你好,ChatGPT!'; // 输入内容
  23. inputBox.dispatchEvent(new Event('input', { bubbles: true })); // 模拟输入事件
  24. }
  25. }
  26.  
  27. // 每隔一段时间执行一次 simulateInput
  28. setInterval(simulateInput, 1 * 60 * 1000); // 每分钟执行一次
  29.  
  30. function simulateSubmit() {
  31. const sendButton = document.querySelector('[data-testid*="stop"]'); // 查找包含 "stop" 的 data-testid 属性的按钮
  32. if (sendButton) {
  33. return;
  34. }
  35.  
  36. // 延迟一秒钟后执行
  37. setTimeout(() => {
  38. const inputBox = document.getElementById('prompt-textarea');
  39. const inputValue = inputBox ? inputBox.value.trim() : '';
  40. const expectedValue = '你好,ChatGPT!';
  41.  
  42. // 判断输入框内容是否为预期值,执行后续逻辑
  43. if (inputValue === expectedValue) {
  44. // 找到发送按钮,并触发点击事件
  45. const sendButton = document.getElementById('prompt-textarea').parentElement.nextElementSibling;
  46. if (sendButton) {
  47. sendButton.click(); // 触发点击事件
  48. }
  49. }
  50. }, 1000); // 延迟一秒钟
  51. }
  52.  
  53.  
  54. // 每隔一段时间执行一次 simulateSubmit
  55. setInterval(simulateSubmit, 1 * 60 * 1000); // 每分钟执行一次

QingJ © 2025

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