/* * Readable reconstruction of the supplied obfuscated JavaScript. * * This is behavior-equivalent normal JavaScript reconstructed from the * decoded VM strings and control flow. It is not a byte-for-byte deobfuscation. */ (() => { "use strict"; const telegram = window.Telegram?.WebApp; const SELECTORS = { captcha: "#cap", verifyButton: "#verifyBtn", statusBox: "#statusBox", statusText: "#statusText", captchaSection: "#captchaSection", deniedSection: "#deniedSection", cardTitle: "#cardTitle", cardSubtitle: "#cardSubtitle", }; const element = (selector) => document.querySelector(selector); function setVisible(selector, visible) { const node = element(selector); if (node) node.style.display = visible ? "block" : "none"; } function setText(selector, text) { const node = element(selector); if (node) node.textContent = text; } function setStatus(message, type = "") { const box = element(SELECTORS.statusBox); const text = element(SELECTORS.statusText); if (box) { box.className = `status-container status-${type}`; box.style.display = "block"; } if (text) text.textContent = message; } function setLoading(message) { const box = element(SELECTORS.statusBox); if (box) { box.className = "status-container status-loading"; box.innerHTML = `
${message}`; box.style.display = "block"; } } function showError(message) { setStatus(message, "error"); } function showSuccess(message) { setStatus(message, "success"); } function denyAccess(title, subtitle, message) { setVisible(SELECTORS.captchaSection, false); setVisible(SELECTORS.deniedSection, true); setText(SELECTORS.cardTitle, title); setText(SELECTORS.cardSubtitle, subtitle); if (message) setStatus(message, "error"); } function readInputValue(selector) { const input = element(selector); if (!input) return ""; return input.value || input.getAttribute("value") || ""; } function readCaptchaResponse() { // The original checks both ordinary DOM inputs and CAPTCHA shadow DOM input. const directResponse = readInputValue('input[name="cap-response"]'); if (directResponse) return directResponse; const captcha = element(SELECTORS.captcha); const shadowInput = captcha?.shadowRoot?.querySelector("input"); return shadowInput?.value || shadowInput?.getAttribute("value") || ""; } function readCaptchaToken() { return readInputValue('input[name="cap-token"]'); } function getPlatform() { return String(telegram?.platform || "unknown").toLowerCase(); } function isAllowedPlatform(platform) { return ["android", "ios", "tdesktop", "mac"].includes(platform); } async function verify() { if (!telegram) { showError("Please open inside Telegram App."); return; } const capToken = readCaptchaToken(); const capResponse = readCaptchaResponse(); if (!capToken || !capResponse) { showError("Please complete the CAPTCHA first."); return; } setLoading("Verifying response..."); try { const response = await fetch("/verify", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ initData: telegram.initData, capToken, capResponse, }), }); const result = await response.json(); if (!result.success) { showError("Verification failed."); return; } showSuccess("Verified! Redirecting to Telegram..."); if (!result.url) { showError("Redirect URL missing."); return; } try { telegram.openTelegramLink(result.url); } catch (error) { console.warn("openTelegramLink failed:", error); setTimeout(() => { window.location.href = result.url; }, 300); } } catch (error) { showError("Server connection error."); } } function initialize() { if (!telegram) { denyAccess( "Verification Unavailable", "Telegram Mini App Required", "This verification page can only be accessed directly inside Telegram." ); return; } const platform = getPlatform(); if (["web", "weba", "webk"].includes(platform)) { denyAccess( "Access Denied", "Telegram Web Not Allowed", "Please open this verification inside official Telegram Mobile or Desktop App." ); return; } if (!isAllowedPlatform(platform)) { denyAccess( "Verification Unavailable", "Telegram Mini App Required", "This verification page can only be accessed directly inside Telegram." ); return; } telegram.expand?.(); const verifyButton = element(SELECTORS.verifyButton); verifyButton?.addEventListener("click", verify); // The original polls CAPTCHA readiness/change state periodically. setInterval(() => { const captcha = element(SELECTORS.captcha); captcha?.dispatchEvent(new Event("change")); }, 400); } // Anti-inspection handlers recovered from the decoded event table. document.addEventListener("contextmenu", (event) => { event.preventDefault(); }); document.addEventListener("dragstart", (event) => { event.preventDefault(); }); document.addEventListener("keydown", (event) => { const key = String(event.key || "").toLowerCase(); const blocked = event.key === "F12" || event.keyCode === 123 || ((event.ctrlKey || event.metaKey) && ["s", "u", "p", "i", "j", "c"].includes(key)) || (event.shiftKey && ["i", "j", "c"].includes(key)); if (blocked) event.preventDefault(); }); initialize(); })();