User:This, that and the other/temp/MediaWiki:Gadget-TabShortener.js

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.
/**
 * +-----------------------------------------------------------------------------+
 * |                    === 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.'); });