User:Serpent King/common.js

function ModifySidebar( action, section, name, link ) { try { switch ( section ) { 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; }

if ( action == 'add' ) { var node = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0]; if ( link != '' ) { var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' ); aNode.appendChild( document.createTextNode( name ) ); aNode.setAttribute( 'href', link ); liNode.appendChild( aNode ); liNode.className = 'plainlinks'; node.appendChild( liNode ); } else { var liNode = document.createElement( 'p' ); liNode.appendChild( document.createTextNode( name ) ); node.appendChild( liNode ); }		}

if ( action == 'remove' ) { var list = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0];

var listelements = list.getElementsByTagName( 'li' );

for ( var i = 0; i < listelements.length; i++ ) { if (					listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||					listelements[i].getElementsByTagName( 'a' )[0].href == link				) {					list.removeChild( listelements[i] ); }			}		}

} catch( e ) { // let's just ignore what's happened return; } }

function CustomizeModificationsOfSidebar { // adds Special:Editcount to toolbox for userpages only if (mw.config.get("wgNamespaceNumber") == 2 || mw.config.get("wgNamespaceNumber") == 3) { ModifySidebar( 'add', 'toolbox', 'Edit count', 'http://www.ssbwiki.com/Special:Editcount/' + mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'All logs', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&page=User%3A'+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Block log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=block&page=User%3A'+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Account creation log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=newusers&page=User%3A'+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Upload log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=upload&user='+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Deletion log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=delete&user='+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Move log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=move&user='+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'Protection log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=protect&user='+mw.config.get("wgRelevantUserName")); ModifySidebar( 'add', 'toolbox', 'User rights log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=rights&page=User%3A'+mw.config.get("wgRelevantUserName")); }	if (mw.config.get("wgPageName") == 'Special:RecentChanges') { ModifySidebar( 'add', 'toolbox', 'All logs', 'http://www.ssbwiki.com/Special:Logs/'); ModifySidebar( 'add', 'toolbox', 'Block log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=block'); ModifySidebar( 'add', 'toolbox', 'Account creation log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=newusers'); ModifySidebar( 'add', 'toolbox', 'Upload log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=upload'); ModifySidebar( 'add', 'toolbox', 'Deletion log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=delete'); ModifySidebar( 'add', 'toolbox', 'Move log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=move'); ModifySidebar( 'add', 'toolbox', 'Protection log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=protect'); ModifySidebar( 'add', 'toolbox', 'User rights log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=rights'); ModifySidebar( 'add', 'toolbox', 'NAMESPACES', ''); ModifySidebar( 'add', 'toolbox', 'main:0; user:2; smashwiki:4; file:6; mediawiki:8; template:10; help:12; category:14; smasher:100; forum:110', ''); } else if (mw.config.get("wgNamespaceNumber") != 2 && mw.config.get("wgNamespaceNumber") != 3 && mw.config.get("wgNamespaceNumber") != -1) { ModifySidebar( 'add', 'toolbox', 'All logs', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&page='+mw.config.get('wgPageName')); ModifySidebar( 'add', 'toolbox', 'Deletion log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=delete&page='+mw.config.get('wgPageName')); ModifySidebar( 'add', 'toolbox', 'Move log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=move&page='+mw.config.get('wgPageName')); ModifySidebar( 'add', 'toolbox', 'Protection log', 'http://www.ssbwiki.com/index.php?title=Special%3ALog&type=protect&page='+mw.config.get('wgPageName')); } }

jQuery( CustomizeModificationsOfSidebar );