Jump to content

User:Ioeth/friendlytabs.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ioeth (talk | contribs) at 21:38, 20 November 2008 (testing new feature). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// 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-nstab-help', name: 'Help' },
		{ id: 'ca-nstab-special', name: 'Special' },
		{ id: 'ca-nstab-project', name: 'Project' },
		{ id: 'ca-nstab-user', name: 'User' },
		{ id: 'ca-edit', name: 'Edit' },
		{ id: 'ca-viewsource', name: 'Source' },
		{ id: 'ca-talk', name: 'Talk' },
		{ id: 'ca-undelete', name: 'Undelete' },
		{ id: 'ca-addsection', name: '+' }
	];
}
 
function friendlytabs() {
	for(i = 0; i < idsToRename.length; i++) {
		if(document.getElementById(idsToRename[i].id)) {
			if(idsToRename[i].id == 'ca-nstab-main' && typeof( idsToRename[i].mainPageOnly ) == boolean && idsToRename[i].mainPageOnly && document.getElementById('ca-nstab-main').firstChild.href == 'http://en.wikipedia.org/wiki/Main_Page' ) {
				document.getElementById( idsToRename[i].id ).firstChild.innerHTML = idsToRename[i].name;
			} else {
				document.getElementById(idsToRename[i].id).firstChild.innerHTML = idsToRename[i].name;
			}
		}
	}
}
 
addOnloadHook(friendlytabs);