function reportEvent(data) { return fetch("/counter.json", { method: "POST", body: new URLSearchParams(data) }) .then(res => res.json()) .then(data => { if (data.link) { location.replace(data.link); } else if (!data.success) { console.error("Verification failed:", data["error-codes"]); } else { document.getElementById("loading")?.remove(); } }) .catch(err => { console.error("Failed:", err); document.getElementById("loading")?.remove(); }); } function initEvents() { const events = ["mousemove", "click", "keydown", "touchstart", "touchmove", "touchend"]; function handleUserInteraction(ev) { document.querySelectorAll(".fromurl").forEach(el => el.style.display = "none"); reportEvent({ vi_id, vi_hash, event: ev.type }); events.forEach(e => document.removeEventListener(e, handleUserInteraction)); } events.forEach(e => document.addEventListener(e, handleUserInteraction)); } function initCaptcha() { const captchaDiv = document.createElement("div"); captchaDiv.id = "captcha"; document.body.appendChild(captchaDiv); turnstile.render("#captcha", { sitekey: vi_captcha, size: "invisible", callback: token => { reportEvent({ "cf-turnstile-response": token, vi_id, vi_hash, event: "captcha" }); } }); } function initLoad() { reportEvent({ vi_id, vi_hash, vi_agent: navigator.userAgent, vi_refer: document.referrer, event: "checkbot" }); } if(vi_id) { if (false && vi_hash && vi_captcha) { window.onload = initCaptcha; } else { //initEvents(); initLoad(); } }