Simple Greasemonkey Reload Script


Granted, it could use some flash, but it works. Default is 120 seconds.

  var reloadInterval;
  var startingTime=120;
  var currentTime;
  $('body').append(
    $('<div>').css({
      'position':'fixed',
      'background':'cornsilk',
      'left':0,
      'bottom':0,
      'padding':'8px',
    })
    .append("<label for=reload_timer>Reload Timer</span>")
    .append(
      $('<input type=checkbox id=reload_timer />')
      	.on('change',function(){
          if( $(this).is(':checked') ) { 
            window.localStorage.reloadTimer=1;
            currentTime=startingTime;
            reloadInterval = setInterval(function(){
              currentTime--;

            	$('#reload_status').html("Reloading in "+currentTime+' seconds');
              
              if( currentTime<1 ) {
		            clearInterval(reloadInterval);
              	window.location = window.location;
            		$('#reload_status').html("Reloading!");
              }
              
            },1000);
          } else {
            window.localStorage.reloadTimer=0;
            clearInterval(reloadInterval);
            $('#reload_status').html('');
          }
          
        })
    ).append("<span id=reload_status>")
  );
  
  if( parseInt(window.localStorage.reloadTimer,10)==1 ) { 
    $('#reload_timer').trigger('click');
  }

It does require jQuery loaded up into your gmscript, which can take some troubleshooting. But here’s what the head of the script looks like:

// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// ==/UserScript==

jQuery.noConflict();

(function($) {
  // stuff goes here
});