User:MBisanz/tabs.js

// If FriendlyConfig aint exist. if( typeof( FriendlyConfig ) == 'undefined' ) { FriendlyConfig = {}; }

/** FriendlyConfig.idsToRename ( array ) An array of hashes that defines the ids of the tabs to be renamed and what they should be renamed to. */ if( typeof( FriendlyConfig.idsToRename ) == 'undefined' ) { FriendlyConfig.idsToRename = [ { id: 'ca-nstab-main', name: 'Main', mainPageOnly: true }, { id: 'ca-main', name: 'Main', mainPageOnly: true }, { id: 'ca-nstab-help', name: 'Help' }, { id: 'ca-history', name: 'H' }, { id: 'ca-nstab-special', name: 'Special' }, { id: 'ca-special', name: 'Special' }, { id: 'ca-nstab-category', name: 'C' }, { id: 'ca-category', name: 'C' }, { id: 'ca-nstab-project', name: 'WP' }, { id: 'ca-project', name: 'WP' }, { id: 'ca-nstab-user', name: 'U' }, { id: 'ca-user', name: 'U' }, { id: 'ca-edit', name: 'E' }, { id: 'ca-viewsource', name: 'Source' }, { id: 'ca-talk', name: 'T' }, { id: 'ca-protect', name: 'P' }, { id: 'ca-unprotect', name: 'UP' }, { id: 'ca-delete', name: 'D' }, { id: 'ca-undelete', name: 'UD' }, { id: 'ca-watch', name: 'W' }, { id: 'ca-unwatch', name: 'UW' }, { id: 'ca-move', name: 'M' }, { id: 'ca-addsection', name: '+' } ]; }

function friendlyFindTabCaption(tab) { while (tab.nodeType != 3) { //Until we find a text node tab = tab.firstChild; }	return tab.parentNode; }

function friendlytabs { for(i = 0; i < FriendlyConfig.idsToRename.length; i++) { if(document.getElementById(FriendlyConfig.idsToRename[i].id)) { if(typeof( FriendlyConfig.idsToRename[i].mainPageOnly ) == 'boolean' && FriendlyConfig.idsToRename[i].mainPageOnly ) { if( mw.config.get('wgPageName') == 'Main_Page' ) { friendlyFindTabCaption( document.getElementById( FriendlyConfig.idsToRename[i].id ) ).innerHTML = FriendlyConfig.idsToRename[i].name; }			} else { friendlyFindTabCaption( document.getElementById( FriendlyConfig.idsToRename[i].id ) ).innerHTML = FriendlyConfig.idsToRename[i].name; }		}	} } $(friendlytabs);