Skip to content

Instantly share code, notes, and snippets.

@NKCSS
Created April 24, 2023 09:28
Show Gist options
  • Save NKCSS/4e35c9f1aae93d92732a9069430876c6 to your computer and use it in GitHub Desktop.
Save NKCSS/4e35c9f1aae93d92732a9069430876c6 to your computer and use it in GitHub Desktop.
Scroll ChatGPT conversation
const sleep = sleepMs => new Promise(x => setTimeout(x, sleepMs));
const scrollContent = async function(){
const content = document.querySelector('[class^="react-scroll-to-bottom"] > div.flex');
const scroller = content.parentElement;
const viewHeight = scroller.getBoundingClientRect().height;
const height = content.getBoundingClientRect().height - viewHeight;
// If you want different step size, you can adjust it here. I did 2/3rd so you can still have a recognition point between steps.
window.scrollStep = Math.floor((viewHeight / 3) * 2);
// Jump every 1,5s. You can also set this to 1 and the scrollStep to 1-5 and see the page scroll continiously.
window.scrollDelay = 1500;
for(let i = 0; i < height; i += window.scrollStep)
{
await sleep(window.scrollDelay);
scroller.scrollTop = i;
}
await sleep(window.scrollDelay);
scroller.scrollTop = height;
};
await scrollContent();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment