Advertisement
Guest User

Untitled

a guest
Sep 11th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Neoquest Attacker v2.1
  3. // @namespace http://userscripts.org/users/useridnumber
  4. // @include http://www.neopets.com/games/neoquest/*
  5. // ==/UserScript==
  6. // Updated by Kauri
  7. // 09/09/2021
  8.  
  9.  
  10. //USER INFO:
  11. //Please adjust the potions which you would like to use, for both OUT OF COMBAT and IN COMBAT.
  12. //Adjust these values as you see fit. % of health at which you heal.
  13. var NonCombatHealPercent = 0.8;
  14. var CombatHealPercent = 0.5;
  15.  
  16.  
  17. var neoquest=document.body.innerHTML.split('NeoQuest is brought to you by')[1];
  18. var healthString = neoquest.split('Health: ')[1].split(" ")[0].replace(/<[\/]{0,1}(b|B)[^><]*>/g,"");
  19. var health = eval(healthString);
  20. var healthLost = parseInt(healthString.split("/")[1]) - parseInt(healthString.split("/")[0])
  21.  
  22.  
  23. function findLinkContainingString(myStr) {
  24. var aTags = document.getElementsByTagName("a");
  25. var searchText = myStr;
  26. var found;
  27.  
  28. for (var i = 0; i < aTags.length; i++) {
  29. if (aTags[i].textContent.search(searchText) != -1) {
  30. console.log("Found tag with textContent: " + aTags[i].textContent);
  31. found = aTags[i];
  32. break;
  33. }
  34. }
  35. return found;
  36. }
  37.  
  38.  
  39. function getHealForPotion(potion) {
  40. var link = findLinkContainingString(potion);
  41. if (link == null) {
  42. return 0;
  43. }
  44. return parseInt(link.textContent.match(/(\d+)/)[0])
  45. }
  46.  
  47. function Items(){
  48. findLinkContainingString("View Items").click();
  49. }
  50.  
  51.  
  52. function NonCombatPotion(){
  53. var weakHeal = neoquest.search('a Weak Healing Potion');
  54. var standardHeal = neoquest.search('a Standard Healing Potion');
  55. var strongHeal = neoquest.search('a Strong Healing Potion');
  56. var greatHeal = neoquest.search('a Great Healing Potion');
  57. var superiorHeal = neoquest.search('a Superior Healing Potion');
  58. var spiritHeal = neoquest.search('a Spirit Healing Potion');
  59.  
  60. //
  61. // For potion use OUT OF COMBAT
  62. // Uses potions from weakest to strongest.
  63. // Add comment in front of "else if" lines if you don't want to use that type of potion.
  64. //
  65.  
  66. if (0>1) { ; } //This is always false; it simply starts the "if, else if" chain. I don't know how to code, so this is probably a terrble way of doing it.
  67. //else if (weakHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220000&do=use'; }
  68. //else if (standardHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220001&do=use'; }
  69. //else if (strongHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220002&do=use'; }
  70. else if (greatHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220003&do=use'; }
  71. else if (superiorHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220004&do=use'; }
  72. //else if (spiritHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220005&do=use'; }
  73. else {breakscript} //Intended to make the script break if you run out of potions to prevent you dying. comment this line if you're at the start of the game.
  74. }
  75.  
  76.  
  77. function findCombatPotion() {
  78. var CombatPotion;
  79. var weakHeal2 = getHealForPotion("Weak Healing Potion");
  80. var standardHeal2 = getHealForPotion("Standard Healing Potion");
  81. var strongHeal2 = getHealForPotion("Strong Healing Potion");
  82. var greatHeal2 = getHealForPotion("Greater Healing Potion");
  83. var superiorHeal2 = getHealForPotion("Superior Healing Potion");
  84. var spiritHeal2 = getHealForPotion("Spirit Healing Potion");
  85.  
  86. //
  87. // For potion use IN COMBAT
  88. // Uses potions from weakest to strongest.
  89. // Add comment in front of "else if" lines if you don't want to use that type of potion.
  90. //
  91. if (CombatPotion == null) {
  92. if (0>1) { ; } //This is always false; it simply starts the "if, else if" chain. I don't know how to code, so this is probably a terrble way of doing it.
  93. //else if (weakHeal2 > 0) { CombatPotion = findLinkContainingString("Weak Healing Potion"); }
  94. //else if (standardHeal2 > 0) { CombatPotion = findLinkContainingString("Standard Healing Potion"); }
  95. //else if (strongHeal2 > 0) { CombatPotion = findLinkContainingString("Strong Healing Potion"); }
  96. else if (greatHeal2 > 0) { CombatPotion = findLinkContainingString("Greater Healing Potion"); }
  97. else if (superiorHeal2 > 0) { CombatPotion = findLinkContainingString("Superior Healing Potion"); }
  98. //else if (spiritHeal2 > 0) { CombatPotion = findLinkContainingString("Spirit Healing Potion"); }
  99. else { breakscript } //Intended to make the script break if you run out of potions to prevent you dying. comment this line if you're at the start of the game.
  100. }
  101. return CombatPotion;
  102. }
  103.  
  104. if(neoquest.search('to see what you found')!=-1){
  105. location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
  106. }
  107.  
  108. if(neoquest.search('navarrows.gif')!=-1){
  109. if(health<( NonCombatHealPercent )){
  110. Items();
  111. }else {location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=move&movedir=';}
  112. }
  113.  
  114. //
  115. // Heal out of combat
  116. //
  117. for(i=0;i<document.forms.length;i++){
  118. if(document.forms[i].elements[0].value=="Click here to return to the map"){
  119. if(neoquest.search('Your Items')!=-1){
  120. if(health<( NonCombatHealPercent )){
  121. NonCombatPotion();
  122. }else {location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=move&movedir=';}
  123. }
  124.  
  125. else document.forms[i].submit();
  126. }
  127. }
  128.  
  129.  
  130.  
  131. if(neoquest.search('to begin the fight')!=-1){
  132. location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
  133. }
  134.  
  135.  
  136. //
  137. // Heal in combat
  138. //
  139. if(health<( CombatHealPercent)&&((neoquest.search('Spirit of Growth')!=-1)||(neoquest.search('Healing Potion')!=-1))){
  140. if(neoquest.search('Spirit of Growth')!=-1){
  141. findLinkContainingString("Spirit of Growth").click();
  142.  
  143. }else if(neoquest.search('Healing Potion')!=-1){
  144. findCombatPotion().click();
  145. }
  146.  
  147. //
  148. // Otherwise use absorption
  149. // Commenting these two lines out if you don't want to use absorption
  150. //
  151. } else if(neoquest.search('Cast Absorption')!=-1){
  152. findLinkContainingString("Cast Absorption").click()
  153.  
  154. //
  155. // Otherwise Attack
  156. //
  157. } else if(neoquest.search('Attack')!=-1){
  158. findLinkContainingString("Attack").click();
  159.  
  160. } else if(neoquest.search('Do nothing')!=-1){
  161. findLinkContainingString("Do nothing").click();
  162. }
  163.  
  164.  
  165.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement