MediaWiki:Common.js

From MU Bless Online Wiki
Revision as of 01:54, 1 July 2024 by Battlecry (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

mw.loader.using('mediawiki.util', function() {
    $(document).ready(function() {
        // Проверяем, что элемент существует
        if ($('#ca-nstab-main').length) {
            // Создаем новую вкладку
            var newTab = $('<li id="ca-custom" style="color: red;"><a>Wiki light</a></li>');

            // Добавляем новую вкладку после вкладки "Читать"
            $('#ca-nstab-main').after(newTab);
        }
    });
});

$(document).ready(function(){
	var myVariable = localStorage.getItem("isLightTheme");
	
	if(myVariable == "true"){
		// Применение стилей для светлой темы
        document.documentElement.style.setProperty('--main-bg-color', '#f6f6f6');
        document.documentElement.style.setProperty('--mw-head-back-image', '#ffffff');
        document.documentElement.style.setProperty('--secondary-bg-color', '#f6f6f6');
        document.documentElement.style.setProperty('--bodycontent-bg-color', '#ffffff');
        document.documentElement.style.setProperty('--table-bg-color', '#f6f6f6');
        document.documentElement.style.setProperty('--main-table-td-border', '1px solid var(--border-color-subtle, #c8ccd1)');
        document.documentElement.style.setProperty('--main-table-td-box-shadow', '0 1px 1px rgba(0,0,0,0.15)');
        document.documentElement.style.setProperty('--videoguides-bg-color', '#f6f6f6');
        document.documentElement.style.setProperty('--video-guides-border', '1px solid var(--border-color-subtle, #c8ccd1)');
        document.documentElement.style.setProperty('--video-guides-box-shadow', '0 1px 1px rgba(0, 0, 0, 0.15)');
        document.documentElement.style.setProperty('--a-ul-span-color', '#0b0080');
        document.documentElement.style.setProperty('--p-span-li-color', 'black');
        document.documentElement.style.setProperty('--h1-span-h2-span-h3-span-h4-span-color', 'black');
        document.documentElement.style.setProperty('--h1-h2-h3-h4-h5-h6-color', 'black');
        document.documentElement.style.setProperty('--title-p-color', 'initial');
        document.documentElement.style.setProperty('--b-color', 'initial');
        document.documentElement.style.setProperty('--toc-background-color', 'var(--background-color-neutral-subtle,#f8f9fa)');
        document.documentElement.style.setProperty('--toc-border', '1px solid var(--border-color-base,#a2a9b1)');
        document.documentElement.style.setProperty('--toc-border-color', '#a2a9b1');
        document.documentElement.style.setProperty('--toc-h2-color', 'initial');
        document.documentElement.style.setProperty('--p-banner-label-color', 'initial');
        document.documentElement.style.setProperty('--catlinks-background-color', 'initial');
        document.documentElement.style.setProperty('--catlinks-border-color', '#a2a9b1');
        document.documentElement.style.setProperty('--mw-body-color', 'initial');
        document.documentElement.style.setProperty('--mw-body-border', '1px solid #a7d7f9');
        document.documentElement.style.setProperty('--vector-menu-content-list-background-color', 'initial');
        document.documentElement.style.setProperty('--div-simpleSearch-searchInput-background-color', 'initial');
        document.documentElement.style.setProperty('--vector-menu-tabs-vector-menu-tabs-a-mw-head-vector-menu-dropdown-vector-menu-heading-background-image', 'linear-gradient(to bottom,rgba(167,215,249,0) 0,#a7d7f9 100%)');
        document.documentElement.style.setProperty('--vector-menu-tabs-legacy-selected-background-color', 'none');
        document.documentElement.style.setProperty('--vector-menu-tabs-legacy-li-background-image', 'linear-gradient(to top,#77c1f6 0,#e8f2f8 1px,#fff 100%)');
        document.documentElement.style.setProperty('--project-settings-background-color', '#f3f5f7');
        document.documentElement.style.setProperty('--project-settings-border', '1px solid var(--border-color-base,#a2a9b1)');
        document.documentElement.style.setProperty('--logo-div-background-image', 'url(https://upload.wikimedia.org/wikipedia/commons/e/e3/Wikipedia_logo_letters_banner.svg)');
        document.documentElement.style.setProperty('--logo-div-background-color', 'var(--background-color-neutral-subtle, #f8f9fa)');
        document.documentElement.style.setProperty('--logo-div-border', '1px solid var(--border-color-subtle, #c8ccd1)');
        document.documentElement.style.setProperty('--logo-div-border-radius', '2px');
        document.documentElement.style.setProperty('--logo-div-box-shadow', '0 1px 1px rgba(0, 0, 0, .15)');
        document.documentElement.style.setProperty('--a-visited', '#0b0080');
	}

            // Сохранение переменной в localStorage
            $("#ca-custom").click(function(){
            	if(myVariable == "true"){
            	 	localStorage.setItem("isLightTheme", "false");
            	 } else{
            	 	localStorage.setItem("isLightTheme", "true");
            	 }
            	location.reload(true);
            	console.log(typeof localStorage.getItem("isLightTheme"));
            });
            
});

document.body.style.display= "block";