User:Przemub/vector.dark.js

jQuery(document).ready(function{   Msz2001_darkskin_init; });

function Msz2001_darkskin_init{ var is_dark_skin = !Msz2001_darkskin_isSetOff;

/* Wyłącz tryb ciemny, jeśli użytkownik go nie chce */ if(!is_dark_skin) Msz2001_darkskin_toggleOff; else Msz2001_darkskin_toggleOn;

/* Dodaj linki do przełączania trybu */ var elToggleOff = document.createElement("li"); elToggleOff.id = "Msz2001-darkskin-toggleofflink"; elToggleOff.innerHTML = "Tryb jasny"; if(!is_dark_skin) elToggleOff.style.display = "none";

var elToggleOn = document.createElement("li"); elToggleOn.id = "Msz2001-darkskin-toggleonlink"; elToggleOn.innerHTML = "Tryb ciemny"; if(is_dark_skin) elToggleOn.style.display = "none";

var elFaqLink = document.getElementById("n-FAQ");

if(elFaqLink){ elFaqLink.parentNode.insertBefore(elToggleOff, elFaqLink.nextSibling); elFaqLink.parentNode.insertBefore(elToggleOn, elFaqLink.nextSibling); }else{ setTimeout(function{           var elAboutWikipediaLink = document.querySelector("#mw-mf-page-left ul.hlist li:first-child");            var elNavLeft = document.querySelector("#mw-panel .vector-menu-content-list");            if(elAboutWikipediaLink){                elAboutWikipediaLink.parentNode.insertBefore(elToggleOff, elAboutWikipediaLink);                elAboutWikipediaLink.parentNode.insertBefore(elToggleOn, elAboutWikipediaLink);            }else{                elNavLeft.appendChild(elToggleOff);                elNavLeft.appendChild(elToggleOn);            }        }, 3000); } }

function Msz2001_darkskin_toggleOn{ if($("html").hasClass("disable-dark-skin")){ $("html").removeClass("disable-dark-skin"); $("html").addClass("enable-dark-skin"); }   var metaThemeColor = document.querySelector("meta[name=theme-color]"); if(metaThemeColor) metaThemeColor.setAttribute("content", "#222");

var toggle_off_link = document.querySelector("#Msz2001-darkskin-toggleofflink"); var toggle_on_link = document.querySelector("#Msz2001-darkskin-toggleonlink"); if(toggle_off_link) toggle_off_link.style.display = "inherit"; if(toggle_on_link) toggle_on_link.style.display = "none";

document.cookie = "disable_darkskin_Msz2001=0; path=/"; $.ajax("https://tools.wmflabs.org/vector-dark/setcookie.php?is_on=true", {xhrFields: {     withCredentials: true   }}); }

function Msz2001_darkskin_toggleOff{ if(!$("html").hasClass("disable-dark-skin")){ $("html").addClass("disable-dark-skin"); $("html").removeClass("enable-dark-skin"); }   var metaThemeColor = document.querySelector("meta[name=theme-color]"); if(metaThemeColor) metaThemeColor.setAttribute("content", "#eaecf0");

var toggle_off_link = document.querySelector("#Msz2001-darkskin-toggleofflink"); var toggle_on_link = document.querySelector("#Msz2001-darkskin-toggleonlink"); if(toggle_off_link) toggle_off_link.style.display = "none"; if(toggle_on_link) toggle_on_link.style.display = "inherit";

document.cookie = "disable_darkskin_Msz2001=1; path=/"; $.ajax("https://tools.wmflabs.org/vector-dark/setcookie.php?is_on=false", {xhrFields: {     withCredentials: true   }}); }

function Msz2001_darkskin_isSetOff{ return (document.cookie.indexOf("disable_darkskin_Msz2001=1") >= 0); }