Jump to content

User:Dlrohrer2003/validate-css.js

From wikishia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/** 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: [[Category:Wikipedia scripts]]
 */

$( function() {

    var conf = mw.config.get(['wgPageName', 'wgNamespaceNumber', 'wgServer', 'wgScript']);

    if (conf.wgPageName.match(/\.css$/i) && (2 == conf.wgNamespaceNumber || 8 == conf.wgNamespaceNumber)) {

        var validator = "http://jigsaw.w3.org/css-validator/validator?uri=";
        var pageURL = window.location.protocol + conf.wgServer + conf.wgScript + "?title=" + conf.wgPageName + "&action=raw&ctype=text/css";

        mw.util.addPortletLink("p-cactions", validator + encodeURIComponent(pageURL), "Validate CSS", "ca-validatecss" ,"Validate CSS" ,"" , null);

    }
});