I've been working on a script that scrolls to the dead end of my twitter follower [twitter.com/following] list automatically. So far, I've achieved this with my newbie knowledge:
var delay=2000
setTimeout(function(){
for(var i = 0; i<10; i++){
window.scrollTo(0,document.body.scrollHeight);
}
},delay)
The problem the scroller stops after one scroll to the bottom and it doesn't scroll further when the page height changes. Is there a way to loop it with a delay so that scroll gets executed repeatedly until it reaches the last follower.
Alternatively, is there a way to do the same by constantly tracking and dynamically updating the height of the page.
I think you want to use setInterval
instead of setTimeout
.
setInterval
will fire repeatedly instead of just the one time.
This works for me:
setInterval(function() { window.scrollTo(0, document.body.scrollHeight); },
2000);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments