Throw the script below in the browser's JS console.
It moves the viewport to the bottom of the page repeatedly with a delay in between. This is useful when the page loads data via infinite scroll and you want to do something with all the data.
const atPageBottom = () => {
const scrolled = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
const documentHeightMinusOneViewport =
document.body.scrollHeight - Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
return Math.abs( documentHeightMinusOneViewport - scrolled ) < 3;
}
const scrollUntilAtPageBottom = () => {
if (atPageBottom()) {
return Promise.resolve(true);
}
window.scrollTo(0, document.body.scrollHeight);
return (new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 1000)
}))
.then(scrollUntilAtPageBottom);
}
scrollUntilAtPageBottom();