Skip to content

Instantly share code, notes, and snippets.

@jiwnchoi
Last active December 5, 2023 08:18
Show Gist options
  • Save jiwnchoi/ae1dc4b949eec92e1e3086055cc11499 to your computer and use it in GitHub Desktop.
Save jiwnchoi/ae1dc4b949eec92e1e3086055cc11499 to your computer and use it in GitHub Desktop.
chatgpt_response_time_checker.js
// input prompt to text area and paste code to javascript console.
(function () {
const DOMPath = document.querySelector("#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.w-full.pt-2.md\\:pt-0.dark\\:border-white\\/20.md\\:border-transparent.md\\:dark\\:border-transparent.md\\:w-\\[calc\\(100\\%-\\.5rem\\)\\] > form > div > div > div")
const genButton = "button[data-testid='send-button']"
const stopButton = "button[aria-label='Stop generating]'";
const startTime = Date.now()
document.querySelector(genButton).click()
const observer = new MutationObserver(checkForTargetElement);
const observerConfig = { subtree: true, childList: true };
observer.observe(DOMPath, observerConfig);
function handleElementAppearance() {
const endTime = Date.now()
if (endTime- startTime > 100) {
console.log("Time taken: ", endTime - startTime)
observer.disconnect()
}
}
function checkForTargetElement() {
if (!document.querySelector(stopButton)) handleElementAppearance();
}
})();
(() => {const t=Date.now();const g="button[data-testid='send-button']";const s="button[aria-label='Stop generating]'";const p=document.querySelector("#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.w-full.pt-2.md\\:pt-0.dark\\:border-white\\/20.md\\:border-transparent.md\\:dark\\:border-transparent.md\\:w-\\[calc\\(100\\%-\\.5rem\\)\\] > form > div > div > div");document.querySelector(g).click();const o=new MutationObserver(()=>{if(!document.querySelector(s)){const e=Date.now();if(e-t>100){console.log("Time taken: ",e-t);o.disconnect()}}});o.observe(p,{subtree:!0,childList:!0})})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment