User:Fumple/common.js

// ================================================================================ // Page specific JS/CSS // ================================================================================

//Check page specific files mw.loader.using("mediawiki.api", function {    var skin = mw.config.get("skin"),        page = mw.config.get("wgPageName"),        user = mw.config.get("wgUserName");

var pages = [ ['MediaWiki:Common.js/' + page + ".js", "globaljs"], ['MediaWiki:Common.css/' + page + ".css", "globalcss"], ['MediaWiki:' + skin + '.js/' + page + ".js", "skinjs"], ['MediaWiki:' + skin + '.css/' + page + ".css", "skincss"] ];   if (user != null) pages.push(        ['User:' + user + '/common.js/' + page + ".js", "userjs"],        ['User:' + user + '/common.css/' + page + ".css", "usercss"],        ['User:' + user + '/' + skin + '.js/' + page + ".js", "userskinjs"],        ['User:' + user + '/' + skin + '.css/' + page + ".css", "userskincss"]    ); pages.forEach(function (el) {       if (el[1] == "js") {            if (new URL(window.location).searchParams.get("disable-page-js") != null) return;            mw.loader.load('/w/index.php?title=' + encodeURIComponent(el[0]) + '&action=raw&ctype=text/javascript');        }        else {            if (new URL(window.location).searchParams.get("disable-page-css") != null) return;            mw.loader.load('/w/index.php?title=' + encodeURIComponent(el[0]) + '&action=raw&ctype=text/css', 'text/css');        }        new mw.Api.get({ action: 'parse', page: el[0], prop: "" }).done(function (data) { $("#p-namespaces ul").append(' ' + el[1] + ' '); }).fail(function (data) { $("#p-namespaces ul").append(' ' + el[1] + ' '); });   }); });

//Page owner $(".ns-2 #content a, .ns-3 #content a").each(function {    if ($(this).attr("href") == ("/wiki/User:" + mw.config.get("wgRelevantUserName")).replace(/\s/g, "_")) $(this).addClass("page-owner") })