User:StupendousStupdiity/common.js

function pageCheck(pagename){ var ClassName = document.querySelector(".page-" + pagename); var ReturnedBool = false; if (ClassName){ ReturnedBool = true; }   return ReturnedBool; }

function GraveyardSeaColorCycle { var Infobox = document.querySelector(".portable-infobox"); var functionalClasses = "portable-infobox pi-background pi-border-color pi-theme-wikia pi-layout-default "; var ElementalArray = ["Fire","Air","Earth","Water"]; var ElementIndex = (ElementalArray.indexOf(Infobox.className.substring(80))); if (ElementIndex != 3){ Infobox.className = functionalClasses + ElementalArray[ElementIndex+1]; }   else if (ElementIndex == 3){ Infobox.className = functionalClasses + ElementalArray[0]; } }

function GraveyardSeaToggleCycle { var ButtonSelf = document.getElementById("GraveyardSeaToggleCycle"); if (ButtonSelf.checked == true) { if (!GraveyardSeaCycleInterval){ GraveyardSeaCycleInterval = setInterval(GraveyardSeaColorCycle,1000); }   } else { clearInterval(GraveyardSeaCycleInterval); var Infobox = document.querySelector(".portable-infobox"); Infobox.className = "portable-infobox pi-background pi-border-color pi-theme-wikia pi-layout-default "; GraveyardSeaCycleInterval = null; } }

var GraveyardSeaCycleInterval;

$(function {   console.log("Ran.");    console.log(pageCheck("Graveyard_Sea"));    if (pageCheck("Graveyard_Sea") == true){        var ContainerDiv = document.createElement('div');        var InfoboxTitle = document.querySelector(".pi-title");        var InfoboxColorCycleToggle = document.createElement('input');        ContainerDiv.style.fontSize = "11px";        ContainerDiv.innerHTML = "Enable color cycling";        InfoboxColorCycleToggle.type = "checkbox";        InfoboxColorCycleToggle.id = "GraveyardSeaToggleCycle";        InfoboxColorCycleToggle.setAttribute("onClick","GraveyardSeaToggleCycle");        ContainerDiv.insertBefore(InfoboxColorCycleToggle,ContainerDiv.lastChild);        InfoboxTitle.appendChild(ContainerDiv, InfoboxTitle.firstChild);    } });