MediaWiki:Group-user.js

出自維基百科,自由嘅百科全書

注意:儲存之後,你可能要兜過你嘅瀏覽器快取至睇到更改。Internet Explorer: 撳住Ctrl掣再撳重新整理掣。 Firefox: 撳住Shift掣再撳重新載入(又或者撳Ctrl-Shift-R)。 Google Chrome同埋Safari用戶就噉撳個重載掣。

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

mw.loader.using( [ 'mediawiki.util' ] ).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.org/wiki/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[0] + '/' + mw.config.get( 'skin' );
			if ( titleParts[1] === 'skin.js' ) {
				window.location.href = mw.util.getUrl( userSkinPage + '.js' );
			} else if ( titleParts[1] === 'skin.css' ) {
				window.location.href = mw.util.getUrl( userSkinPage + '.css' );
			}
		}
	}
});