Games By web crawler 2 installs Rating 0.0 (0) approved

Neopets - Kiko Pop Auto-Player

Automatically pops a balloon and collects your prize from Kiko Pop.
auto-player kiko pop neopets
https://www.scriptneo.com/script/neopets-kiko-pop-auto-player

Version selector


SHA256
4990472357d7b55c3404f527a6f2dbb7f1db9331b88c4f181da9c95b98ae736a
Static scan
Score: 2
Flags: uses_gm_xmlhttprequest

Source code

// ==UserScript==
// @name          Neopets - Kiko Pop Auto-Player
// @author        Odd
// @description   Automatically pops a balloon and collects your prize from Kiko Pop.
// @match         *://*.neopets.com/worlds/kiko/kpop/*
// @namespace     https://www.scriptneo.com/
// @version       1.0.0
// @grant         GM.xmlHttpRequest
// @grant         GM_xmlhttpRequest
// @downloadURL  https://www.scriptneo.com/scripts/download.php?id=41
// @updateURL    https://www.scriptneo.com/scripts/download.php?id=41
// ==/UserScript==

var DelayMax = 5000;
var DelayMin = 3000;
var Tries = 3;

(function () {

    function getStoredValue(key, defaultValue) {

        var value = localStorage.getItem(key);

        if (value != null) {

            if (typeof value == "string") {

                try { return JSON.parse(value); }
                catch (ex) { }
            }

            return value;
        }

        return defaultValue;
    }

    function setStoredValue(key, value) {

        if (value == null || value === undefined) localStorage.removeItem(key);
        else {

            if (typeof value != "number" && typeof value != "string") value = JSON.stringify(value);

            localStorage.setItem(key, value);
        }
    }

    if (typeof $ == "undefined") $ = unsafeWindow.$;

    if (typeof GM_xmlhttpRequest == "undefined") GM_xmlhttpRequest = GM.xmlHttpRequest;

    $("#pageDesc").after("<table id=\"kikoPopAutoPlayer\" style=\"margin: 0 auto; text-align: center; width: 450px;\"><tr><td><br><br><b>-Kiko Pop Auto-Player-</b><br><br></td></tr><tr><td></td></tr><tr><td><table cellpadding=\"0\" cellspacing=\"0\" style=\"margin: 0 auto; text-align: left;\"><tr><td><b>Auto-start:</b></td><td style=\"padding-left: 16px;\"><input id=\"kikoPopAutoPlayerAutoStart\" style=\"margin: 0;\" type=\"checkbox\"></td></tr><tr><td style=\"padding-top: 24px;\"><b>Difficulty:</b></td><td style=\"padding: 24px 0 0 16px;\"><table cellpadding=\"0\" cellspacing=\"0\"><tr><td><input id=\"kikoPopAutoPlayerDifficulty1\" name=\"kikoPopAutoPlayerDifficulty\" style=\"margin: 0;\" type=\"radio\"></td><td style=\"padding-left: 6px;\"><label for=\"kikoPopAutoPlayerDifficulty1\">Easy & Effortless</label></td></tr><tr><td style=\"padding-top: 10px;\"><input id=\"kikoPopAutoPlayerDifficulty2\" name=\"kikoPopAutoPlayerDifficulty\" style=\"margin: 0;\" type=\"radio\"></td><td style=\"padding: 10px 0 0 6px;\"><label for=\"kikoPopAutoPlayerDifficulty2\">Standard, I Can Take It</label></td></tr><tr><td style=\"padding-top: 10px;\"><input id=\"kikoPopAutoPlayerDifficulty3\" name=\"kikoPopAutoPlayerDifficulty\" style=\"margin: 0;\" type=\"radio\"></td><td style=\"padding: 10px 0 0 6px;\"><label for=\"kikoPopAutoPlayerDifficulty3\">Super Crazy Hard!!!</label></td></tr></table></td></tr></table><br><br></td></tr><tr><td><input id=\"kikoPopAutoPlayerStartStop\" type=\"button\"><br><br><br></td></tr></table>");

    var autoStart = (getStoredValue("kikoPop.autoStart") || false);
    var autoStartCheckbox = $("#kikoPopAutoPlayerAutoStart")
        .prop("checked", autoStart);
    var difficulty = Math.max(Math.min((parseInt(getStoredValue("kikoPop.difficulty")) || 2), 3), 1);
    var difficulty1 = $("#kikoPopAutoPlayerDifficulty1")
        .prop("checked", (difficulty == 1));
    var difficulty2 = $("#kikoPopAutoPlayerDifficulty2")
        .prop("checked", (difficulty == 2));
    var difficulty3 = $("#kikoPopAutoPlayerDifficulty3")
        .prop("checked", (difficulty == 3));
    var options = $("#kikoPopAutoPlayer > tbody > tr:nth-child(3)");
    var optionsL23 = 'CHVPqeJq1';
    var playing = autoStart;
    var startStop = $("#kikoPopAutoPlayerStartStop")
        .val(autoStart ? "Stop" : "Start");
    var status = $("#kikoPopAutoPlayer > tbody > tr:nth-child(2) > td");
    var timeoutID;

    if (playing) options.hide();

    function radio_onChange() {

        if (difficulty1.prop("checked")) difficulty = 1;
        else if (difficulty2.prop("checked")) difficulty = 2;
        else if (difficulty3.prop("checked")) difficulty = 3;

        setStoredValue("kikoPop.difficulty", ((difficulty == 2) ? null : difficulty));
    }

    function reset() {

        playing = false;

        if (timeoutID) {

            clearTimeout(timeoutID);

            timeoutID = null;
        }

        options.show();

        startStop.val("Start");

        status.html("");
    }

    function waitAndPopBalloon() {

        var tries = Tries;

        function onAbort() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to pop a balloon again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(popBalloon, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't pop a balloon because our requests were aborted!<br><br><br>");
            }
        }

        function onError() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to pop a balloon again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(popBalloon, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't pop a balloon due to an unexpected error!<br><br><br>");
            }
        }

        function onTimeout() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to pop a balloon again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(popBalloon, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't pop a balloon because our requests timed out!<br><br><br>");
            }
        }

        function popBalloon() {

            GM_xmlhttpRequest({

                data: ("difficulty=" + difficulty),
                headers:
                {

                    "Content-Type": "application/x-www-form-urlencoded",
                    Referer: location.href
                },
                method: "POST",
                onabort: onAbort,
                onerror: onError,
                onload: function (response) {

                    if (playing) {

                        if (response && response.responseText && (response = JSON.parse(response.responseText))) {

                            startStop.hide();

                            if (response.success) {

                                if (response.prize) {

                                    status.html(("<div style=\"width: 500px;\">" + $("#popupPrize").html() + "</div>")
                                        .replace(/<div[^>]*class\=\"button120\"[^>]*>.*<\/div>\s*/i, "")
                                        .replace(/<div[^>]*id\=\"prizeImage\"[^>]*>\s*<\/div>/i, "<div id=\"prizeImage\" style=\"background-image: url(" + response.prize.url + ");\"></div>")
                                        .replace(/<div[^>]*id\=\"prizeName\"[^>]*>\s*<b[^>]*>\s*<\/b>\s*<\/div>/i, "<div id=\"prizeName\"><b>" + response.prize.name + "</b></div>"));
                                }

                                if (prize.avatar) {

                                    $("#avatarDisplay").show()
                                        .after("<br><br>");

                                    startStop.next()
                                        .remove();
                                }

                                return;
                            }

                            status.html("<div style=\"width: 500px;\">Whoa, careful there! You're trying to hit a balloon, not take out one of the Kikos swimming in the lake. Maybe you'll have better luck tomorrow?</div>");

                            return;
                        }

                        reset();

                        status.html("Oops! We couldn't pop a balloon due to an unrecognized response!<br><br><br>");
                    }
                },
                ontimeout: onTimeout,
                timeout: 30000,
                url: (location.origin + "/worlds/kiko/kpop/ajax/prize.php")
            });
        }

        status.html("Popping a balloon...<br><br>");

        timeoutID = setTimeout(popBalloon, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));
    }

    function waitAndSelectDifficulty() {

        var tries = Tries;

        function onAbort() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to select a difficulty again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(selectDifficulty, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't select a difficulty because our requests were aborted!<br><br><br>");
            }
        }

        function onError() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to select a difficulty again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(selectDifficulty, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't select a difficulty due to an unexpected error!<br><br><br>");
            }
        }

        function onTimeout() {

            if (playing) {

                if (tries) {

                    tries--;

                    status.html("Oops! Trying to select a difficulty again (" + ((Tries - tries) + 1) + " of " + Tries + ")...<br><br>");

                    timeoutID = setTimeout(selectDifficulty, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));

                    return;
                }

                reset();

                status.html("Oops! We couldn't select a difficulty because our requests timed out!<br><br><br>");
            }
        }

        function selectDifficulty() {

            GM_xmlhttpRequest({

                data: ("difficulty=" + difficulty),
                headers:
                {

                    "Content-Type": "application/x-www-form-urlencoded",
                    Referer: location.href
                },
                method: "POST",
                onabort: onAbort,
                onerror: onError,
                onload: function (response) { if (playing) waitAndPopBalloon(); },
                ontimeout: onTimeout,
                timeout: 30000,
                url: (location.origin + "/worlds/kiko/kpop/ajax/difficulty.php")
            });
        }

        status.html("Selecting difficulty...<br><br>");

        timeoutID = setTimeout(selectDifficulty, Math.round((Math.random() * (DelayMax - DelayMin)) + DelayMin));
    }

    //GreaseMonkey compatible change
    document.getElementById(autoStartCheckbox.attr("id"))
        .addEventListener("change", function () {

            setStoredValue("kikoPop.autoStart", ((autoStart = autoStartCheckbox.prop("checked")) || null));
        });

    document.getElementById(difficulty1.attr("id"))
        .addEventListener("change", radio_onChange);

    document.getElementById(difficulty2.attr("id"))
        .addEventListener("change", radio_onChange);

    document.getElementById(difficulty3.attr("id"))
        .addEventListener("change", radio_onChange);

    //GreaseMonkey compatible click
    document.getElementById(startStop.attr("id"))
        .addEventListener("click", function () {

            if (playing = !playing) {

                options.hide();

                startStop.val("Stop");

                waitAndSelectDifficulty();
            }
            else {

                reset();
            }
        });

    if (playing) {

        if (!$("#difficultyForm").length) {

            startStop.hide();

            status.html("You've already played today!<br>");

            return;
        }

        waitAndSelectDifficulty();
    }
})();