GameFAQs system list recombobulator

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

当前为 2014-05-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GameFAQs system list recombobulator
  3. // @description Takes the console list in the header and remakes it with your own chosen list of consoles.
  4. // @version 1
  5. // @author King of Cats
  6. // @namespace Cats
  7. // @grant none
  8. // @include http://www.gamefaqs.com/*
  9. // ==/UserScript==
  10.  
  11. // Feel free to make changes and redistribute as long as you make it known you're distributing an edited version of this script.
  12.  
  13. var mainNav = document.evaluate('//nav[@class="masthead_systems"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  14.  
  15. if (mainNav !== null) {
  16.  
  17. var moreSystems = document.evaluate('//span[@class="masthead_platform_drop"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  18. var links = mainNav.getElementsByTagName("a");
  19. for (var i = links.length-1; i >= 0; i--) {
  20. if (links[i].parentNode == mainNav) {
  21. links[i].parentNode.removeChild(links[i]);
  22. }
  23. }
  24. /* Default values as an example */
  25. //var newNames = ["3DS","DS","iPhone","PC","PS3","PS4","PSP","Vita","Wii U","Xbox 360","Xbox One"];
  26. //var newLinks = ["3ds","ds","iphone","pc","ps3","ps4","psp","vita","wii-u","xbox360","xboxone"];
  27. /* Custom entries */
  28. var newNames = ["","",""];
  29. var newLinks = ["","",""];
  30. var newAnchors = new Array();
  31. for (var i = 0; i < newNames.length; i++) {
  32. newAnchors[i] = document.createElement('a');
  33. newAnchors[i].setAttribute('href', '/'+newLinks[i]);
  34. newAnchors[i].textContent = newNames[i];
  35. mainNav.insertBefore(newAnchors[i],moreSystems);
  36. }
  37.  
  38. }