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.
/* Validate CSS
 * =============================================================================
 * Description: Add a tab to a CSS validation service on CSS pages with the
 *              "css" and "sanitized-css" page content model. This Script is
 *               inspired by and loosely based on a Wikimedia Commons gadget:
 *              [[Commons:MediaWiki:Gadget-CSSValidate.js]]
 *
 *      Author: [[User:Dlrohrer2003]]
 */

mw.loader.using( [ 'mediawiki.util' ], function() {
	'use strict';

	const conf = mw.config.get( [ 'wgPageContentModel' ] );

	if (
		( conf.wgPageContentModel === 'css' || conf.wgPageContentModel === 'sanitized-css' )
		&& !document.getElementById( 'ca-validate-css' )
	) {

		const validatorParams = {
			usermedium: 'all',
			warning: '1',
			lang: 'en',
			uri: window.location.origin + mw.util.getUrl( null, {action: 'raw', ctype: 'text/css'} )
		};

		mw.util.addPortletLink(
			'p-cactions',
			'https://jigsaw.w3.org/css-validator/validator?' + $.param( validatorParams ),
			'Validate CSS',
			'ca-validate-css',
			'Validate CSS',
			'',
			null
		);
	}
});