Recently, we needed to perform an infinite scroll on a website so that it would load all of its resources (both text and images). As the website was too long and it would take hours to manually scroll little by little, we used the Firefox console and JavaScript to perform the scroll without any additional plugins.
To do so we followed these steps: First we pressed the F12
button to enable the build-in console of Firefox.
Then, we typed allow pasting
in the console to enable the ability to paste code directly into the console editor. Once we did that, we deleted the text allow pasting
as it would create a problem once we run our code later on.
Following, we pasted the following code which both defines the function that performs the infinite scroll and the call that starts it.
//To avoid naming conflicts, give a non common names to the function and variable
var bytefreaksTimeout;
function bytefreaksScroll() {
window.scrollBy(0,1);
bytefreaksTimeout = setTimeout(bytefreaksScroll,10);
}
bytefreaksScroll();
As you will see in the following video, the scrolling was working flawlessly, once the scrolling reached the place we needed it to we used the following line in the console to stop the scrolling.
clearTimeout(bytefreaksTimeout);