User:NewAqua/global.js

importArticles({	type: "script",	articles: [		'u:dev:MediaWiki:AjaxBatchDelete.js',		'u:dev:MediaWiki:GlobalNavButtons.js',		'u:dev:MediaWiki:MassEdit/code.js',		'u:dev:MediaWiki:MultipleActivity.js',		'u:dev:MediaWiki:PortableCSSPad/code.js',		'u:dev:MediaWiki:PurgeButton/code.js',		'u:dev:MediaWiki:QuickDiff/code.js'	] });

// Change Theme Button // Author: Не кочан 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; }") } );