ChatGPT Auto Prompt Sender

Automates sending of the next pre-filled prompt in ChatGPT after the current response completion.

  1. // ==UserScript==
  2. // @name ChatGPT Auto Prompt Sender
  3. // @namespace https://userscript.moukaeritai.work/
  4. // @version 0.9.8.20231001
  5. // @description Automates sending of the next pre-filled prompt in ChatGPT after the current response completion.
  6. // @author JP Zhang
  7. // @match https://chat.openai.com/c/*
  8. // @match https://chat.openai.com
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  10. // @grant GM_registerMenuCommand
  11. // @grant GM_openInTab
  12. // @supportURL https://greasyfork.org/ja/scripts/472713
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. setTimeout(function() {
  17. 'use strict';
  18.  
  19. const observer = new MutationObserver((mutationList) => {
  20. mutationList.forEach((mutation) => {
  21. if (mutation.addedNodes.length > 0) {
  22. mutation.addedNodes.forEach((node) => {
  23. if (node.tagName === "BUTTON" && node.hasAttribute("data-testid") && node.getAttribute("data-testid") === "send-button") {
  24. if (!node.disabled) {
  25. console.log("Send button found and it is enabled. Clicking...");
  26. observer.disconnect();
  27. setTimeout(() => node.click(), 100);
  28. return;
  29. }
  30. }
  31. });
  32. }
  33. });
  34. });
  35.  
  36. function executeButtonAction() {
  37. const dotsDiv = document.querySelector("div.text-2xl");
  38. if(dotsDiv) {
  39. dotsDiv.querySelectorAll('span').forEach(span => {
  40. span.style.background = 'red';
  41. span.style.color = 'white';
  42. });
  43. }
  44.  
  45. observer.observe(document.body, { childList: true, subtree: true });
  46. }
  47.  
  48. // Adding event listener for the Ctrl+Alt+J keyboard shortcut
  49. window.addEventListener('keydown', function(e) {
  50. if (e.altKey && e.key === 'j') {
  51. executeButtonAction();
  52. }
  53. });
  54.  
  55. GM_registerMenuCommand("Schedule Next Prompt After Ongoing Response", executeButtonAction);
  56.  
  57. }, 1000);