Skip to content

Instantly share code, notes, and snippets.

@MatheusMuriel
Created April 13, 2020 14:23
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 MatheusMuriel/f91e13c5adb6462f2eb6a4ab6473405d to your computer and use it in GitHub Desktop.
Save MatheusMuriel/f91e13c5adb6462f2eb6a4ab6473405d to your computer and use it in GitHub Desktop.
Scroll até o limite máximo da pagina
// Scroll para o fim da pagina
// Esse script é feito para scrollar até o fim de paginas com loading
// Eu o programei para ir até o final da pagina do instagram web
// mas creio que possa ser usado em diversos cenarios por isso estou compartilhando
// Caso ele pare antes de chegar ao final tente aumentar o tempo do sleep na linha 12
const sleep = (ms) => { return new Promise(resolve => setTimeout(resolve, ms)) }
var isEndOfPage = false;
while (!isEndOfPage) {
let heightBegin = document.body.scrollHeight;
window.scrollTo(0 , document.body.scrollHeight);
await sleep(2000);
let heightActual = document.body.scrollHeight;
isEndOfPage = (heightBegin === heightActual);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment