User:PleaseStand/short-title.js

// Released into the public domain  /*global jQuery, mediaWiki*/

( function ( mw, $ ) {	var ns, nsPrefixMap, shortcut;	ns = mw.config.get( 'wgNamespaceNumber' );	if ( ns >= 0 && mw.config.get( 'wgAction' ) === 'view' ) {		nsPrefixMap = {			0: '',			4: 'WP:',			5: 'WT:'		};

shortcut = (			ns in nsPrefixMap				? nsPrefixMap[ns]				: mw.config.get( 'wgFormattedNamespaces' )[ns] + ':'		) + mw.config.get( 'wgTitle' );

mw.loader.using( 'mediawiki.api' ).then( function {			return ( new mw.Api ).get( { action: 'query', revids: mw.config.get( 'wgCurRevisionId' ), prop: 'revisions', maxage: 86400 } );		} ).then( function ( data ) {			var isoDate;			try {				isoDate = data.query.pages[mw.config.get( 'wgArticleId' )].revisions[0].timestamp;			} catch ( e ) {				return;			}

document.title = shortcut + ' - ' + isoDate.replace( /T.*$/, '' ) + ' Wikipedia,' + mw.config.get( 'wgContentLanguage' ).toUpperCase; } );

} else { document.title = document.title.replace( / \- [^\-]*$/, ' - Wikipedia,' + mw.config.get( 'wgContentLanguage' ).toUpperCase ); } }( mediaWiki, jQuery ) );