User:Xrblsnggt/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 t1="REPLACEME"; var t2="AFD_UTC_LOG_DATE";

// VALUES var v1="REPLACED"; //YYYY_Month_DD var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); var myDate=new Date var v2="" + myDate.getUTCFullYear + "_" + monthname[myDate.getUTCMonth] + "_" + myDate.getUTCDate;

// REPLACEMENT var replaceText = document.body.innerHTML; replaceText=doReplace(replaceText,t1,v1); replaceText=doReplace(replaceText,t2,v2); // ...   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; }