User:Frostels/monobook.js

e optional, though providing at * least an id and a tooltip is recommended. * * By default the new link will be added to the end of the list. To * add the link before a given existing item, pass the DOM node of * that item (easily obtained with document.getElementById) as the * nextnode parameter; to add the link _after_ an existing item, pass * the node's nextSibling instead. * * @param String portlet -- id of the target portlet ("p-cactions", "p-personal", "p-navigation" or "p-tb") * @param String href -- link URL * @param String text -- link text (will be automatically lowercased by CSS for p-cactions in Monobook) * @param String id -- id of the new item, should be unique and preferably have the appropriate prefix ("ca-", "pt-", "n-" or "t-") * @param String tooltip -- text to show when hovering over the link, without accesskey suffix * @param String accesskey -- accesskey to activate this link (one character, try to avoid conflicts) * @param Node nextnode -- the DOM node before which the new item should be added, should be another item in the same list * * @return Node -- the DOM node of the new item (an LI element) or null */ function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) { var node = document.getElementById(portlet); if ( !node ) return null; node = node.getElementsByTagName( "ul" )[0]; if ( !node ) return null;

var link = document.createElement( "a" ); link.appendChild( document.createTextNode( text ) ); link.href = href;

var item = document.createElement( "li" ); item.appendChild( link ); if ( id ) item.id = id;

if ( accesskey ) { link.setAttribute( "accesskey", accesskey ); tooltip += " ["+accesskey+"]"; }	if ( tooltip ) { link.setAttribute( "title", tooltip ); }	if ( accesskey && tooltip ) { updateTooltipAccessKeys( new Array( link ) ); }

if ( nextnode && nextnode.parentNode == node ) node.insertBefore( item, nextnode ); else node.appendChild( item ); // IE compatibility (?)

return item; }

addOnloadHook( function { //add janitor portlet var portlet      = document.createElement( 'div' ); portlet.className = 'portlet'; portlet.id        = 'p-janitor'; portlet.innerHTML = ' janitor   '; var pTb = document.getElementById( 'p-wikicities-nav' ) pTb.parentNode.insertBefore( portlet, pTb ); delete pTb, portlet; // addPortletLink(portlet, href, text, id, tooltip, accesskey, document.getElementById( 'nextnodes' )) addPortletLink( 'p-janitor', '/wiki/PvXwiki:Unvetted pages', 'Unvetted Builds', 'n-unvetted', 'Unvetted Builds' ); addPortletLink( 'p-janitor', '/wiki/Special:GraceExpired', 'Grace Expired', 'n-graceexpired', 'Grace Expired' ); addPortletLink( 'p-janitor', '/wiki/Category:Candidates_for_deletion', 'Deletion Candidates', 'n-deletion', 'Deletion Candidates' ); addPortletLink( 'p-janitor', '/wiki/Special:Uncategorizedpages', 'Uncategorized Pages', 'n-uncatpage', 'Uncategorized Pages' ); addPortletLink( 'p-janitor', '/wiki/Special:BrokenRedirects', 'Broken Redirects', 'n-brokenredirect', 'Broken Redirects' ); addPortletLink( 'p-janitor', '/wiki/Special:DoubleRedirects', 'Double Redirects', 'n-doubleredirect', 'Double Redirects' ); addPortletLink( 'p-janitor', '/wiki/Category:Stubs', 'Stub Articles', 'n-stub', 'Stub Articles' ); addPortletLink( 'p-janitor', '/wiki/Category:Has stub sections', 'Stub Sections', 'n-stubsections', 'Stub Sections' ); addPortletLink( 'p-janitor', '/wiki/Category:Rewrite', 'Needs Rewriting', 'n-rewrite', 'Rewrite Category' ); addPortletLink( 'p-janitor', '/wiki/Category:Cleanup', 'Needs Cleanup', 'n-cleanup', 'Cleanup Category' ); addPortletLink( 'p-janitor', '/wiki/Category:Articles to be merged', 'Needs Merge', 'n-merge', 'Merge Category' ); addPortletLink( 'p-janitor', '/wiki/Category:Builds that need updating', 'Needs Update', 'n-update', 'Build-Update Category' ); addPortletLink( 'p-janitor', '/wiki/Category:Archive-Pending', 'Archive Pending', 'n-archivepending', 'Archive-Pending Category' ); addPortletLink( 'p-janitor', '/wiki/Special:Log/block', 'Block Log', 'n-BlockLog', 'Block Log' ); addPortletLink( 'p-janitor', '/wiki/Special:Ipblocklist', 'Block List', 'n-IPBlockList', 'List of Blocked Users and IPs' );

//Checkuser if ( wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) addPortletLink( 'p-cactions', '/wiki/Special:CheckUser?user=' + wgTitle.match( '^(^[^\/]+)(\/.*)?$' )[1], 'Check User', 'n-checkuser', 'Check User' );

//User Contributions if ( wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) addPortletLink( 'p-cactions', '/wiki/Special:Contributions/' + wgTitle.match( '^(^[^\/]+)(\/.*)?$' )[1], 'User Contributions', 'n-UserContributions', 'User Contributions' );

//Add Section if ( wgNamespaceNumber == 0 || wgNamespaceNumber == 2 || wgNamespaceNumber == 100) { addPortletLink( 'p-cactions', '/index.php?title=' + wgPageName + '&action=edit&section=new', 'Add Section', 'n-addsection', 'Add a section to this page' ) };

//Misc. addPortletLink( 'p-tb', '/wiki/Special:Mypage/monobook.js', 'My Monobook', 'n-monobook', 'My monobook.js' ); addPortletLink( 'p-personal', '/wiki/User:Toraen/Sandbox', 'My Sandbox', 'n-sandbox', 'My Sandbox' ); addPortletLink( 'p-personal', '/wiki/Special:Watchlist', 'My Watchlist', 'n-watchlist', 'My Watchlist' ) addPortletLink( 'p-cactions', '/index.php?title=' + wgPageName + '&action=purge', 'Purge Cache', 'n-purgecache', 'Purges the sever cache for this page' );

} );