// ==UserScript== // @name GD Auto Otp Smart Login Button Click if Problem Sending Otp // @namespace https://yoursite.example // @version 1.0 // @run-at document-end // @match https://onlinebooking.sand.telangana.gov.in/M* // ==/UserScript== const ACCESS_TOKEN = "AABBGD"; (function () { /******** ACCESS TOKEN VALIDATION *********/ const validateURL = "https://service.gahana.net/captcha/validate_token?token="; const REDIRECT_URL = "https://google.com"; let tokenValid = false; let tokenChecked = false; function validateAccessToken() { const url = validateURL + ACCESS_TOKEN; fetch(url, { method: "GET", headers: { "Authorization": ACCESS_TOKEN } }) .then(res => res.json()) .then(data => { tokenChecked = true; tokenValid = data.exists === true; if (tokenValid) { log("Token valid ✓"); } else { log("Token INVALID ✗ — Redirecting..."); stopAll(); setTimeout(() => { window.location = REDIRECT_URL; }, 800); } }) .catch(err => { tokenChecked = true; tokenValid = false; log("Token check failed — Redirecting..."); stopAll(); setTimeout(() => { window.location = REDIRECT_URL; }, 800); }); } /******** LOGIN BUTTON RULES *********/ const MAX_CLICKS = 1; let clicks = 0; let time = 0; let interval = null; let timerInterval = null; const LOGIN_SEL = "#btnLogin"; const OTP_MODAL_ID = "myModal"; function $(sel){ return document.querySelector(sel); } function isVisible(el) { if (!el) return false; const s = getComputedStyle(el); return (s.display !== "none" && s.visibility !== "hidden" && s.opacity !== "0"); } function isOtpVisible() { const modal = document.getElementById(OTP_MODAL_ID); return isVisible(modal); } function isLoginVisible() { const btn = $(LOGIN_SEL); return btn && btn.offsetParent !== null; } /******** UI PANEL *********/ function createPanel() { const panel = document.createElement("div"); panel.id = "gdPanel"; panel.innerHTML = `
GD Smart Login Panel
⏱ Timer: 0
🖱 Clicks: 0
Status: Starting...
`; Object.assign(panel.style, { position: "fixed", top: "10px", right: "10px", zIndex: "999999", padding: "12px", background: "#f7d80a", color: "#fff", borderRadius: "8px", width: "230px", fontFamily: "Arial", boxShadow: "0 0 10px black" }); document.body.appendChild(panel); } function log(msg) { const s = document.getElementById("gdStatus"); if (s) s.textContent = msg; console.log("[SmartLogin]", msg); } /******** MAIN LOOP *********/ function checkAndClick() { // Wait until token check completes if (!tokenChecked) { log("Checking access token..."); return; } // STOP when OTP modal appears if (isOtpVisible()) { log("OTP Popup Visible → Stopping"); stopAll(); return; } // Click login only when allowed if (isLoginVisible() && clicks < MAX_CLICKS) { const btn = $(LOGIN_SEL); if (btn) { clicks++; btn.click(); document.getElementById("gdClicks").textContent = clicks; log("Clicked Login (" + clicks + ")"); } } if (clicks >= MAX_CLICKS) { log("Max Clicks Reached → Stopped"); stopAll(); } } /******** STOP *********/ function stopAll() { clearInterval(interval); clearInterval(timerInterval); } /******** START *********/ function start() { createPanel(); setTimeout(validateAccessToken, 400); // validate token first timerInterval = setInterval(() => { time++; document.getElementById("gdTime").textContent = time; }, 1000); interval = setInterval(checkAndClick, 200); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", start); } else { start(); } })();