Skip to content

Instantly share code, notes, and snippets.

@cnscorpions
Last active December 20, 2021 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnscorpions/40797369d2105f009c2650f267692efb to your computer and use it in GitHub Desktop.
Save cnscorpions/40797369d2105f009c2650f267692efb to your computer and use it in GitHub Desktop.
Scroll to webpage bottom
/**
* scroll to bottom
* @param {*} page
*/
(async () => {
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 400;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 1000);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment