🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

AContinuar - Sequência de cliques Ctrl+Alt+A

Simula hover, clica em botões e confirma no modal ao pressionar Ctrl+Alt+A.

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 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         AContinuar - Sequência de cliques Ctrl+Alt+A
// @namespace    http://tampermonkey.net/
// @version      2.5
// @description  Simula hover, clica em botões e confirma no modal ao pressionar Ctrl+Alt+A.
// @author       Guilherme
// @match        *://*/*
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    /** 🔍 Busca elemento via XPath */
    function getElementByXpath(xpath) {
        return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    }

    /** ⏳ Espera o elemento aparecer (até o tempo limite) */
    async function waitForElement(xpath, timeout = 5000) {
        const start = Date.now();
        while (Date.now() - start < timeout) {
            const el = getElementByXpath(xpath);
            if (el) return el;
            await new Promise(r => setTimeout(r, 200));
        }
        return null;
    }

    /** 🖱️ Simula um evento real de mouse */
    function simulateMouseEvent(element, eventType = 'click') {
        const event = new MouseEvent(eventType, {
            bubbles: true,
            cancelable: true,
            view: window
        });
        element.dispatchEvent(event);
    }

    /** 🧠 Aguarda um pequeno delay */
    const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

    /** 🏁 Sequência principal */
    async function executarSequencia() {
        try {
            console.log('🚀 Iniciando sequência de cliques...');

            // 🔹 1. Simula hover no botão de ações
            const botaoAcoesXPath = '//*[@id="infinite-scroller"]/section/main/section/div[1]/header/aside/button[2]';
            const botaoAcoes = await waitForElement(botaoAcoesXPath, 5000);
            if (!botaoAcoes) {
                console.warn('⚠️ Botão de ações não encontrado.');
                return;
            }

            simulateMouseEvent(botaoAcoes, 'mouseover');
            console.log('🖱️ Hover simulado no botão de ações.');

            // Aguarda menu abrir
            await sleep(800);

            // 🔹 2. Clica no botão "Continuar"
            const continuarXPath = '/html/body/div[3]/div/div/button[3]';
            const continuar = await waitForElement(continuarXPath, 5000);
            if (!continuar) {
                console.warn('⚠️ Botão "Continuar" não encontrado.');
                return;
            }

            simulateMouseEvent(continuar, 'mousedown');
            simulateMouseEvent(continuar, 'mouseup');
            simulateMouseEvent(continuar, 'click');
            console.log('✅ Botão "Continuar" clicado.');

            // Aguarda modal aparecer
            await sleep(1000);

            // 🔹 3. Clica no botão dentro do modal
            const modalBotaoXPath = '/html/body/div[4]/div/div[2]/div/div[1]/div/div[2]/button[2]';
            const modalBotao = await waitForElement(modalBotaoXPath, 5000);
            if (!modalBotao) {
                console.warn('⚠️ Botão dentro do modal não encontrado.');
                return;
            }

            simulateMouseEvent(modalBotao, 'mousedown');
            simulateMouseEvent(modalBotao, 'mouseup');
            simulateMouseEvent(modalBotao, 'click');
            console.log('🎯 Botão dentro do modal clicado com sucesso.');

        } catch (error) {
            console.error('❌ Erro na execução da sequência:', error);
        }
    }

    /** ⌨️ Atalho global Ctrl + Alt + A */
    window.addEventListener('keydown', function (event) {
        // ignora se estiver digitando num input
        if (['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)) return;

        if (event.ctrlKey && event.altKey && event.key.toLowerCase() === 'a') {
            event.preventDefault();
            console.log('⌨️ Atalho Ctrl+Alt+A detectado.');
            executarSequencia();
        }
    }, true); // <- “true” captura o evento antes que o site o consuma
})();