User:Kernigh sockpuppet/monobook.js

//

/* * Monobook script of Kernigh sockpuppet at Wikihack - public domain * * ATTENTION! Do not copy to MediaWiki:Monobook.js without * configuring correct main page and changing ca-nstab-user * to ca-nstab-main. */

// customise the script here scr = new Object; scr.wikiName      = "Wikihack"; // from title bar scr.frontPageName = "User:Jayt/Sandbox/Main Page"; // from title bar scr.frontPagePhp  = "User:Jayt/Sandbox/Main_Page"; // from index.php?title=

/* * Monobook "front page" formatting script * by Kernigh - public domain * * The purpose of this script is remove the heading from * the wiki's front page and to rename the article tab. */

// is this article being the named page? function isNamedPage( wikiName, pageName ) { return document && document.title && document.title.indexOf && document.title.indexOf( pageName + " - " + wikiName ) == 0; }

// use DOM to remove siteSub, firstHeading function removeFirstHeading { if( document && document.getElementById && document.getElementsByTagName ) { var h1s = document.getElementsByTagName( "h1" ); var siteSub = document.getElementById( "siteSub" ); if( h1s && h1s.item ) { var firstHeading = h1s.item(0); if( firstHeading && firstHeading.parentNode && firstHeading.parentNode.removeChild ) firstHeading.parentNode.removeChild( firstHeading ); }

if( siteSub && siteSub.parentNode && siteSub.parentNode.removeChild ) siteSub.parentNode.removeChild( siteSub ); } } if( isNamedPage( scr.wikiName, scr.frontPageName ) ) addOnloadHook( removeFirstHeading );

// does the article tab go to the named page? function isNearNamedPage( wikiName, pageName ) { if( isNamedPage( wikiName, pageName ) ) return true; if( isNamedPage( wikiName, "Talk:" + pageName ) ) return true;

// else check the title= argument in the url if( document && document.URL ) { var url = document.URL + "&";

return url.indexOf( "?title=" + scr.frontPagePhp + "&" ) > -1 || url.indexOf( "?title=Talk:" + scr.frontPagePhp + "&" ) > -1 || url.indexOf( "&title=" + scr.frontPagePhp + "&" ) > -1 || url.indexOf( "&title=Talk:" + scr.frontPagePhp + "&" ) > -1; }

return false; }

// use DOM to rename "article" tab to "front page" function formatFrontPageTab { if( document && document.getElementById ) { var mainTab = document.getElementById( "ca-nstab-user" );

if( document.createTextNode && mainTab && mainTab.firstChild ) { var frontPageLink = mainTab.firstChild; var frontPageText = document.createTextNode("front page"); if( frontPageLink.replaceChild && frontPageLink.firstChild ) frontPageLink.replaceChild( frontPageText, frontPageLink.firstChild ); } } } if ( isNearNamedPage( scr.wikiName, scr.frontPageName ) ) addOnloadHook( formatFrontPageTab );