GameFAQs system list recombobulator

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

目前為 2014-05-15 提交的版本,檢視 最新版本

// ==UserScript==
// @name           GameFAQs system list recombobulator
// @description    Takes the console list in the header and remakes it with your own chosen list of consoles.
// @version        1
// @author         King of Cats
// @namespace      Cats
// @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) {

	var moreSystems = document.evaluate('//span[@class="masthead_platform_drop"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
	
	var links = mainNav.getElementsByTagName("a");
	for (var i = links.length-1; i >= 0; i--) {
		if (links[i].parentNode == mainNav) {
			links[i].parentNode.removeChild(links[i]);
		}
	}
	
	/* Default values as an example */
	//var newNames = ["3DS","DS","iPhone","PC","PS3","PS4","PSP","Vita","Wii U","Xbox 360","Xbox One"];
	//var newLinks = ["3ds","ds","iphone","pc","ps3","ps4","psp","vita","wii-u","xbox360","xboxone"];
	
	/* Custom entries */
	var newNames = ["","",""];
	var newLinks = ["","",""];
	
	var newAnchors = new Array();
	
	for (var i = 0; i < newNames.length; i++) {
		newAnchors[i] = document.createElement('a');
		newAnchors[i].setAttribute('href', '/'+newLinks[i]);
		newAnchors[i].textContent = newNames[i];
		mainNav.insertBefore(newAnchors[i],moreSystems);
	}

}