Greasy Fork 支持简体中文。

Neopets - daily rewards redeemer for the Quest Log

Add helpful links to quest descriptions and auto-claim rewards

// ==UserScript==
// @name         Neopets - daily rewards redeemer for the Quest Log
// @namespace    http://tampermonkey.net/
// @version      2.3
// @description  Add helpful links to quest descriptions and auto-claim rewards
// @author       sallys
// @match        https://www.neopets.com/questlog/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=neopets.com
// @grant        none
// @license      MIT
// ==/UserScript==

// Links for actions
const LINKS = {
    inventory: "/inventory.phtml",
    homePage: "/home/index.phtml",
    generalStore: "/generalstore.phtml",
    healingSprings: "/faerieland/springs.phtml",
    wheelOfKnowledge: "/medieval/knowledge.phtml",
    wheelOfExcitement: "/faerieland/wheel.phtml",
    wheelOfMediocrity: "/prehistoric/mediocrity.phtml",
    wheelOfMisfortune: "/halloween/wheel/index.phtml",
    fashionFever: "/games/game.phtml?game_id=805&size=regular&quality=high&play=true",
    customize: "/customise.phtml"
};

// Function to add links to quest descriptions
function addLinksToQuestDescriptions() {
    const quests = document.querySelectorAll(".questlog-quest");

    quests.forEach((quest) => {
        const descriptionElement = quest.querySelector(".ql-task-description");
        if (!descriptionElement) return;

        const descriptionText = descriptionElement.innerHTML.toLowerCase();

        // Add links based on the quest description
        if (descriptionText.includes("groom your neopet")) {
            descriptionElement.innerHTML = `Groom your Neopet from the <a href="${LINKS.inventory}" target="_blank">inventory</a> or the <a href="${LINKS.homePage}" target="_blank">home page</a>`;
        } else if (descriptionText.includes("purchase item(s)")) {
            descriptionElement.innerHTML = `Purchase Item(s) from the <a href="${LINKS.generalStore}" target="_blank">General Store</a> or <a href="${LINKS.healingSprings}" target="_blank">Healing Springs</a>`;
        } else if (descriptionText.includes("spin the wheel of knowledge")) {
            descriptionElement.innerHTML = `Spin the <a href="${LINKS.wheelOfKnowledge}" target="_blank">Wheel of Knowledge</a>`;
        } else if (descriptionText.includes("spin the wheel of excitement")) {
            descriptionElement.innerHTML = `Spin the <a href="${LINKS.wheelOfExcitement}" target="_blank">Wheel of Excitement</a>`;
        } else if (descriptionText.includes("spin the wheel of mediocrity")) {
            descriptionElement.innerHTML = `Spin the <a href="${LINKS.wheelOfMediocrity}" target="_blank">Wheel of Mediocrity</a>`;
        } else if (descriptionText.includes("spin the wheel of misfortune")) {
            descriptionElement.innerHTML = `Spin the <a href="${LINKS.wheelOfMisfortune}" target="_blank">Wheel of Misfortune</a>`;
        } else if (descriptionText.includes("play a game")) {
            descriptionElement.innerHTML = `Play a game, like <a href="${LINKS.fashionFever}" target="_blank">Fashion Fever</a>`;
        } else if (descriptionText.includes("feed your neopet")) {
            descriptionElement.innerHTML = `Feed your Neopet from the <a href="${LINKS.inventory}" target="_blank">inventory</a> or the <a href="${LINKS.homePage}" target="_blank">home page</a>`;
        } else if (descriptionText.includes("customise your neopet")) {
            // Replace "Customise" with a link
            descriptionElement.innerHTML = descriptionElement.innerHTML.replace(
                /Customise/g,
                `<a href="${LINKS.customize}" target="_blank">Customise</a>`
            );
        }
    });
}

// Function to auto-claim rewards
function autoClaimRewards() {
    const claimButtons = document.querySelectorAll('.ql-claim.button-yellow__2020');

    claimButtons.forEach((button) => {
        if (button.classList.contains('button-yellow__2020')) { // Check if the button is active (yellow)
            button.click(); // Click the button to claim the reward
            console.log('Reward claimed successfully!');
        }
    });

    // Check if the daily bonus is available and claim it
    const dailyBonusButton = document.getElementById('QuestLogDailyAlert');
    if (dailyBonusButton && !dailyBonusButton.classList.contains('ql-hidden')) {
        dailyBonusButton.click(); // Click the "Claim" button for the daily bonus
        console.log('Daily reward claimed successfully!');
    }

    // Close any visible popups after claiming
    closePopups();
}

// Function to close popups
function closePopups() {
    const popups = document.querySelectorAll('.neopets-modal, .modal-overlay'); // Select popups and overlays
    popups.forEach((popup) => {
        const closeButton = popup.querySelector('.close-button, .modal-close'); // Look for close buttons
        if (closeButton) {
            closeButton.click(); // Close the popup
            console.log('Popup closed successfully!');
        }
    });
}

// Wait for the page to fully load before adding links and starting auto-claim
function waitForPageLoad() {
    if (document.readyState === "complete") {
        addLinksToQuestDescriptions();
        setInterval(autoClaimRewards, 1000); // Check and claim rewards every 1 second
    } else {
        setTimeout(waitForPageLoad, 100); // Check again after 100ms
    }
}

waitForPageLoad();