User:DBD Abyss/global.js

(function fixGlobalNav {   var localNav = document.querySelector('.WikiHeader .navbackground'),        navStyle = window.getComputedStyle(localNav),        bgColor = navStyle.getPropertyValue('background-color'),        textColor = navStyle.getPropertyValue('color'),        borderElements = document.querySelectorAll('.global-navigation .page-width, .global-navigation-item'),        globalNav = document.querySelector('.global-navigation'),        bgParse = bgColor.match(/(\d+), (\d+), (\d+)/).splice(1),        gt127 = 0,        arrowColor,        arwStyle = document.createElement('style'),        thisWiki = document.querySelector('.search-select').children[0],        startWiki = document.querySelector('.global-navigation-link.start-wikia'),        thisWikiLabel = document.querySelector('#searchLabelInline');    // change chevron colour based on the background colour we're going to use for the nav for (var i = 0; i < 3; i++) parseInt(bgParse[i]) > 127 && gt127++; if (gt127 < 2) arrowColor = 'white'; else arrowColor = 'black'; // it's impossible to use the Selectors API with psuedo-elements (wtf mozilla) - this is the next best thing arwStyle.innerHTML = '.hubs-entry-point:after, #searchFormChevron, .AccountNavigation > li > a:after { border: 5px solid transparent; border-top-color: ' + arrowColor + '; }'; arwStyle.innerHTML += '\n.search-label-bold { color: ' + arrowColor + ' !important; }'; document.head.appendChild(arwStyle); // kill borders because they look kinda horrible for (var i = 0; i < borderElements.length; i++) { borderElements[i].style.border = 'none'; } // change nav bg   globalNav.style.backgroundColor = bgColor; globalNav.style.color = textColor; });