User:Xrblsnggt/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
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 <textarea> 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; }