Unstuck

Unstuck Aug PN

Από την 01/08/2025. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Unstuck
// @namespace    http://tampermonkey.net/
// @version      2025-08-01
// @description  Unstuck Aug PN
// @author       ...
// @match        https://pockieninja.online
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Espera a que exista un elemento con texto exacto
    function waitForElementByText(text, callback, interval = 500, timeout = 10000) {
        const start = Date.now();

        function search() {
            const xpath = `//*[normalize-space(text())='${text}']`;
            const result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
            for (let i = 0; i < result.snapshotLength; i++) {
                const el = result.snapshotItem(i);
                if (el.offsetParent !== null) { // solo visibles
                    callback(el);
                    return;
                }
            }
            if (Date.now() - start < timeout) {
                setTimeout(search, interval);
            } else {
                console.log(`❗ No se encontró el elemento con texto: "${text}"`);
            }
        }
        search();
    }

    // Espera a que exista una imagen con src exacto
    function waitForImageBySrc(src, callback, interval = 500, timeout = 10000) {
        const start = Date.now();

        function search() {
            const imgs = document.querySelectorAll(`img[src='${src}']`);
            for (let img of imgs) {
                if (img.offsetParent !== null) { // solo visibles
                    callback(img);
                    return;
                }
            }
            if (Date.now() - start < timeout) {
                setTimeout(search, interval);
            } else {
                console.log(`❗ No se encontró la imagen con src: "${src}"`);
            }
        }
        search();
    }

    // Click en el centro de la pantalla
    function clickCenter() {
        const x = window.innerWidth / 2;
        const y = window.innerHeight / 2;

        ['mousedown', 'mouseup', 'click'].forEach(type => {
            const event = new MouseEvent(type, {
                bubbles: true,
                cancelable: true,
                clientX: x,
                clientY: y,
                view: window
            });
            const target = document.elementFromPoint(x, y);
            if (target) {
                target.dispatchEvent(event);
            }
        });

        console.log('✅ Click en el centro de la pantalla');
    }

    // Click varias veces en Accept
    function clickAccept25Times(acceptEl, times = 25, delay = 300) {
        let count = 0;
        function doClick() {
            if (count < times) {
                acceptEl.click();
                count++;
                console.log(`✅ Click en Accept #${count}`);
                setTimeout(doClick, delay);
            } else {
                console.log('🎉 Terminados los 25 clicks en Accept');
            }
        }
        doClick();
    }

    // Secuencia completa
    waitForElementByText('Leave', el => {
        el.click();
        console.log('✅ Click en Leave');
        setTimeout(() => {
            waitForElementByText('World Map', el2 => {
                el2.click();
                console.log('✅ Click en World Map');
                setTimeout(() => {
                    clickCenter();
                    setTimeout(() => {
                        waitForImageBySrc('https://pockie-ninja.sfo3.cdn.digitaloceanspaces.com/assets/public/ui/SlotMachine/icon.png', imgEl => {
                            imgEl.click();
                            console.log('✅ Click en imagen SlotMachine');
                            setTimeout(() => {
                                waitForElementByText('Challenge', challengeEl => {
                                    challengeEl.click();
                                    console.log('✅ Click en Challenge');
                                    setTimeout(() => {
                                        waitForElementByText('Accept', acceptEl => {
                                            clickAccept25Times(acceptEl);
                                        });
                                    }, 500);
                                });
                            }, 500);
                        });
                    }, 1000);
                }, 1000);
            });
        }, 1000);
    });

})();