MediaWiki:MoveSubcategoriesToTheTop.js

-function (config) { // moves subcats to trending pages var mwc = mw.config.get(['wgNamespaceNumber', 'wgUserName', 'wgPageName']), api = new mw.Api, $target = $('.category-page__trending-pages'), $ul = $('', {           class: 'cathoist-container category-page__trending-pages',        }); if (config.loaded || !mwc.wgUserName || !$target.length || mwc.wgNamespaceNumber !== 14) return; config.loaded = !0; api.get({       action: 'query',        list: 'categorymembers',        cmtype: 'subcat',        cmlimit: 500,        cmtitle: mwc.wgPageName    }) .done(function(data) {       if (!data || data.error) {            console.log('cathoist.get error', data);            return;        }        var cats = data.query.categorymembers;        if (!cats.length) return;        cats.forEach(function(cat) { var $a = $('', {               class: 'category-page__trending-page-title',                text: cat.title,                href: new mw.Title(cat.title).getUrl            }), $li = $('', {               class: 'category-page__trending-page',            }); $li.append($a); $ul.append($li); });       $ul.insertAfter($target);    }) .fail(function(data) {       console.log('cathoist.fail', data);    }); }(window.catHoist = window.catHoist || {});