Neopets - Side Account Protector

Stops you from going any farther on non-side-account pages.

  1. // ==UserScript==
  2. // @name Neopets - Side Account Protector
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.11
  5. // @description Stops you from going any farther on non-side-account pages.
  6. // @author baffleblend
  7. // @include http://www.neopets.com/games/*
  8. // @include http://www.neopets.com/winter/adventcalendar.phtml
  9. // @include http://www.neopets.com/objects.phtml?type=shop&obj_type=*
  10. // @include http://www.neopets.com/objects.phtml?obj_type=*&type=shop
  11. // @include http://www.neopets.com/pirates/anchormanagement.phtml
  12. // @include http://www.neopets.com/halloween/applebobbing.phtml
  13. // @include http://www.neopets.com/bank.phtml
  14. // @include http://www.neopets.com/art/submit_art.phtml
  15. // @include http://www.neopets.com/desert/shrine.phtml
  16. // @include http://www.neopets.com/magma/darkcave.phtml
  17. // @include http://www.neopets.com/beauty/vote.phtml
  18. // @include http://www.neopets.com/beauty/details.phtml?pet=*
  19. // @include http://www.neopets.com/worlds/geraptiku/tomb.phtml
  20. // @include http://www.neopets.com/games/crossword/*
  21. // @include http://www.neopets.com/pirates/forgottenshore.phtml
  22. // @include http://www.neopets.com/desert/fruitmachine.phtml
  23. // @include http://www.neopets.com/jelly/jelly.phtml
  24. // @include http://www.neopets.com/prehistoric/omelette.phtml
  25. // @include http://www.neopets.com/halloween/gravedanger/
  26. // @include http://www.neopets.com/medieval/grumpyking.phtml
  27. // @include http://www.neopets.com/faerieland/springs.phtml?*
  28. // @include http://www.neopets.com/worlds/kiko/kpop/
  29. // @include http://www.neopets.com/shenkuu/lunar/
  30. // @include http://www.neopets.com/moon/meteor.phtml
  31. // @include http://www.neopets.com/magma/quarry.phtml
  32. // @include http://www.neopets.com/takedonation_new.phtml?*
  33. // @include http://www.neopets.com/freebies/
  34. // @include http://ncmall.neopets.com/mall/shop.phtml?page=giveaway
  35. // @include http://www.neopets.com/medieval/rubbishdump.phtml
  36. // @include http://www.neopets.com/thriftshoppe/index.phtml
  37. // @include http://www.neopets.com/medieval/symolhole.phtml
  38. // @include http://www.neopets.com/freebies/tarlastoolbar.phtml
  39. // @include http://www.neopets.com/faerieland/tdmbgpop.phtml
  40. // @include http://www.neopets.com/trudys_surprise.phtml
  41. // @include http://www.neopets.com/island/tombola.phtml
  42. // @include http://www.neopets.com/medieval/wiseking.phtml
  43. // @include http://www.neopets.com/water/fishing.phtml
  44. // @include http://www.neopets.com/dome/*
  45. // @include http://www.neopets.com/battledome/*
  46. // @include http://www.neopets.com/desert/sc/*
  47. // @include http://www.neopets.com/halloween/scratch.phtml
  48. // @include http://www.neopets.com/winter/kiosk.phtml
  49. // @include http://www.neopets.com/altador/colosseum/
  50. // @include http://www.neopets.com/faerieland/wheel.phtml
  51. // @include http://www.neopets.com/desert/extravagance.phtml
  52. // @include http://www.neopets.com/medieval/knowledge.phtml
  53. // @include http://www.neopets.com/prehistoric/mediocrity.phtml
  54. // @include http://www.neopets.com/halloween/wheel/*
  55. // @include http://www.neopets.com/prehistoric/monotony/*
  56. // @include http://www.neopets.com/market.phtml?*
  57. // @include http://www.neopets.com/wishing.phtml
  58. // @include http://www.neopets.com/prehistoric/battleground/
  59. // @include http://www.neopets.com/medieval/turmaculus.phtml
  60. // @include http://www.neopets.com/winter/snowager.phtml
  61. // @include http://www.neopets.com/games/kadoatery/index.phtml?
  62. // @include http://www.neopets.com/faerieland/hiddentower938.phtml
  63. // @include http://www.neopets.com/medieval/guessmarrow.phtml
  64. // @include http://www.neopets.com/medieval/earthfaerie.phtml
  65. // @include http://www.neopets.com/faerieland/darkfaerie.phtml
  66. // @include http://www.neopets.com/island/kitchen.phtml
  67. // @include http://www.neopets.com/winter/snowfaerie.phtml
  68. // @include http://www.neopets.com/space/coincidence.phtml
  69. // @include http://www.neopets.com/prehistoric/ticketbooth.phtml
  70. // @include http://www.neopets.com/medieval/turdleracing.phtml
  71. // @include http://www.neopets.com/halloween/strtest/*
  72. // @include http://www.neopets.com/winter/shopofmystery.phtml
  73. // @include http://www.neopets.com/stockmarket.phtml*
  74. // @include http://www.neopets.com/faerieland/poogleracing.phtml
  75. // @include http://www.neopets.com/medieval/pickyourown_index.phtml
  76. // @include http://www.neopets.com/winter/igloo.phtml
  77. // @include http://www.neopets.com/pirates/foodclub.phtml*
  78. // @include http://www.neopets.com/faerieland/caverns/*
  79. // @include http://www.neopets.com/faerieland/employ/*
  80. // @include http://www.neopets.com/halloween/corkgun.phtml
  81. // @include http://www.neopets.com/halloween/coconutshy.phtml
  82. // @include http://www.neopets.com/medieval/cheeseroller.phtml
  83. // @include http://www.neopets.com/pirates/buriedtreasure/*
  84. // @include http://www.neopets.com/halloween/bagatelle.phtml
  85. // @include http://www.neopets.com/space/warehouse/*
  86. // @include http://www.neopets.com/refer/*
  87. // @include http://www.neopets.com/altador/council.phtml
  88. // @include http://www.neopets.com/halloween/braintree.phtml
  89. // @include http://www.neopets.com/halloween/esophagor.phtml
  90. // @include http://www.neopets.com/shenkuu/neggcave/
  91. // @grant none
  92. // ==/UserScript==
  93.  
  94. (function() {
  95. 'use strict';
  96. function id(el,id) {return el.getElementById(id);}
  97. function cl(el,cls) {return el.getElementsByClassName(cls);}
  98. function tg(el,tag) {return el.getElementsByTagName(tag);}
  99. function at(el,att) {return el.getAttribute(att);}
  100. function rnd(limit) {return Math.ceil(Math.random() * limit)}
  101. function hide(el){el.style.display="none";}
  102. function randomPick(list){var theValue = rnd(list.length)-1;var selection = theValue; return list[selection];}
  103.  
  104. //=====CONFIGURATION==========================================================
  105.  
  106. var mainacc = ""; //Put your main account's username here so the script knows when it's safe.
  107.  
  108. function doIt(){
  109.  
  110. var phrases = [ // What exactly is your pet going to yell at you?
  111. "If you want to go here, log out! Now!",
  112. "I won't let you put my life on the line for a quick neopoint!",
  113. "Just back away slowly, and nobody gets hurt.",
  114. "You forgot you were on this account, didn't you?",
  115. "This is for your own good, " + mainacc +"."
  116. ];
  117.  
  118.  
  119. //What's the name of the pet you want to show up if on a page where your active pet can't be detected?
  120. var defaultPet = "PETNAMEHERE";
  121.  
  122.  
  123. //========================================
  124. //Code below here.
  125.  
  126. var activePetModule = cl(document,"sidebarTable")[0]; //Grabs the module where the active pet's information is stored
  127. var actpetname = null;
  128. var pageContent = cl(document,"content")[0];
  129. if (activePetModule !== undefined&& activePetModule !== null){
  130. actpetname = tg(activePetModule,"b")[0].textContent; //Detects current active pet's name
  131. pageContent = cl(document,"content")[0];
  132. }
  133.  
  134.  
  135. var currentURL = window.location.href; //Reads the URL of the current page.
  136. var chosenPhrase = randomPick(phrases);
  137. var message = "This page is not allowed when logged into a side account! If you gained an item or neopoints from visiting this page,<br>go to <a href='http://www.neopets.com/inventory.phtml'>your inventory</a> or <a href='http://www.neopets.com/donations.phtml?'>the Money Tree</a> and dispose of it IMMEDIATELY."
  138. var redtext = "STOP!!!";
  139. var panicURLs = ["http://www.neopets.com/faerieland/springs.phtml?bought=true","http://www.neopets.com/magma/quarry.phtml","http://www.neopets.com/freebies/","http://www.neopets.com/shop_of_offers.phtml?slorg_payout=yes","http://www.neopets.com/freebies/tarlastoolbar.phtml"]
  140. var panicNow = false;
  141. var imageNumber = "3";
  142.  
  143. for (var i = 0;i<panicURLs.length;i++){ //Checks if you're on a page that automatically rewards something.
  144. if (currentURL == panicURLs[i]){
  145. panicNow = true;
  146. }
  147. }
  148.  
  149. if (panicNow === true)
  150. {
  151. redtext = "OH NO!!!";
  152. chosenPhrase = "Get rid of that! HURRY! Please, I don't want to die...";
  153. message = "You've gotten illegal items and/or neopoints! Go to <a href='http://www.neopets.com/quickstock.phtml'>your inventory</a> or <a href='http://www.neopets.com/donations.phtml?'>the Money Tree</a><br>and discard or donate anything you've gained RIGHT NOW!"
  154. imageNumber = "2";
  155. }
  156.  
  157.  
  158. if (actpetname !== undefined && actpetname !== null){
  159. defaultPet = actpetname; //Makes your active pet the one yelling at you, if there is one on that page.
  160. }
  161. pageContent.innerHTML = "<center><img src='http://pets.neopets.com/cpn/" + defaultPet +"/" + imageNumber + "/4.png'><br><h1 style='font-size:4em;color:#ff0000;margin-left:20%;margin-right:20%;'>" + redtext +"</h1><p style='font-weight:bold;'>" + defaultPet +" says, \'" + chosenPhrase +"\'</p><p>" + message + "</p><p>If this is your main account, please go to your userscript manager and configure this script.</p></center>";
  162. }
  163. var userHeader = cl(document,"user medText")[0];
  164. var loggedinto = tg(userHeader,"a")[0].textContent; //Grabs current username
  165. if (loggedinto != mainacc){ //Is the current username the same as your main account name?
  166. doIt();
  167. }
  168. })()