User:Energy X/common.js

importScriptPage('MultiUpload/code.js', 'dev');

nullEditDelay = 1000; importScriptPage('MediaWiki:MassNullEdit/code.js', 'dev');

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:ListFiles/code.js',        'u:dev:MediaWiki:AjaxBatchDelete.js',    ] }); // Function to check if element exists in page function check_element_exists(elem) { return document.body.contains(document.querySelector(elem)); } // Function to get the Pokémon type from class and return the color function poke_type(element_class){ var color = "black"; switch(element_class) { case "Bug": color = "#CEDE48"; break; case "Dark": color = "#A2958D"; break; case "Dragon": color = "#9F77FF"; break; case "Electric": color = "#F9DA5F"; break; case "Fairy": color = "#FEA3E8"; break; case "Fighting": color = "#E5524A"; break; case "Flying": color = "#CEBFFB"; break; case "Fire": color = "#F08030"; break; case "Ghost": color = "#A18DC4"; break; case "Grass": color = "#77DD77"; break; case "Ground": color = "#67ED9A"; break; case "Ice": color = "#BCE6E6"; break; case "Normal": color = "#C6C6A7"; break; case "Poison": color = "#D878D8"; break; case "Psychic": color = "#F99CB8"; break; case "Rock": color = "#D1C17D"; break; case "Steel": color = "#D1D1E0"; break; case "Water": color = "#9BB8FE"; break; case "???": color = "#9DC1B7"; break; }   return color; }

/* Movebox template */ var movebox_str = ".movebox";

if(check_element_exists(movebox_str) !== false){ // Get class for color var movebox = document.querySelector(movebox_str); var movebox_prim_color = poke_type(movebox.className.split(" ")[0]); var movebox_sec_color = poke_type(movebox.className.split(" ")[1]);

// If no secondary type if(movebox_sec_color.match("black")) movebox_sec_color = movebox_prim_color;

// Apply colors to borders and background movebox.style.borderColor = movebox_prim_color;

var movebox_slideshow_str = movebox_str + " .wikia-slideshow"; if(check_element_exists(movebox_slideshow_str) !== false){ var movebox_sliders = Array.from(document.querySelectorAll(movebox_slideshow_str)); var movebox_tabber = Array.from(document.querySelectorAll(movebox_str + " .tabbertab"));

for(var i = 0; i < movebox_sliders.length; i++){ movebox_sliders[i].style.background = "linear-gradient(" + movebox_prim_color + "," + movebox_sec_color + ")"; movebox_sliders[i].style.borderColor = movebox_prim_color;

if(check_element_exists(movebox_str + ".tabbertab") !== false) movebox_tabber[i].style.borderColor = movebox_sec_color; }   }

var movebox_table_header = Array.from(document.querySelectorAll(movebox_str + " table th")); for(var i = 0; i < movebox_table_header.length; i++) movebox_table_header[i].style.background = movebox_sec_color;

var movebox_cell = Array.from(document.querySelectorAll(movebox_str + " table td")); for(var i = 0; i < movebox_cell.length; i++) movebox_cell[i].style.borderColor = movebox_prim_color;

document.querySelector(movebox_str + " table").style.borderColor = movebox_prim_color;

var movebox_tabbernav_str = movebox_str + " .tabbernav"; if(check_element_exists(movebox_tabbernav_str) !== false) document.querySelector(movebox_tabbernav_str).style.borderColor = movebox_prim_color; }

/* Evolution */ /* var evolution_str = ".evolution > center";

if(check_element_exists(evolution_str) !== false){ var evolution_gallery = Array.from(document.querySelectorAll(evolution_str));

// Replace arrows for(var i = 0; i < evolution_gallery.length; i++) evolution_gallery[i].innerHTML = "→"; }*/

/* Sprite gallery */ /* var sprite_gallery_str = ".sprite-gallery";

if(check_element_exists(sprite_gallery_str) !== false){ // Get types var sprite_gallery = document.querySelector(sprite_gallery_str);

var sprite_gallery_tabber = Array.from(document.querySelectorAll(sprite_gallery_str + " .tabbernav a")); var sprite_gallery_border = Array.from(document.querySelectorAll(sprite_gallery_str + " .tabbertab")); var sprite_gallery_prim_color = poke_type_primary(sprite_gallery.className.split(" ")[0]); var sprite_gallery_sec_color = poke_type_primary(sprite_gallery.className.split(" ")[1]);

// If no secondary type if(sprite_gallery_sec_color.match("black")){ sprite_gallery_sec_color = sprite_gallery_prim_color; //document.querySelector(sprite_gallery_str + " .tabbernav").style.borderBottom = "1px solid " + sprite_gallery_prim_color; }   for(var i = 0; i < sprite_gallery_tabber.length; i++){ sprite_gallery_tabber[i].style.background = sprite_gallery_prim_color; sprite_gallery_tabber[i].style.borderColor = sprite_gallery_sec_color; sprite_gallery_border[i].style.borderColor = sprite_gallery_sec_color; } }*/