User:Megadardery/common.js

function AddSidebarItem(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) { return; } } function AddTab(action, after, tooltip, shortcutbutton) {

mw.util.addPortletLink(		'p-cactions', 		wgScript + "?title=" + wgPageName + "&action=" + action,		action,		'ca-' + action,		tooltip,		shortcutbutton,		document.getElementById('ca-' + after).nextSibling	); document.getElementById('ca-' + action).parentNode.insertBefore(document.createTextNode("\n"), document.getElementById('ca-' + action));

if (wgAction == action) { document.getElementById('ca-' + action).className += "selected"; } } function Summary(entervalue) { document.editform.wpSummary.value = entervalue; } if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !document.getElementById('wpForReUpload') && !document.getElementsByClassName('warning')[0] && !document.getElementsByClassName('error')[0]) { function loadAutoAboutfileTemplate {  uploadDescription = document.getElementById('wpUploadDescription');

uploadDescription.value = '{' + '{' + 'aboutfile\n|1=\n|2=\'\'\'\'\n}}'; }

addOnloadHook(loadAutoAboutfileTemplate); }

function SidebarItems { AddSidebarItem("toolbox", "Preview Subpages", wgServer+wgArticlePath.replace("$1", "Special:PrefixIndex/"+wgPageName+"/"), "Preview all subpages of this page."); AddSidebarItem("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 Tabs { AddTab("info", "history", "Show helpful info for the current page.", "i"); AddTab("purge", "move", "Purge this page to clear the cache and force the most current revision to appear.", "u"); }

//Enable or disable the above codes addOnloadHook(Tabs); addOnloadHook(SidebarItems); addOnloadHook(Summary('delete tag'));