Neopets - Random Shops Button

Makes the "Shops" button on the Neopets nav bar link to a random shop instead of Neopia Central.

  1. // ==UserScript==
  2. // @name Neopets - Random Shops Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Makes the "Shops" button on the Neopets nav bar link to a random shop instead of Neopia Central.
  6. // @author Baffle Blend
  7. // @match http://www.neopets.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function shopShuffle() {
  15. //Shop IDs that have either never been used or have been removed from the site
  16. var badIDs = [6,11,19,28,29,32,33,52,64,65,99,109,115];
  17. do{
  18. var shopID = Math.ceil(Math.random() * 117);
  19. var checkID = badIDs.indexOf(shopID);
  20. //If the random number is one of the bad IDs, try again
  21. }while(checkID!==-1);
  22. return shopID;
  23. };
  24.  
  25. //Grabs the "Shops" button
  26. var navbar = document.getElementById("template_nav");
  27. var navbutton = navbar.getElementsByClassName("nav_image");
  28. var shopbutton = navbutton[6].firstChild;
  29.  
  30.  
  31. //Assigns the randomized shop link to the button
  32. var fullurl = "http://www.neopets.com/objects.phtml?type=shop&obj_type=" + shopShuffle();
  33. shopbutton.href = fullurl;
  34. }
  35.  
  36.  
  37.  
  38. )();