Unstuck

Unstuck Aug PN

Mint 2025.08.01.. Lásd a legutóbbi verzió

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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);
    });

})();