User:Pawchalk/vector.js

/* pawchalk 2021 */

var isDark = true; var styles;

var listItem = document.createElement("li"); listItem.setAttribute("id", "solarizedSwitcher");

var element = document.getElementById("pt-userpage"); element.insertAdjacentElement("afterend", listItem);

//creating the button var button = document.createElement("button"); //assigning the button an id button.setAttribute("id", "buttonSwitch"); //make the button useable button.setAttribute("onclick", "invert");

document.getElementById("solarizedSwitcher").appendChild(button);

//this function will swap from lightmode to darkmode

var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styles = ':root {--base03:   #002b36;--base02:    #073642;--base01:    #586e75;--base00:    #657b83;--base0:     #839496;--base1:     #93a1a1;--base2:     #eee8d5;--base3:     #fdf6e3;--yellow:    #b58900;--orange:    #cb4b16;--red:       #dc322f;--magenta:   #d33682;--violet:    #6c71c4;--blue:      #268bd2;--cyan:      #2aa198; --green:     #859900;}'; document.head.appendChild(styleSheet); styleSheet.innerText = styles;

function invert{

if(isDark == true){

styles = ':root {--base03:   #000000;--base02:    #000000;--base01:    #000000;--base00:    #657b83;--base0:     #839496;--base1:     #93a1a1;--base2:     #eee8d5;--base3:     #fdf6e3;--yellow:    #b58900;--orange:    #cb4b16;--red:       #dc322f;--magenta:   #d33682;--violet:    #6c71c4;--blue:      #268bd2;--cyan:      #2aa198; --green:     #859900;}'; styleSheet.innerText = styles; isDark = false;

}else{ styles = ':root {--base03:   #002b36;--base02:    #073642;--base01:    #586e75;--base00:    #657b83;--base0:     #839496;--base1:     #93a1a1;--base2:     #eee8d5;--base3:     #fdf6e3;--yellow:    #b58900;--orange:    #cb4b16;--red:       #dc322f;--magenta:   #d33682;--violet:    #6c71c4;--blue:      #268bd2;--cyan:      #2aa198; --green:     #859900;}'; styleSheet.innerText = styles;

isDark = true;

}

}