User:Dlrohrer2003/validate-css.js

/* Validate CSS * ============================================================================= * Description: Add a tab to a CSS validation service on User and MediaMiki *             namespace CSS pages. This Script is inspired by and loosely *             based on a Wikimedia Commons gadget: *             Commons:MediaWiki:Gadget-CSSValidate.js * *     Author: User:Dlrohrer2003 * * Categories: */

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

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

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

const pageURL = window.location.protocol + conf.wgServer + mw.util.getUrl( conf.wgPageName, {action: 'raw', ctype: 'text/css'} ); const cssValidator = 'https://jigsaw.w3.org/css-validator/validator?' + $.param( { usermedium: 'all', warning: '1', lang: 'en', uri: pageURL } );

mw.util.addPortletLink( 'p-cactions', cssValidator, 'Validate CSS', 'ca-validate-css', 'Validate CSS', '', null );

} });