User:RockMFR/localtimemainpage.js

if (wgPageName == "Main_Page" && (wgAction == "view" || wgAction == "purge")) { var offset = dayOffsetFromUTC; if (offset == -1) { switchContent("Wikipedia:Main_Page/Yesterday"); } else if (offset == 1) { switchContent("Wikipedia:Main_Page/Tomorrow"); } }

// returns -1 if one day behind UTC, 0 if same day, 1 if one day ahead function dayOffsetFromUTC { var ourDate = new Date; if (ourDate.getDate != ourDate.getUTCDate) { if (ourDate.getTimezoneOffset < 0) { // ahead of UTC return 1; } else if (ourDate.getTimezoneOffset > 0) { // behind UTC return -1; } }  return 0; }

// switches page content to newPage function switchContent(newPage) { addOnloadHook(function {   try {      http_request = new ActiveXObject('Msxml2.XMLHTTP');    } catch (e) {      try {        http_request = new ActiveXObject('Microsoft.XMLHTTP');      } catch (e) {        try {          http_request = new XMLHttpRequest;        } catch (e) {          http_request = false;        }      }    }    if (!http_request) {      return;    }    document.getElementById("bodyContent").innerHTML = 'Loading...';    http_request.open('GET','/w/api.php?action=parse&page=' + newPage + '&format=json',true);    http_request.send(null);    http_request.onreadystatechange = function {      if (http_request.readyState == 4) {        var result = eval( '(' + http_request.responseText + ')' );        document.getElementById("bodyContent").innerHTML = result['parse']['text']['*']; // FIXME      }    };  }); }