A Useful Little Trick, Using the Browser Console

Some tasks get solved through the browser console (F12), with a pretty good return on effort.
Still, whenever I do this, I can’t shake the feeling that I’m just fooling around.

Today’s fooling around is a script that does one simple thing — scrolls the page down.
The trick is that once it hits the bottom, it waits, and if more content loaded, it keeps scrolling down.
The interval and number of attempts were tuned by trial and error.

var attempts = 100,
scrollInterval = setInterval(function(){
     scrolled = window.innerHeight+window.scrollY;
     window.scroll(0,scrolled);

    if(scrolled == document.body.clientHeight){
       if(!attempts--){
           clearInterval(scrollInterval);
       }
   }
},200);

Stopping it is simple —

clearInterval(scrollInterval);

When can this be useful?

  1. When you need to quickly scroll to the bottom of a page and you’re too lazy to spin the mouse wheel. (This was actually my case, I needed to scroll through a list of 1000 twitter follows, so I could then emulate clicking the “Unfollow” button on all of them)
  2. When you need to scroll your feed back several years.

Lzhedmitriy 2.0