MediaWiki:Gadget-GameHighlight.js

// Highlighting for tabs on game pages var selfLink = document.getElementsByClassName("mw-selflink"); if (selfLink.length > 2) { if (selfLink[1].firstChild.nodeName=='SPAN') { selfLink[1].firstChild.classList.add(selfLink[1].firstChild.classList[2].replace('2', '')); selfLink[1].firstChild.classList.remove(selfLink[1].firstChild.classList[2]); } }

var gameTab = document.getElementsByClassName('mcbutton'); var headers = document.getElementsByClassName('mw-headline');

function compareText(item1, item2) { if (item1 == item2) { return true; } }

function highlightTab(item) { item.classList.add(item.classList[2].replace('2', '')); item.classList.remove(item.classList[2]); }

$(document).ready(function{ for (var i = 0; i < headers.length; i++) {	if (typeof headers[i].firstChild.text !== 'undefined') {	for (var j = 0; j < gameTab.length; j++) {		if (compareText(headers[i].firstChild.text, gameTab[j].textContent)) {			highlightTab(gameTab[j]);		}	}	} } });