/* Any JavaScript here will be loaded for registered users only */

mw.loader.using(  ).done( function () {
	/**
	 * Redirect User:Name/skin.js and skin.css to the current skin's pages
	 * (unless the 'skin' page really exists).
	 *
	 * Dependencies: mediawiki.util
	 *
	 * @source https://www.mediawiki.orghttps://wiki95.com/en/Snippets/Redirect_skin.js
	 * @revision 2016-04-13
	 */
	if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
		var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
		// Make sure there was a part before and after the slash
		// And that the latter is 'skin.js' or 'skin.css'
		if ( titleParts.length === 2 ) {
			var userSkinPage = titleParts + '/' + mw.config.get( 'skin' );
			if ( titleParts === 'skin.js' ) {
				window.location.href = mw.util.getUrl( userSkinPage + '.js' );
			} else if ( titleParts === 'skin.css' ) {
				window.location.href = mw.util.getUrl( userSkinPage + '.css' );
			}
		}
	}
	/* Actions specific to the edit page */
	if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
		/**
		 * Fix edit summary prompt for undo
		 *
		 *  Fixes the fact that the undo function combined with the "no edit summary prompter"
		 *  complains about missing editsummary, if leaving the edit summary unchanged.
		 *  Added by ], code by ].
		 *  See also ].
		 */
		$( function () {
			if ( document.location.search.indexOf( 'undo=' ) !== -1 && document.getElementsByName( 'wpAutoSummary' ) ) {
				document.getElementsByName( 'wpAutoSummary' ).value = '1';
			}
		} );
	}
});