// ==UserScript== // @name Neopets - Auto Fishing // @namespace Scriptneo // @version 1.0.0 // @author Scriptneo // @description Fish with all your pets in one click // @match *://*.neopets.com/water/fishing.phtml* // @grant none // @downloadURL https://www.scriptneo.com/scripts/download.php?id=37 // @updateURL https://www.scriptneo.com/scripts/download.php?id=37 // ==/UserScript== const $form = $("form[action='/water/fishing.phtml']"); $form.css({ "height": "250px" }).before(``); $("#fish-all").on("click", async function () { const delay = (min, max) => Math.floor(Math.random() * max) + min; $(this) .prop("disabled", true) .toggleClass("button-green__2020") .toggleClass("button-purple__2020") .html(`Processing...`); $form.html(`
Pet Item Skill level up?
`); const refck = $("body").html().match(/"_ref_ck":'(.{32})'/)[1]; $(this).html("Getting pet list..."); const pets = await getPetNames(); for (let i = 0; i < pets.length; i++) { $(this).html(`${pets[i]} fishing...`); const outcome = await goFish(pets[i]); $("#fish-result tbody").append(outcome); $(this).html(`Switching active pet...`); if (pets.length === 1) { // No need to switch pets if only one pet break; } if (i < pets.length - 1) { // Not last pet yet, switch to next pet await changePet(pets[i + 1]); } else { // Reached last pet, switch back to first pet await changePet(pets[0]); } } $(this) .html("Done!") .toggleClass("button-purple__2020") .toggleClass("button-green__2020"); //------------------------------------------------------------------------- // Functions //------------------------------------------------------------------------- function getPetNames() { return new Promise(resolve => { $.ajax({ type: "GET", url: "https://www.neopets.com/home/index.phtml", success: data => { const response = $.parseHTML(data); let pets = []; $(response).find(".hp-carousel-pet").each(function (index, element) { const petname = $(element).attr("data-name"); pets.push(petname); }); resolve(pets); } }); }); } function changePet(pet) { return new Promise(resolve => { setTimeout(() => { $.ajax({ type: "POST", url: "https://www.neopets.com/np-templates/ajax/changepet.php", data: { "_ref_ck": refck, "new_active_pet": pet }, success: data => { const response = JSON.parse(data); if (response["error"] === false) { resolve(); } } }); }, delay(10, 200)); }) } function goFish(pet) { return new Promise(resolve => { setTimeout(() => { $.ajax({ type: "POST", url: "https://www.neopets.com/water/fishing.phtml", data: { "go_fish": "1" }, success: data => { const response = $.parseHTML(data); const outcome = $(response).find(".page-title__2020 ~ p").text(); const item = outcome.match(/\.{3}(.+?)!/)[1]; const level = (() => { let lvlup; try { lvlup = outcome.match(/increases to (\d+)/)[1]; } catch (e) { lvlup = "-"; } return lvlup; })(); resolve(`${pet}${item}${level}`); } }); }, delay(10, 200)); }) } });