GameFAQs system list recombobulator

Takes the console list in the header and remakes it with your own chosen list of consoles.

Ekde 2014/06/26. Vidu La ĝisdata versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           GameFAQs system list recombobulator
// @description    Takes the console list in the header and remakes it with your own chosen list of consoles.
// @author         King of Cats
// @namespace      Cats
// @version        2
// @grant          none
// @include        http://www.gamefaqs.com/*
// ==/UserScript==

// Feel free to make changes and redistribute as long as you make it known you're distributing an edited version of this script.

var mainNav = document.evaluate('//nav[@class="masthead_systems"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

if  (mainNav !== null) {

	/* Default values as an example */
	//var newNamesHeader = ["3DS","DS","iPhone","PC","PS3","PS4","PSP","Vita","Wii U","Xbox 360","Xbox One"];
	//var newLinksHeader = ["3ds","ds","iphone","pc","ps3","ps4","psp","vita","wii-u","xbox360","xboxone"];
	//var newNamesDropdown = ["Android","Ouya","Arcade","PlayStation","Dreamcast","PlayStation 2","Game Boy Advance","Saturn","GameCube","Super Nintendo","Genesis","Wii","NES","Xbox","Nintendo 64","And 96 More..."]
	//var newLinksDropdown = ["android","ouya","arcade","ps","dreamcast","ps2","gba","saturn","gamecube","snes","genesis","wii","nes","xbox","n64","systems.html"]
	//var newDropdownTitle = "More Systems"
	
	/* Custom entries */
	var newNamesHeader = ["","",""];
	var newLinksHeader = ["","",""];
	var newNamesDropdown = ["","",""];
	var newLinksDropdown = ["","",""];
	var newDropdownTitle = "";
	
	// false, remove dropdown. true, edit dropdown.
	var keepDropdown = true;

	var newAnchorsHeader = new Array();
	var newAnchorsDropdown = new Array();
	var newListItemsDropdown = new Array();
	var moreSystems = document.evaluate('//span[@class="masthead_platform_drop"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
	
	var headerLinks = mainNav.getElementsByTagName("a");
	for (var i = headerLinks.length-1; i >= 0; i--) {
		if (headerLinks[i].parentNode == mainNav) {
			headerLinks[i].parentNode.removeChild(headerLinks[i]);
		}
	}
	
	for (var i = 0; i < newNamesHeader.length; i++) {
		newAnchorsHeader[i] = document.createElement('a');
		newAnchorsHeader[i].setAttribute('href', '/'+newLinksHeader[i]);
		newAnchorsHeader[i].textContent = newNamesHeader[i];
		mainNav.insertBefore(newAnchorsHeader[i],moreSystems);
	}
	
	if (keepDropdown) {
		var dropdownContainer = moreSystems.getElementsByTagName("ul")[0];
		var dropdownLinks = moreSystems.getElementsByTagName("li");
		
		moreSystems.getElementsByTagName("a")[0].childNodes[0].textContent = newDropdownTitle+" ";
		
		for (var i = dropdownLinks.length-1; i >= 0; i--) {
			dropdownLinks[i].parentNode.removeChild(dropdownLinks[i]);
		}
		
		for (var i = 0; i < newNamesDropdown.length; i++) {
			newListItemsDropdown[i] = document.createElement('li');
			newListItemsDropdown[i].setAttribute('class', 'masthead_platform_subnav_item');
			newAnchorsDropdown[i] = document.createElement('a');
			newAnchorsDropdown[i].setAttribute('href', '/'+newLinksDropdown[i]);
			newAnchorsDropdown[i].textContent = newNamesDropdown[i];
			dropdownContainer.appendChild(newListItemsDropdown[i]);
			newListItemsDropdown[i].appendChild(newAnchorsDropdown[i]);
		}
	} else {
		moreSystems.parentNode.removeChild(moreSystems);
	}

}