Jump to content

MediaWiki:Common.js

Revision as of 22:41, 11 March 2026 by Redk1tty (talk | contribs)

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.
(function () {
    if (mw.config.get('wgNamespaceNumber') < 0) return;

    var title = mw.config.get('wgPageName');
    var cssPage = 'Template:PageCSS/' + title + '.css';

    var api = new mw.Api();

    api.get({
        action: 'query',
        titles: cssPage,
        format: 'json'
    }).done(function (data) {
        var pages = data.query.pages;
        var pageId = Object.keys(pages)[0];

        if (pageId !== "-1") {
            var cssUrl = mw.util.getUrl(cssPage, { action: 'raw', ctype: 'text/css' });
            mw.loader.load(cssUrl, 'text/css');
        }
    });
})();