User:Антаркт/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AjaxPatrol/code.js',        'u:dev:MediaWiki:Thread Inspection/code.js',        'u:dev:MediaWiki:PiniginsUserInfo/code.js',         'u:dev:MediaWiki:DiscussionsActivity.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AjaxPatrol/code.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PiniginsUserInfo/code.js',    ] });

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:DiscussionsActivity.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:RecentChangesMultiple/code.2.js',    ] });

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:RecentChangesMultiple/code.2.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MultipleActivity.js',    ] }); importArticles({ type: 'script', articles: [       'u:dev:MediaWiki:DiscussionTemplates.js',    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PortableCSSPad/code.js',    ] }); mw.loader.using("oojs-ui").then(   function  {        var changeThemeButton = new OO.ui.ButtonWidget({ icon: "puzzle", title: "Изменить тему", id: "nkch-theme-button" });

var body = document.body;

changeThemeButton.$element[0].addEventListener("click", function (e) {           var currentTheme, themeToChange;

if (body.classList.contains("theme-fandomdesktop-light")) { currentTheme = "light"; themeToChange = "dark"; } else if (body.classList.contains("theme-fandomdesktop-dark")) { currentTheme = "dark"; themeToChange = "light"; }

body.classList.remove("theme-fandomdesktop-" + currentTheme); body.classList.add("theme-fandomdesktop-" + themeToChange);

$.ajax({               method: "GET",                url: encodeURI(mw.config.get("wgServer") + mw.config.get("wgScriptPath") + "/wikia.php"),                data: {                    controller: "ThemeApi",                    method: "themeVariables",                    variant: themeToChange                }            }).done(                function (data) {                    mw.util.addCSS(data);                }            ); }, false);

document.querySelector(".fandom-community-header__top-container .wiki-tools a").before(changeThemeButton.$element[0]); mw.util.addCSS("#nkch-theme-button .oo-ui-buttonElement-button { color: var(--theme-body-text-color); padding: 5px 6px; }") } ); mw.loader.using("mediawiki.api").then( function { return new mw.Api.loadMessagesIfMissing(["community-header-pages"]); } ).then( function { $.ajax({           url: encodeURI(mw.config.get("wgServer") + mw.config.get("wgScriptPath") + "/api/v1/Articles/Details"),            type: "GET",            data: {                controller: "DesignSystemApi",                method: "getCommunityHeader",                product: "wikis",                id: mw.config.get("wgCityId"),            }        }).done(            function (data) {                var wikiTools = document.querySelectorAll(".wiki-tools");

for (var i = 0; i < wikiTools.length; i++) { var counter = document.createElement("div");

Object.assign(counter.style, {                       display: "flex",                        flexDirection: "column",                        gap: "3px",                        justifyContent: "center",                        textAlign: "right",                        marginRight: "8px"                    });

var counterValue = document.createElement("span"); counterValue.innerHTML = data.counter.value;

Object.assign(counterValue.style, {                       display: "block",                        fontWeight: "bold",                        lineHeight: 1                    });

counter.appendChild(counterValue);

var counterLabel = document.createElement("span"); counterLabel.innerHTML = mw.message(data.counter.label.key).text;

Object.assign(counterLabel.style, {                       display: "block",                        fontSize: "10px",                        fontWeight: "bold",                        lineHeight: 1,                        textTransform: "uppercase"                    });

counter.appendChild(counterLabel);

wikiTools[i].children[0].before(counter); }           }        );    } );