Unstuck

Unstuck Aug PN

目前為 2025-08-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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

})();