User:Matthewmayer/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
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 of whether the code is safe, you can ask at the help desk.
// <pre><nowiki> // *** The useful code *** function highlightMyLanguages() { //p-lang } function addUnwatch() { //adds 'unwatch' links in watchlist if (window.location.href.indexOf("Special:Watchlist")!=-1) { //correct page, so retrieve watchlist items var items=document.getElementById('bodyContent').getElementsByTagName('li'); for (var i=0;i<items.length;i++) { //what is the title of this page? pagename=items[i].getElementsByTagName('a')[0].title; //create 'unwatch' element unwatchelt=document.createElement('a'); unwatchelt.setAttribute('href','/w/index.php?title='+pagename+'&action=unwatch'); unwatchelt.setAttribute('title','Unwatch '+pagename); unwatchelt.appendChild(document.createTextNode('(unwatch)')); //add the 'unwatch' element items[i].appendChild(unwatchelt); } } } // Utility functions function addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } function getElementsByClass(searchClass,node,tag) { /* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com Created by: Dustin Diaz :: http://www.dustindiaz.com/ */ var classElements = new Array(); if (node == null) node = document; if (tag == null) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if (pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } // ***add listeners for Unwatch add-on *** if (window.addEventListener) window.addEventListener("load", addUnwatch, false); else if (window.attachEvent) window.attachEvent("onload", addUnwatch); //</nowiki></pre>