User:Kernigh/sysop.js

//

/* * Monobook script * by Kernigh - public domain * * Sysops can use this script to move those "protect" and "delete" * tabs out of the way. */

function moveSysopTabs { var protectTab = document.getElementById( "ca-protect" ); // li var deleteTab = document.getElementById( "ca-delete" );   // li  var toolbox = document.getElementById( "p-tb" ); // div var toolbody = false; var toolist = false; var i, j;

// find toolbody = div child of toolbox if( i = toolbox.childNodes ) for( j = 0; j < i.length; j++ ) if( i.item( j ).nodeName.toLowerCase == "div" ) toolbody = i.item( j );

// find toolist = ul child of toolbody if( i = toolbody.childNodes ) for( j = 0; j < i.length; j++ ) if( i.item( j ).nodeName.toLowerCase == "ul" ) toolist = i.item( j );

// proceed only if all elements exist and DOM is in order if( protectTab && deleteTab && toolist && toolist.appendChild ) {

// move the tabs to the toolbox toolist.appendChild( protectTab ); toolist.appendChild( deleteTab );

// if possible, label them as "[Sysop]" if( document.createTextNode ) { if( protectTab.firstChild && protectTab.insertBefore ) protectTab.insertBefore(document.createTextNode( "[Sysop] " ),                               protectTab.firstChild ); if( deleteTab.firstChild && deleteTab.insertBefore ) deleteTab.insertBefore(document.createTextNode( "[Sysop] " ),                               deleteTab.firstChild ); }

} } addOnloadHook( moveSysopTabs );

//