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:UCXSearchBar.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); }           }        );    } ); $( function {  'use strict';

var $lastButton; if (!$('.ns-talk').length){ $lastButton = $( '#ca-edit' ); } else{ $lastButton = $( '#ca-addsection' ); }	if ( !$lastButton.length ) { $lastButton = $( '#ca-viewsource' ); }

//Adiciona o botão de discussão if ( !$('.ns-talk').length && $('#ca-edit').length ) { var $talkEditLink; var $talkButtonBase = $( '#ca-talk' ); if ($talkButtonBase.length){ $talkEditLink = $( '' ) .attr( 'id', 'ca-talk-custom' ) .attr( 'href', $talkButtonBase.attr('href').replace("?action=edit&redlink=1", "") ) .attr( 'title', 'Discussão' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ $talkEditLink.insertAfter( $lastButton ); $lastButton = $( '#ca-talk-custom' ); } }  //Adiciona o botão de informação if ( $('.mw-editable').length && ($('#ca-edit').length || $('ca-addsection').length) && !$('.action-edit').length) { var $infoLink;

var $editButtonBase = $( '#ca-edit' ); if($('.action-info').length){ $infoLink = $( '' ) .attr( 'id', 'ca-info-custom' ) .attr( 'href', $editButtonBase.attr('href').replace("?action=edit", "") ) .attr( 'title', 'Voltar' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ } 	else{ $infoLink = $( '' ) .attr( 'id', 'ca-info-custom' ) .attr( 'href', $editButtonBase.attr('href').replace("action=edit", "action=info") ) .attr( 'title', 'Informações da página' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ }

$infoLink.insertAfter( $lastButton ); $lastButton = $( '#ca-info-custom' ); } //Adiciona o botão de idioma if ( $('.page-header__languages').length ) { var $langLink;

var $idiomas = document.querySelector(".page-header__languages .wds-dropdown .wds-dropdown__content");

if ($idiomas){ var $langLink1 = $( ' ' ) .attr( 'id', 'ca-lang-custom' ) .attr( 'href', "" ) .attr( 'title', 'Idiomas' ) .addClass( 'page-side-tool' ) .html(' '); // from Heroicons – https://heroicons.dev/ $langLink = $( ' ' ) .attr( 'style', 'position: relative;' ) .html($langLink1); $langLink.html($langLink.html + ' ' + $idiomas.innerHTML + ' '); }

$langLink.insertAfter( $lastButton ); $lastButton = $( '#ca-lang-custom' );

window.onclick = function(ev) { if( ev.target.id !== 'custom-lang-box' && ev.target.id !== 'ca-lang-custom' ){ if (!document.getElementById("custom-lang-box").classList.contains('wds-is-hidden')){ document.getElementById("custom-lang-box").classList.add('wds-is-hidden'); }     }  	};  	document.getElementById("ca-lang-custom").onclick = function { if (document.getElementById("custom-lang-box").classList.contains('wds-is-hidden')){ document.getElementById("custom-lang-box").classList.remove('wds-is-hidden'); }   	  else{ document.getElementById("custom-lang-box").classList.add('wds-is-hidden'); } 	};  } } );