User:Megadardery/common.js

function Add(heading, title, link, tooltip) { try { switch (heading) { case "languages": var target = "p-lang"; break; case "toolbox": var target = "p-tb"; break; case "navigation": var target = "p-navigation"; break; default: var target = "p-" + section; break; }

var node = document.getElementById(target) .getElementsByTagName('div')[0] .getElementsByTagName('ul')[0]; var aNode = document.createElement('a'); var liNode = document.createElement('li'); aNode.appendChild(document.createTextNode(title)); aNode.setAttribute('href', link); aNode.setAttribute('title', tooltip); liNode.appendChild(aNode); liNode.className='plainlinks'; node.appendChild(liNode);

} catch(e) { // lets just ignore what's happened return; } } function AddItemsToSidebar { Add("toolbox", "Preview Subpages", wgServer+wgArticlePath.replace("$1", "Special:PrefixIndex/"+wgPageName+"/"), "Preview all subpages of this page."); Add("toolbox", "Purge the Cache", wgServer+wgArticlePath.replace("$1", "index.php?title="+wgPageName+"&action=purge"), "Purge this page to clear the cache and force the most current revision to appear."); } function Summary { document.editform.wpSummary.value = 'Changing "NSMB Wii" template name to "NSMBW", discussed on forum'; } addOnloadHook(AddItemsToSidebar); addOnloadHook(Summary);