Gartic.io Token Fetcher (Optimized) 2

Fetch tokens from turnstile and send to server with auto-refresh

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Gartic.io Token Fetcher (Optimized) 2
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Fetch tokens from turnstile and send to server with auto-refresh
// @author       You
// @match        *://gartic.io/*
// @match        *://*.gartic.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const TOKEN_INTERVAL = 5000; // كل 4 ثواني تقريبًا
    const PAGE_REFRESH_INTERVAL = 2 * 60 * 1000;
    function createTurnstileFrame() {
        const iframe = document.createElement("iframe");
        iframe.style.display = "none";
        iframe.sandbox = "allow-scripts allow-same-origin";
        document.body.appendChild(iframe);

        const html = `
            <!DOCTYPE html>
            <html>
            <head><script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script></head>
            <body>
                <div id="cf-turnstile"></div>
                <script>
                    window.onload = function() {
                        turnstile.render("#cf-turnstile", {
                            sitekey: "0x4AAAAAABBPKaIbNwnPEfSo",
                            callback: function(token) {
                                parent.postMessage(token, "*");
                            }
                        });
                    }
                </script>
            </body>
            </html>
        `;

        iframe.srcdoc = html;
    }

    window.addEventListener("message", function (event) {
        const token = event.data;
        if (typeof token === "string" && token.length > 20) {
            console.log("Token received:", token);

            fetch("https://mesho.alwaysdata.net/add-token", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json"
                },
                body: JSON.stringify({ token: token })
            })
            .then(res => res.json())
            .then(data => console.log("Server Response:", data))
            .catch(err => console.error("Error sending token:", err));
        }

        // Remove all iframes after usage
        document.querySelectorAll("iframe").forEach(iframe => iframe.remove());
    });

    setInterval(createTurnstileFrame, TOKEN_INTERVAL);
    createTurnstileFrame();

      setTimeout(() => {
        console.log("Refreshing page to prevent freeze...");
        location.reload();
    }, PAGE_REFRESH_INTERVAL);

})();