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; }") } );