User:Karate Jesus/monobook.js

/** * Add a link to one of the portlet menus on the page, including: * * p-cactions: Content actions (shown as tabs above the main content in Monobook) * p-personal: Personal tools (shown at the top right of the page in Monobook) * p-navigation: Navigation * p-tb: Toolbox * * This function exists for the convenience of custom JS authors. All * but the first three parameters are 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 portlet var portlet      = document.createElement( 'div' ); portlet.className = 'portlet'; portlet.id       = 'p-random'; portlet.innerHTML = ' random   '; var pTb = document.getElementById( 'p-tb' ) pTb.parentNode.insertBefore( portlet, pTb ); delete pR, portlet;

//add portlet var portlet      = document.createElement( 'div' ); portlet.className = 'portlet'; portlet.id       = 'p-admin'; portlet.innerHTML = ' admin   '; var pTb = document.getElementById( 'p-random' ) pTb.parentNode.insertBefore( portlet, pTb ); delete pR, portlet;

// addPortletLink(portlet, href, text, id, tooltip, accesskey, document.getElementById( 'nextnodes' )) addPortletLink( 'p-admin', '/Grace_Expired', 'Grace Expired', 'n-graceexpired', 'Grace Expired' ); addPortletLink( 'p-admin', '/User:Phenaxkian/Delete', 'Deletion candidates', 'n-deletion', 'Deletion Candidates' ); addPortletLink( 'p-admin', '/Special:Log/block', 'Block Log', 'n-BlockLog', 'Block Log' ); addPortletLink( 'p-admin', '/Special:Ipblocklist', 'Block List', 'n-IPBlockList', 'List of Blocked Users and IPs' ); addPortletLink( 'p-admin', '/Special:Block/' + wgTitle.match( '^(^[^\/]+)(\/.*)?$' )[1], 'Block User', 'n-BlockUser', 'Block User' );

//Checkuser if ( wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) { addPortletLink( 'p-cactions', '/Special:CheckUser?user=' + wgTitle.match( '^(^[^\/]+)(\/.*)?$' )[1], 'Check User', 'n-checkuser', 'Check User' ); }else { addPortletLink( 'p-cactions', '/Special:CheckUser', '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' ); };

//Random addPortletLink( 'p-random', '/User:Karate Jesus/Shit I hate to look up', 'Random Shit', 'n-randomshit', 'Random Shit' ); addPortletLink( 'p-random', '/Special:DeletedContributions', 'Deleted Contribs', 'n-deletedcontribs', 'Deleted Contribs' ); addPortletLink( 'p-random', '/Special:BrokenRedirects', 'Broken Redirects', 'n-brokenredirect', 'Broken Redirects' ); addPortletLink( 'p-random', '/Special:DoubleRedirects', 'Double Redirects', 'n-doubleredirect', 'Double Redirects' ); addPortletLink( 'p-admin', '/Special:Newimages', 'New Images', 'n-newimages', 'Gallery of New Images' ); addPortletLink( 'p-admin', '/Special:Uncategorizedpages', 'Uncategorised Pages', 'n-uncatpage', 'Uncategorised pages' ); addPortletLink( 'p-admin', '/Category:Stubs', 'Stub Articles', 'n-stub', 'Stub Articles' ); addPortletLink( 'p-admin', '/PvXwiki:Unvetted pages', 'Unvetted Builds', 'n-unvetted', 'Unvetted Builds' ); } );