Created
September 18, 2023 02:05
-
-
Save JimLiu/bbe8f4c7ae716c8e23d98b682ee28dd0 to your computer and use it in GitHub Desktop.
ChatGPT自动继续脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
async function continueInput() { | |
await wait(3000); | |
console.log("Type continue after 1 second"); | |
const textarea = document.querySelector("#prompt-textarea"); | |
textarea.value = "继续" | |
textarea.click(); | |
console.log("Press Enter after 1 second"); | |
await wait(1000); | |
let event = new InputEvent("input", { bubbles: true }); | |
// dispatch the event on some DOM element | |
textarea.dispatchEvent(event); | |
console.log("Press Send after 1 second"); | |
await wait(1000); | |
document.querySelector("button[data-testid=send-button]").click(); | |
console.log("Done"); | |
} | |
const observer = new MutationObserver(() => { | |
// Find the button of 'Regenerate' | |
[...document.querySelectorAll("button.btn")].forEach((btn) => { | |
if (btn.innerText.includes("Regenerate")) { | |
continueInput(); | |
} | |
if (btn.innerText.includes("Continue generating")) { | |
console.log("Found the button of 'Continue generating'"); | |
setTimeout(() => { | |
console.log("Clicked it to continue generating after 1 second"); | |
btn.click(); | |
}, 3000); | |
} | |
}); | |
}); | |
// Start observing the dom change of the form | |
observer.observe(document.forms[0], { | |
attributes: false, | |
childList: true, | |
subtree: true, | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment