跳转到内容

User:Frankou/Friendly/friendlytabs.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// 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 < FriendlyConfig.idsToRename.length; i++) {
		if(document.getElementById(FriendlyConfig.idsToRename[i].id)) {
			if(FriendlyConfig.idsToRename[i].id == 'ca-nstab-main' && typeof( FriendlyConfig.idsToRename[i].mainPageOnly ) == 'boolean' && FriendlyConfig.idsToRename[i].mainPageOnly  ) {
				if( document.getElementById('ca-nstab-main').firstChild.href.indexOf('Main_Page') != -1 ) {
					document.getElementById( FriendlyConfig.idsToRename[i].id ).firstChild.innerHTML = FriendlyConfig.idsToRename[i].name;
				}
			} else {
				document.getElementById( FriendlyConfig.idsToRename[i].id ).firstChild.innerHTML = FriendlyConfig.idsToRename[i].name;
			}
		}
	}
}
 
$(friendlytabs);