Execute custom JavaScript
There is a lot that Auto Refresh Page can do, besides just refreshing the web page. Did you know you can execute custom JavaScript code after each page refresh or at each countdown interval? Think of all the amazing things you can do! To run a script after a page refresh, follow the steps below.
How to run a JavaScript code after a refresh
Install Auto Refresh Page - Google Chrome, Opera / Yandex.Browser, Microsoft Edge
Open Auto Refresh Page and click Advanced options
Checkmark the option Refresh and run code
In the textbox area, enter the following code:
document.querySelector('body'); setTimeout(() => { alert('Hello!') }, 1000);Check "All frames" to capture all internal documents.
Click the Start button to begin the countdown.
The key to running a script after a refresh is to include the line document.querySelector('body'); followed by a setTimeout() which contains the code that you want to execute on the page. You can run any code that you like within the setTimeout() method to perform any number of actions, such as clicking advanced buttons or elements on the page, changing css styles and much more.
Hello World
The following script prints "Hello!" to the browser alert window after each refresh.
setTimeout(() =>
{ alert ('Hello!')
}, 1000);
Changing the page color
The following script changes the web page background color after each countdown interval.
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
document.querySelector('body').style.background = getRandomColor();
What can you do with code?
Perform any action that replaces a person
Automatically click elements on a page
Search for information on a page
Enable / disable various functionality on the page
Scroll the page from top to bottom and vice versa
Change СSS
Register automatically without a person
Fill out and submit forms
Bypass Google Robot Protection
Parse pages
And much more available to your imagination.