User:Blupo/wikia.js

// credit goes to andrewds1021 (function {    "use strict";    //if (typeof window.categoryCSSActive !== undefined) return;    window.categoryCSSActive = true;    window.categoryCSS = {        // test        "Market": "MediaWiki:Market.css",        "Shop Item": "MediaWiki:Shop_Item.css",        "Virhst Woodlands": "MediaWiki:Virhst_Woodlands.css",        "Redveil Grove": "MediaWiki:Redveil_Grove.css",        "Avalanche Expanse": "MediaWiki:Avalanche_Expanse.css",        "Hidden Wilds": "MediaWiki:Hidden_Wilds.css",        "Desolate Dunes": "MediaWiki:Desolate_Dunes.css",        "Entoloma Gloomlands": "MediaWiki:Entoloma_Gloomlands.css",        "Blooming Plateau": "MediaWiki:Blooming_Plateau.css",        "Va' Rok": "MediaWiki:Va'_Rok.css"    };    var list = window.categoryCSS;    var list_keys = Object.keys(list); // get categories    if (list_keys.length <= 0) return;    // generate API request    console.log("CategoryCSS.js: Attempting to generate API request"); var wgArticleId = mw.config.get("wgArticleId"); var request = { action: "query", pageids: wgArticleId, prop: "categories", clprop: "hidden" };   // send API request, check results, and import CSS console.log("CategoryCSS.js: Waiting for \"mediawiki.api\""); mw.loader.using("mediawiki.api").then(function {        console.log("CategoryCSS.js: \"mediawiki.api\" has been loaded. Attempting to send API request");        return new mw.Api.get(request);    }).then(function (reply) {        console.log("CategoryCSS.js: An API reply has been received. Attempting to extract data");        var page = reply.query.pages[wgArticleId];        var categories = [];        var importCSS = [];        if (page.categories) {            page.categories.map(function(category) { categories.push(category.title); });       } else {            console.log("CategoryCSS.js: Cound not load categories, or none exist");            return;        }        for (var index in categories) {            var key = categories[index];            key = key.substring(key.indexOf(":") + 1);            var value = list[key] ? list[key] : list[key.replace(/\s/g, "_")];            if (!value) {                console.log("CategoryCSS.js: No match found for category " + key + ".");            } else {                importCSS.push(value);                console.log("CategoryCSS.js: Match found for category " + key + ".");            }        }        if (importCSS.length > 0) {            console.log("CategoryCSS.js: Importing CSS for categories: " + categories.toString);            importArticles({ type: "style", articles: importCSS });       } else {            console.log("CategoryCSS.js: No CSS to import");            return;        }    }); }); /* var wordmarks = [   "https://vignette.wikia.nocookie.net/swordburst2/images/8/89/Wiki-wordmark.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/a/ab/Wiki-wordmark-arcadia1.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/0/00/Wiki-wordmark-arcadia2.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/3/3b/Wiki-wordmark-pvp1.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/1/1f/Wiki-wordmark-pvp2.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/5/59/Wiki-wordmark-pvp3.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/d/db/Wiki-wordmark-virhst1.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/1/1d/Wiki-wordmark-virhst2.png/revision/latest",    "https://vignette.wikia.nocookie.net/swordburst2/images/a/ad/Wiki-wordmark-virhst3.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/0/08/Wiki-wordmark-virhst4.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/5/58/Wiki-wordmark-virhst5.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/9/9e/Wiki-wordmark-virhst6.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/0/0f/Wiki-wordmark-redveil1.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/b/ba/Wiki-wordmark-redveil2.png/revision/latest", "https://vignette.wikia.nocookie.net/swordburst2/images/a/a6/Wiki-wordmark-redveil3.png/revision/latest", ];

$(".wds-community-header__wordmark img").attr("src", wordmarks[Math.floor(Math.random * wordmarks.length)]);

// boop (function {    "use strict";    var config = mw.config.get([ "wgCanonicalSpecialPageName" ]);   if (config.wgCanonicalSpecialPageName != "Recentchanges") { return }    var container = " Abuse Log ";    $('#mw-content-text').before(container); });