Civitai Ultra Fast Auto Clicker

스크롤 최적화된 Civitai 자동 클릭 스크립트 (10초 이내 완료)

目前为 2024-10-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         Civitai Ultra Fast Auto Clicker
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  스크롤 최적화된 Civitai 자동 클릭 스크립트 (10초 이내 완료)
// @author       Your Name
// @match        https://civitai.com/images
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // DOM 요소 캐싱
    let cachedButtons = new Set();
    let lastScrollPosition = 0;

    const createButton = () => {
        const button = document.createElement('button');
        button.innerText = '터보 클릭';
        button.style.cssText = `
            padding: 5px 10px;
            background-color: #ff0000;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            font-weight: bold;
        `;
        return button;
    };

    const rapidClickAllButtons = () => {
        const currentButtons = document.querySelectorAll('button');
        let clickCount = 0;

        currentButtons.forEach(button => {
            if (button.closest('div.absolute.inset-x-1.bottom-1.flex.items-center.justify-between.gap-1')
                && !cachedButtons.has(button)) {
                try {
                    button.click();
                    cachedButtons.add(button);
                    clickCount++;
                } catch (error) {
                    // 에러 무시
                }
            }
        });

        return clickCount;
    };

    const performScroll = () => {
        const scrollElement = document.documentElement || document.body;
        const currentPosition = window.pageYOffset || document.documentElement.scrollTop;
        const scrollHeight = Math.max(
            document.body.scrollHeight,
            document.documentElement.scrollHeight,
            document.body.offsetHeight,
            document.documentElement.offsetHeight
        );

        if (currentPosition >= scrollHeight - window.innerHeight) {
            return false; // 페이지 끝에 도달
        }

        window.scrollTo({
            top: currentPosition + (window.innerHeight / 1.5),
            behavior: 'auto'
        });

        return true;
    };

    const turboScrollAndClick = async () => {
        const totalDuration = 9000;
        const startTime = Date.now();
        let totalClicks = 0;
        let scrollAttempts = 0;

        while (Date.now() - startTime < totalDuration && scrollAttempts < 100) {
            const clicks = rapidClickAllButtons();
            totalClicks += clicks;

            if (clicks > 0) {
                console.log(`현재까지 클릭한 버튼 수: ${totalClicks}`);
            }

            await new Promise(resolve => setTimeout(resolve, 50));

            if (!performScroll()) {
                scrollAttempts++;
                await new Promise(resolve => setTimeout(resolve, 100));
                continue;
            }

            scrollAttempts = 0;
        }

        return totalClicks;
    };

    const cleanup = () => {
        cachedButtons.clear();
        lastScrollPosition = 0;
        if (window.gc) window.gc();
    };

    window.addEventListener('load', function() {
        const panel = document.querySelector('#main > div > div > footer > div.relative.flex.h-\\[var\\(--footer-height\\)\\].w-full.items-center.gap-2.overflow-x-auto.bg-gray-0.p-1.px-2.\\@sm\\:gap-3.dark\\:bg-dark-7.border-t.border-gray-3.dark\\:border-dark-4 > div.mantine-Group-root.mantine-1msv4yg');

        if (!panel) return;

        const newButton = createButton();
        let isProcessing = false;

        newButton.addEventListener('click', async function() {
            if (isProcessing) return;
            isProcessing = true;

            const startTime = Date.now();

            try {
                const totalClicks = await turboScrollAndClick();
                const executionTime = Date.now() - startTime;

                console.log(`총 실행 시간: ${executionTime}ms`);
                console.log(`총 클릭한 버튼 수: ${totalClicks}`);

                if (executionTime < 9500) {
                    setTimeout(() => {
                        cleanup();
                        location.reload();
                    }, 9500 - executionTime);
                } else {
                    cleanup();
                    location.reload();
                }
            } catch (error) {
                console.error('Error:', error);
                cleanup();
            } finally {
                isProcessing = false;
            }
        });

        panel.style.display = 'flex';
        panel.style.justifyContent = 'center';
        panel.appendChild(newButton);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址