Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Neoquest Attacker v2.1
- // @namespace http://userscripts.org/users/useridnumber
- // @include http://www.neopets.com/games/neoquest/*
- // ==/UserScript==
- // Updated by Kauri
- // 09/09/2021
- //USER INFO:
- //Please adjust the potions which you would like to use, for both OUT OF COMBAT and IN COMBAT.
- //Adjust these values as you see fit. % of health at which you heal.
- var NonCombatHealPercent = 0.8;
- var CombatHealPercent = 0.5;
- var neoquest=document.body.innerHTML.split('NeoQuest is brought to you by')[1];
- var healthString = neoquest.split('Health: ')[1].split(" ")[0].replace(/<[\/]{0,1}(b|B)[^><]*>/g,"");
- var health = eval(healthString);
- var healthLost = parseInt(healthString.split("/")[1]) - parseInt(healthString.split("/")[0])
- function findLinkContainingString(myStr) {
- var aTags = document.getElementsByTagName("a");
- var searchText = myStr;
- var found;
- for (var i = 0; i < aTags.length; i++) {
- if (aTags[i].textContent.search(searchText) != -1) {
- console.log("Found tag with textContent: " + aTags[i].textContent);
- found = aTags[i];
- break;
- }
- }
- return found;
- }
- function getHealForPotion(potion) {
- var link = findLinkContainingString(potion);
- if (link == null) {
- return 0;
- }
- return parseInt(link.textContent.match(/(\d+)/)[0])
- }
- function Items(){
- findLinkContainingString("View Items").click();
- }
- function NonCombatPotion(){
- var weakHeal = neoquest.search('a Weak Healing Potion');
- var standardHeal = neoquest.search('a Standard Healing Potion');
- var strongHeal = neoquest.search('a Strong Healing Potion');
- var greatHeal = neoquest.search('a Great Healing Potion');
- var superiorHeal = neoquest.search('a Superior Healing Potion');
- var spiritHeal = neoquest.search('a Spirit Healing Potion');
- //
- // For potion use OUT OF COMBAT
- // Uses potions from weakest to strongest.
- // Add comment in front of "else if" lines if you don't want to use that type of potion.
- //
- 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.
- //else if (weakHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220000&do=use'; }
- //else if (standardHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220001&do=use'; }
- //else if (strongHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220002&do=use'; }
- else if (greatHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220003&do=use'; }
- else if (superiorHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220004&do=use'; }
- //else if (spiritHeal != -1) { location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=items&useitemid=220005&do=use'; }
- 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.
- }
- function findCombatPotion() {
- var CombatPotion;
- var weakHeal2 = getHealForPotion("Weak Healing Potion");
- var standardHeal2 = getHealForPotion("Standard Healing Potion");
- var strongHeal2 = getHealForPotion("Strong Healing Potion");
- var greatHeal2 = getHealForPotion("Greater Healing Potion");
- var superiorHeal2 = getHealForPotion("Superior Healing Potion");
- var spiritHeal2 = getHealForPotion("Spirit Healing Potion");
- //
- // For potion use IN COMBAT
- // Uses potions from weakest to strongest.
- // Add comment in front of "else if" lines if you don't want to use that type of potion.
- //
- if (CombatPotion == null) {
- 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.
- //else if (weakHeal2 > 0) { CombatPotion = findLinkContainingString("Weak Healing Potion"); }
- //else if (standardHeal2 > 0) { CombatPotion = findLinkContainingString("Standard Healing Potion"); }
- //else if (strongHeal2 > 0) { CombatPotion = findLinkContainingString("Strong Healing Potion"); }
- else if (greatHeal2 > 0) { CombatPotion = findLinkContainingString("Greater Healing Potion"); }
- else if (superiorHeal2 > 0) { CombatPotion = findLinkContainingString("Superior Healing Potion"); }
- //else if (spiritHeal2 > 0) { CombatPotion = findLinkContainingString("Spirit Healing Potion"); }
- 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.
- }
- return CombatPotion;
- }
- if(neoquest.search('to see what you found')!=-1){
- location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
- }
- if(neoquest.search('navarrows.gif')!=-1){
- if(health<( NonCombatHealPercent )){
- Items();
- }else {location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=move&movedir=';}
- }
- //
- // Heal out of combat
- //
- for(i=0;i<document.forms.length;i++){
- if(document.forms[i].elements[0].value=="Click here to return to the map"){
- if(neoquest.search('Your Items')!=-1){
- if(health<( NonCombatHealPercent )){
- NonCombatPotion();
- }else {location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=move&movedir=';}
- }
- else document.forms[i].submit();
- }
- }
- if(neoquest.search('to begin the fight')!=-1){
- location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
- }
- //
- // Heal in combat
- //
- if(health<( CombatHealPercent)&&((neoquest.search('Spirit of Growth')!=-1)||(neoquest.search('Healing Potion')!=-1))){
- if(neoquest.search('Spirit of Growth')!=-1){
- findLinkContainingString("Spirit of Growth").click();
- }else if(neoquest.search('Healing Potion')!=-1){
- findCombatPotion().click();
- }
- //
- // Otherwise use absorption
- // Commenting these two lines out if you don't want to use absorption
- //
- } else if(neoquest.search('Cast Absorption')!=-1){
- findLinkContainingString("Cast Absorption").click()
- //
- // Otherwise Attack
- //
- } else if(neoquest.search('Attack')!=-1){
- findLinkContainingString("Attack").click();
- } else if(neoquest.search('Do nothing')!=-1){
- findLinkContainingString("Do nothing").click();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement