Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Neoquest Attacker
- // @namespace http://userscripts.org/users/useridnumber
- // @include http://www.neopets.com/games/neoquest/*
- // ==/UserScript==
- 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 findBestPotion() {
- var bestPotion;
- var weakHeal = getHealForPotion("Weak Healing Potion");
- var standardHeal = getHealForPotion("Standard Healing Potion");
- var strongHeal = getHealForPotion("Strong Healing Potion");
- var greatHeal = getHealForPotion("Greater Healing Potion");
- var superiorHeal = getHealForPotion("Superior Healing Potion");
- var spiritHeal = getHealForPotion("Spirit Healing Potion");
- //
- // Get weakest potion that will give full heal
- //
- if (weakHeal >= healthLost) { bestPotion = findLinkContainingString("Weak Healing Potion"); }
- if (standardHeal >= healthLost) { bestPotion = findLinkContainingString("Standard Healing Potion"); }
- if (strongHeal >= healthLost) { bestPotion = findLinkContainingString("Strong Healing Potion"); }
- if (greatHeal >= healthLost) { bestPotion = findLinkContainingString("Greater Healing Potion"); }
- if (superiorHeal >= healthLost) { bestPotion = findLinkContainingString("Superior Healing Potion"); }
- if (spiritHeal >= healthLost) { bestPotion = findLinkContainingString("Spirit Healing Potion"); }
- //
- // If no potion gives full heal, find strongest in stock.
- //
- if (bestPotion == null) {
- if (spiritHeal > 0) { bestPotion = findLinkContainingString("Spirit Healing Potion"); }
- else if (superiorHeal > 0) { bestPotion = findLinkContainingString("Superior Healing Potion"); }
- else if (greatHeal > 0) { bestPotion = findLinkContainingString("Greater Healing Potion"); }
- else if (strongHeal > 0) { bestPotion = findLinkContainingString("Strong Healing Potion"); }
- else if (standardHeal > 0) { bestPotion = findLinkContainingString("Standard Healing Potion"); }
- else if (weakHeal > 0) { bestPotion = findLinkContainingString("Weak Healing Potion"); }
- }
- return bestPotion;
- }
- 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])
- if(neoquest.search('to see what you found')!=-1){
- location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
- }
- for(i=0;i<document.forms.length;i++){
- if(document.forms[i].elements[0].value=="Click here to return to the map"){
- document.forms[i].submit();
- }
- }
- if(neoquest.search('navarrows.gif')!=-1){
- location.href='http://www.neopets.com/games/neoquest/neoquest.phtml?action=move&movedir=';
- }
- if(neoquest.search('to begin the fight')!=-1){
- location.href='http://www.neopets.com/games/neoquest/neoquest.phtml';
- }
- //
- // We need to heal
- //
- if(health<(0.5)&&((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){
- findBestPotion().click();
- }
- //
- // 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