User:This, that and the other/temp/MediaWiki:Gadget-TabShortener.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:This, that and the other/temp/MediaWiki:Gadget-TabShortener. |
/**
* +-----------------------------------------------------------------------------+
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
* +-----------------------------------------------------------------------------+
*
* Gadget-TabShortener.js: Tab shortening utility
*
* Originially by [[User:Ioeth]] as part of Friendly (now Twinkle).
* Converted to gadget by [[User:This, that and the other]].
*
* A non-gadget, customizable version is available at [[User:Ioeth/friendlytabs.js]].
*/
var TabShortener = {
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: 'History' },
{ id: 'ca-nstab-special', name: 'Special' },
{ id: 'ca-special', name: 'Special' },
{ id: 'ca-nstab-project', name: 'Project' },
{ id: 'ca-project', name: 'Project' },
{ id: 'ca-nstab-user', name: 'User' },
{ id: 'ca-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: '+' }
],
findCaption: function(tab) {
while (tab.nodeType !== 3) { // Until we find a text node
tab = tab.firstChild;
}
return tab.parentNode;
},
init: function() {
$.each(TabShortener.idsToRename, function() {
if (document.getElementById(this.id)) {
if( this.mainPageOnly && mw.config.get('wgPageName') === 'Main_Page' ) {
TabShortener.findCaption( document.getElementById( this.id ) ).innerHTML = this.name;
} else {
TabShortener.findCaption( document.getElementById( this.id ) ).innerHTML = this.name;
}
}
});
}
};
$(document).ready(TabShortener.init);
$(document).ready(function() { mw.util.jsMessage('You are using a nasty old bit of code that I\'d like to get rid of. Please contact <a href="/wiki/User_talk:This,_that_and_the_other">This, that and the other</a> for more info.'); });