User:Steve/monobook.js

From Homestar Runner Wiki

< User:Steve
Revision as of 22:01, 21 September 2006 by Steve (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Mozilla / Firefox: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac)
  • Safari: press Cmd-Option-E
  • IE: hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Konqueror: simply click the Reload button, or press F5
  • Opera users may need to completely clear their cache in Tools→Preferences.
// Add time to the "personal menu" at the top of the page.
// Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay
//
// Indicate where you would like the time to appear:
//   pt-userpage, pt-mytalk, pt-preferences,
//   pt-watchlist, pt-mycontris, pt-logout
//
gsTimeInsertBefore = ; // leave blank to append after "logout"
//
function getTime() {
  var time = new Date();
  var hours = time.getUTCHours();
  if (hours < 10) { hours = "0" + hours; }
  var minutes = time.getUTCMinutes();
  if (minutes < 10) { minutes = "0" + minutes; }
  var currentTime = hours + ":" + minutes
  document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime);
  doTime = window.setTimeout("getTime()", 1000);
}
function makeTime() {
  var li = document.createElement('li');
  li.id = 'pt-time';
  var mySpan = document.createElement('span');
  mySpan.appendChild( document.createTextNode( '00:00 UTC' ) );
  li.appendChild(mySpan);
  if (gsTimeInsertBefore) {
    var before = document.getElementById(gsTimeInsertBefore);
    before.appendChild( li, before );
  }
  else {
    document.getElementById('pt-logout').parentNode.appendChild(li);
  }
  doTime = window.setTimeout("getTime()", 1000);
}
if (window.addEventListener) window.addEventListener ('load', makeTime, false);
else if (window.attachEvent) window.attachEvent ('onload', makeTime);