This is a little Script that I wrote for the Firefox add-on "GreaseMonkey". It is used to auto-reload (refresh) any open Windows in the browser after a set interval.
How to install a GreaseMonkey UserScript:
(1) First, if you don't have it then you'll need to download and install the Firefox add-on "GreaseMonkey". It is very useful and is used for running scripts in the browser to modify webpages, etc.
(2) Then once it's installed you should have a button for it in Firefox's NavBar or somewhere (depends on what version FF you have). Locate the button and click the arrow next to the monkey for a context menu with options, then select "New User Script...".
(3) Then you should get a window where you are to fill in the information - Name, Namespace, Description, Includes and Excludes. This MetaData is optional and more or less can be added later. You can search GreaseMonkey's site or other places for more information on this. But in this example you only need to enter the Name, so call it "Auto-Reload Window".
(4) Once the information is entered then press "OK" and it installs the script and opens the new script in Notepad for you to edit it.
(5) Go ahead and DELETE ALL OF THE TEXT and then you will replace it with the following JavaScript:
*Note: when separating the tags and the values in the MetaData it looks better to use a couple of "TAB" keys like: "// @name [TAB][TAB] Auto-Reload Window", but for some reason the code box here wasn't having it and they didn't stay in-line.. :(
Code:
// ==UserScript==
// @name Auto-Reload Window
// @namespace http://www.360haven.com
// @version 1.0.0.0
// @author JizzaBeez
// @description Auto-Reload the Window at an interval of 60 seconds.
// @include http://*
// @include https://*
// ==/UserScript==
//Register GreaseMonkey Menu Command:
GM_registerMenuCommand("Reload Window", window.location.reload);
//Add Window Event Listener:
window.addEventListener("load", reloadWindow, false);
//Set the Window to Auto-Reload onload:
window.onload = reloadWindow();
//Function to Set a Timeout and then Reload the Window:
function reloadWindow()
{
window.setTimeout(window.location.reload, 60000);
}
(6) As you can see, the code is very simple. I have it to Register a GreaseMonkey Menu Command (optional) and then a function to reload the window. Once replaced, SAVE THE FILE and then you can close it.
(7) Now when you open a page/window in the browser the page will auto-reload (refresh) after 60 seconds. The script can be disabled/enabled by going back to the GreaseMonkey button and click the arrow (like before) and where you see "Auto-Reload Window", just click it to enable/disable. You will also see that in that menu where it says "User Script Commands..." there will be an option to "Reload Window", by clicking it will reload/refresh the window.
(8) If it's working then you have just successfully installed a new UserScript! Many UserScripts can be found at http://userscripts.org/. Just be cautious of what you install because there are some malicious ones that can steal your information!
*Note: GreaseMonkey has to be enabled in order for any scripts to run.
I have attached this file below. It will be named "auto-reload_window.user.js". All UserScripts must be in JavaScript and the file must be named ending with ".user.js". If you create a New User Script through GreaseMonkey like I explained then you don't have to worry about creating the file and putting it in the correct directory because GreaseMonkey will do it for you, so you can always just let GreaseMonkey create the New User Script and then open it in GreaseMonkey to edit it.
Have fun and happy Scripting!