User:Infrangible/monobook.js

function customiseMyPage { runReplace; }

if (window.addEventListener) window.addEventListener("load",customiseMyPage,false); else if (window.attachEvent) window.attachEvent("onload",customiseMyPage);

function runReplace {   // NAMES var mode="CREATE|MAINTAIN|PRUNE|DO NOTHING";

// determine mode based on date date= new Date; milliSeconds = (date.getTime) / 86400000; intMode=Math.floor(milliSeconds) % 4; if (intMode == 0) {       mode="CREATE"; }   if (intMode == 1) {       mode="MAINTAIN"; }   if (intMode == 2) {       mode="PRUNE"; }   if (intMode == 3) {       mode="DO NOTHING"; }

// REPLACEMENT var replaceText = document.body.innerHTML; replaceText=doReplace(replaceText,"TODAYS_WIKI_MODE",mode); document.body.innerHTML = replaceText; }

function doReplace(bodyText, searchTerm, replaceTerm) { var newText = ""; var i = -1; var lcSearchTerm = searchTerm.toLowerCase; var lcBodyText = bodyText.toLowerCase; while (bodyText.length > 0) { i = lcBodyText.indexOf(lcSearchTerm, i+1); if (i < 0) { newText += bodyText; bodyText = ""; } else { // skip anything inside an HTML tag // skip anything inside a block if (lcBodyText.lastIndexOf("/textarea>", i) >= lcBodyText.lastIndexOf("<textarea", i)) { newText += bodyText.substring(0, i) + replaceTerm; bodyText = bodyText.substr(i + searchTerm.length); lcBodyText = bodyText.toLowerCase; i = -1; }   }  }  return newText; }