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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time, base64, hashlib, re
|
| 2 |
+
from fastapi import FastAPI, Request, HTTPException
|
| 3 |
+
from fastapi.responses import HTMLResponse
|
| 4 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
+
from sqlitedict import SqliteDict
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
# --- เปิด CORS เพื่อให้หน้าเว็บจริงทำงานร่วมกับ Hugging Face ได้อย่างเสถียร ---
|
| 10 |
+
app.add_middleware(
|
| 11 |
+
CORSMiddleware,
|
| 12 |
+
allow_origins=["*"],
|
| 13 |
+
allow_credentials=True,
|
| 14 |
+
allow_methods=["*"],
|
| 15 |
+
allow_headers=["*"],
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# --- CONFIGURATION ---
|
| 19 |
+
TARGET_WEBSITE_URL = "https://rov3.vercel.app"
|
| 20 |
+
FIREWALL_DB = "firewall.sqlite"
|
| 21 |
+
MAX_REQUESTS_PER_MINUTE = 20
|
| 22 |
+
BLOCK_TIME_SECONDS = 3600
|
| 23 |
+
SECRET_KEY = "TANZAi_SUPER_SECRET"
|
| 24 |
+
|
| 25 |
+
BOT_BLACKLIST = [
|
| 26 |
+
"sqlmap", "nmap", "dirbuster", "nikto", "hound", "scan", "headless",
|
| 27 |
+
"python-requests", "go-http-client", "java/", "curl/", "wget", "zmeu",
|
| 28 |
+
"masscan", "acunetix", "netsparker", "openvas", "censys", "shodan"
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
def get_client_ip(request: Request):
|
| 32 |
+
for header in ["cf-connecting-ip", "x-real-ip", "x-forwarded-for"]:
|
| 33 |
+
value = request.headers.get(header)
|
| 34 |
+
if value:
|
| 35 |
+
return value.split(',')[0].strip()
|
| 36 |
+
return request.client.host
|
| 37 |
+
|
| 38 |
+
def generate_token(ip):
|
| 39 |
+
time_window = int(time.time() / 600)
|
| 40 |
+
return hashlib.md5(f"{ip}{SECRET_KEY}{time_window}".encode()).hexdigest()
|
| 41 |
+
|
| 42 |
+
def is_blocked(ip):
|
| 43 |
+
with SqliteDict(FIREWALL_DB, autocommit=True) as db:
|
| 44 |
+
if ip in db:
|
| 45 |
+
blocked_until = db[ip].get("blocked_until", 0)
|
| 46 |
+
if blocked_until > time.time(): return True
|
| 47 |
+
else: del db[ip]
|
| 48 |
+
return False
|
| 49 |
+
|
| 50 |
+
def check_rate_limit_and_block(ip):
|
| 51 |
+
with SqliteDict(FIREWALL_DB, autocommit=True) as db:
|
| 52 |
+
data = db.get(ip, {"count": 0, "first_request": time.time()})
|
| 53 |
+
data["count"] += 1
|
| 54 |
+
db[ip] = data
|
| 55 |
+
if time.time() - data["first_request"] > 60:
|
| 56 |
+
del db[ip]
|
| 57 |
+
return
|
| 58 |
+
if data["count"] > MAX_REQUESTS_PER_MINUTE:
|
| 59 |
+
data["blocked_until"] = time.time() + BLOCK_TIME_SECONDS
|
| 60 |
+
db[ip] = data
|
| 61 |
+
|
| 62 |
+
def cyber_security_waf(request: Request):
|
| 63 |
+
user_agent = request.headers.get("user-agent", "").lower()
|
| 64 |
+
if not user_agent or len(user_agent) < 10:
|
| 65 |
+
return False
|
| 66 |
+
for bot in BOT_BLACKLIST:
|
| 67 |
+
if bot in user_agent:
|
| 68 |
+
return False
|
| 69 |
+
if not request.headers.get("accept"):
|
| 70 |
+
return False
|
| 71 |
+
return True
|
| 72 |
+
|
| 73 |
+
# หน้า UI ด่านตรวจ (ดึงปุ่มและ UI ตัว AI ออกไปเพื่อรอโหลดผ่านระบบสคริปต์ตามไปที่หน้าเว็บหลัก)
|
| 74 |
+
def generate_challenge_html(ip):
|
| 75 |
+
token = generate_token(ip)
|
| 76 |
+
html = f"""
|
| 77 |
+
<!DOCTYPE html>
|
| 78 |
+
<html lang="th">
|
| 79 |
+
<head>
|
| 80 |
+
<meta charset="UTF-8">
|
| 81 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 82 |
+
<title>TANZAi | กำลังทำการตรวจสอบความปลอดภัย</title>
|
| 83 |
+
<style>
|
| 84 |
+
body {{ font-family: -apple-system, system-ui, sans-serif; background: white; color: black; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; text-align: center; overflow: hidden; position: relative; }}
|
| 85 |
+
.container {{ max-width: 500px; width: 90%; position: relative; z-index: 10; }}
|
| 86 |
+
h1 {{ font-size: 40px; font-weight: 500; margin-bottom: 0px; color: #10b981; }}
|
| 87 |
+
h2 {{ font-size: 28px; font-weight: 500; margin-top: 10px; margin-bottom: 5px; }}
|
| 88 |
+
p {{ font-size: 16px; color: #555; line-height: 1.4; }}
|
| 89 |
+
#cf-widget-container {{ border: 1px solid #ddd; border-radius: 8px; background: #fafafa; padding: 15px; display: flex; align-items: center; justify-content: space-between; margin-top: 25px; }}
|
| 90 |
+
.cf-left {{ display: flex; align-items: center; }}
|
| 91 |
+
.cf-logo {{ width: 100px; filter: hue-rotate(140deg); }}
|
| 92 |
+
.cf-ip-info {{ font-size: 12px; color: #666; margin-top: 20px; }}
|
| 93 |
+
|
| 94 |
+
.captcha-box {{ display: flex; align-items: center; cursor: pointer; user-select: none; }}
|
| 95 |
+
.captcha-checkbox {{ width: 24px; height: 24px; border: 2px solid #ccc; border-radius: 4px; margin-right: 12px; display: flex; align-items: center; justify-content: center; background: #ffffff; transition: all 0.2s ease; }}
|
| 96 |
+
.captcha-box:hover .captcha-checkbox {{ border-color: #10b981; }}
|
| 97 |
+
.captcha-checkbox.checked {{ background: #10b981; border-color: #10b981; }}
|
| 98 |
+
.captcha-checkbox.checked::after {{ content: '✔'; color: white; font-size: 14px; font-weight: bold; }}
|
| 99 |
+
.cf-spinner {{ border: 4px solid #eee; border-top: 4px solid #10b981; border-radius: 50%; width: 25px; height: 25px; animation: spin 1s linear infinite; margin-right: 15px; display: none; }}
|
| 100 |
+
@keyframes spin {{ 0% {{ transform: rotate(0deg); }} 100% {{ transform: rotate(360deg); }} }}
|
| 101 |
+
</style>
|
| 102 |
+
<script>
|
| 103 |
+
if (window.top !== window.self) {{
|
| 104 |
+
let attackerUrl = "เว็บไซต์อื่น";
|
| 105 |
+
if (location.ancestorOrigins && location.ancestorOrigins.length > 0) {{
|
| 106 |
+
try {{ attackerUrl = new URL(location.ancestorOrigins[0]).hostname; }} catch(e) {{}}
|
| 107 |
+
}} else if (document.referrer) {{
|
| 108 |
+
try {{ attackerUrl = new URL(document.referrer).hostname; }} catch(e) {{}}
|
| 109 |
+
}}
|
| 110 |
+
if (!attackerUrl.includes("hf.space") && !attackerUrl.includes("vercel.app") && !attackerUrl.includes("localhost")) {{
|
| 111 |
+
window.stop();
|
| 112 |
+
document.documentElement.innerHTML = '<div style="font-family:-apple-system,sans-serif;background:white;color:black;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;text-align:center;"><div style="max-width:500px;width:90%;"><h1 style="font-size:40px;color:#ef4444;margin:0;">TANZAi</h1><h2 style="font-size:22px;margin-top:15px;color:#ef4444;">ตรวจพบว่า [' + attackerUrl + '] ทำการดึงหน้าเว็บไซต์เราไปแสดง</h2><p style="color:#555;font-size:16px;line-height:1.5;margin-top:10px;">จะไม่สามารถใช้งานเว็บไซต์จนกว่า [' + attackerUrl + '] จะแก้ไข</p></div></div>';
|
| 113 |
+
}}
|
| 114 |
+
}}
|
| 115 |
+
</script>
|
| 116 |
+
</head>
|
| 117 |
+
<body>
|
| 118 |
+
<div class="container">
|
| 119 |
+
<h1>TANZAi</h1>
|
| 120 |
+
<h2>กำลังทำการตรวจสอบความปลอดภัย</h2>
|
| 121 |
+
<p>กรุณาติ๊กเลือกช่องด้านล่างเพื่อยืนยันว่าคุณไม่ใช่สคริปต์อัตโนมัติ</p>
|
| 122 |
+
<div id="cf-widget-container">
|
| 123 |
+
<div class="cf-left">
|
| 124 |
+
<div class="cf-spinner" id="main-spinner"></div>
|
| 125 |
+
<div id="status-area">
|
| 126 |
+
<div class="captcha-box" id="click-target" onclick="triggerChallenge()">
|
| 127 |
+
<div class="captcha-checkbox" id="check-visual"></div>
|
| 128 |
+
<span style="font-size: 15px; color: #333; font-weight: 500;" id="captcha-text-label">ฉันไม่ใช่โปรแกรมอัตโนมัติ</span>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
<div class="cf-right">
|
| 133 |
+
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4b/Cloudflare_Logo.svg" alt="Cloudflare" class="cf-logo">
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
<div class="cf-ip-info">IP ของคุณ: {ip}</div>
|
| 137 |
+
</div>
|
| 138 |
+
|
| 139 |
+
<script src="/js?tz_token={token}"></script>
|
| 140 |
+
|
| 141 |
+
<script>
|
| 142 |
+
let isProcessing = false;
|
| 143 |
+
async function triggerChallenge() {{
|
| 144 |
+
if(isProcessing) return;
|
| 145 |
+
isProcessing = true;
|
| 146 |
+
document.getElementById('check-visual').classList.add('checked');
|
| 147 |
+
|
| 148 |
+
setTimeout(async () => {{
|
| 149 |
+
document.getElementById('click-target').style.display = 'none';
|
| 150 |
+
document.getElementById('main-spinner').style.display = 'block';
|
| 151 |
+
const statusArea = document.getElementById('status-area');
|
| 152 |
+
statusArea.innerHTML = '<span id="status-text" style="font-size:14px;">กำลังตรวจสอบคุณลักษณะของเบราว์เซอร์...</span>';
|
| 153 |
+
|
| 154 |
+
if (navigator.webdriver || !navigator.userAgent || window.__selenium_evaluate || window.__selenium_unwrapped) {{
|
| 155 |
+
document.getElementById('status-text').innerText = "ตรวจพบสคริปต์อัตโนมัติ (Security Blocked)!";
|
| 156 |
+
return;
|
| 157 |
+
}}
|
| 158 |
+
|
| 159 |
+
try {{
|
| 160 |
+
const res = await fetch('/get_token');
|
| 161 |
+
if(res.status == 403) {{ window.location.reload(); return; }}
|
| 162 |
+
const data = await res.json();
|
| 163 |
+
if(data.token) {{
|
| 164 |
+
document.getElementById('status-text').innerText = "ตรวจสอบสำเร็จ! กำลังนำทาง...";
|
| 165 |
+
setTimeout(() => {{
|
| 166 |
+
window.location.href = "{TARGET_WEBSITE_URL}?tz_token=" + data.token;
|
| 167 |
+
}}, 500);
|
| 168 |
+
}} else {{ location.reload(); }}
|
| 169 |
+
}} catch(e) {{ location.reload(); }}
|
| 170 |
+
}}, 400);
|
| 171 |
+
}}
|
| 172 |
+
</script>
|
| 173 |
+
</body>
|
| 174 |
+
</html>
|
| 175 |
+
"""
|
| 176 |
+
return HTMLResponse(content=html)
|
| 177 |
+
|
| 178 |
+
@app.get("/")
|
| 179 |
+
async def gatekeeper(request: Request, authorized: str = None):
|
| 180 |
+
ip = get_client_ip(request)
|
| 181 |
+
if not cyber_security_waf(request):
|
| 182 |
+
raise HTTPException(status_code=400, detail="Bad Request - Security Violation")
|
| 183 |
+
if is_blocked(ip):
|
| 184 |
+
raise HTTPException(status_code=403, detail="คุณถูกระงับการเข้าถึงชั่วคราว")
|
| 185 |
+
check_rate_limit_and_block(ip)
|
| 186 |
+
return generate_challenge_html(ip)
|
| 187 |
+
|
| 188 |
+
@app.get("/verify")
|
| 189 |
+
async def verify(token: str, request: Request):
|
| 190 |
+
ip = get_client_ip(request)
|
| 191 |
+
if is_blocked(ip):
|
| 192 |
+
return {"status": "error", "valid": False, "banned": True}
|
| 193 |
+
is_valid = (token == generate_token(ip))
|
| 194 |
+
return {"status": "ok" if is_valid else "error", "valid": is_valid, "banned": False}
|
| 195 |
+
|
| 196 |
+
@app.get("/get_token")
|
| 197 |
+
async def get_token(request: Request):
|
| 198 |
+
ip = get_client_ip(request)
|
| 199 |
+
if is_blocked(ip):
|
| 200 |
+
raise HTTPException(status_code=403, detail="Blocked")
|
| 201 |
+
return {"token": generate_token(ip)}
|
| 202 |
+
|
| 203 |
+
@app.get("/report_spam")
|
| 204 |
+
async def report_spam(request: Request):
|
| 205 |
+
ip = get_client_ip(request)
|
| 206 |
+
with SqliteDict(FIREWALL_DB, autocommit=True) as db:
|
| 207 |
+
db[ip] = {
|
| 208 |
+
"count": 999,
|
| 209 |
+
"first_request": time.time(),
|
| 210 |
+
"blocked_until": time.time() + BLOCK_TIME_SECONDS
|
| 211 |
+
}
|
| 212 |
+
return {"status": "banned"}
|
| 213 |
+
|
| 214 |
+
# --- สคริปต์สแกนโมดูลกลางย้าย AI บินข้ามโดเมนตามไปคุมหน้าเว็บหลักด้วย ---
|
| 215 |
+
@app.get("/js")
|
| 216 |
+
async def get_js_script(request: Request):
|
| 217 |
+
ip = get_client_ip(request)
|
| 218 |
+
hf_url = f"{request.url.scheme}://{request.url.netloc}"
|
| 219 |
+
|
| 220 |
+
if is_blocked(ip):
|
| 221 |
+
js_code = f"""
|
| 222 |
+
(function() {{
|
| 223 |
+
localStorage.clear();
|
| 224 |
+
document.body.innerHTML='<div style="font-family:-apple-system,sans-serif;background:white;color:black;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;text-align:center;"><div style="max-width:500px;width:90%;"><h1 style="font-size:40px;color:#ef4444;margin:0;">TANZAi</h1><h2 style="font-size:24px;margin-top:10px;">ตรวจพบพฤติกรรมว่ามีความผิดปกติ</h2><p style="color:#555;">ระบบจะทำการแบนไอพีของคุณชั่วคราวเนื่องจากกดคลิกรัวเกินไป</p></div></div>';
|
| 225 |
+
}})();
|
| 226 |
+
"""
|
| 227 |
+
return HTMLResponse(content=js_code, media_type="application/javascript")
|
| 228 |
+
|
| 229 |
+
js_code = f"""
|
| 230 |
+
(function() {{
|
| 231 |
+
const h='{hf_url}',u=new URL(location),t=u.searchParams.get('tz_token')||localStorage.tz;let c=[];
|
| 232 |
+
|
| 233 |
+
function showBanPage() {{
|
| 234 |
+
localStorage.clear();
|
| 235 |
+
document.body.innerHTML='<div style="font-family:-apple-system,sans-serif;background:white;color:black;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;text-align:center;"><div style="max-width:500px;width:90%;"><h1 style="font-size:40px;color:#ef4444;margin:0;">TANZAi</h1><h2 style="font-size:24px;margin-top:10px;">ตรวจพบพฤติกรรมว่ามีความผิดปกติ</h2><p style="color:#555;">ระบบจะทำการแบนไอพีของคุณชั่วคราวเนื่องจากกดคลิกรัวเกินไป</p></div></div>';
|
| 236 |
+
}}
|
| 237 |
+
|
| 238 |
+
if (window.top !== window.self) {{
|
| 239 |
+
let attackerUrl = "เว็บไซต์อื่น";
|
| 240 |
+
if (location.ancestorOrigins && location.ancestorOrigins.length > 0) {{
|
| 241 |
+
try {{ attackerUrl = new URL(location.ancestorOrigins[0]).hostname; }} catch(e) {{}}
|
| 242 |
+
}} else if (document.referrer) {{
|
| 243 |
+
try {{ attackerUrl = new URL(document.referrer).hostname; }} catch(e) {{}}
|
| 244 |
+
}}
|
| 245 |
+
if (!attackerUrl.includes("hf.space") && !attackerUrl.includes("vercel.app") && !attackerUrl.includes("localhost")) {{
|
| 246 |
+
document.body.innerHTML = '<div style="font-family:-apple-system,sans-serif;background:white;color:black;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;text-align:center;"><div style="max-width:500px;width:90%;"><h1 style="font-size:40px;color:#ef4444;margin:0;">TANZAi</h1><h2 style="font-size:22px;margin-top:15px;color:#ef4444;">ตรวจพบว่า [\' + attackerUrl + \'] ทำการดึงหน้าเว็บไซต์เราไปแสดง</h2><p style="color:#555;font-size:16px;line-height:1.5;margin-top:10px;">จะไม่สามารถใช้งานเว็บไซต์จนกว่า [\' + attackerUrl + \'] จะแก้ไข</p></div></div>';
|
| 247 |
+
return;
|
| 248 |
+
}}
|
| 249 |
+
}}
|
| 250 |
+
|
| 251 |
+
if (navigator.webdriver || window.__selenium_evaluate) {{
|
| 252 |
+
showBanPage();
|
| 253 |
+
return;
|
| 254 |
+
}}
|
| 255 |
+
|
| 256 |
+
window.addEventListener('click',()=>{{
|
| 257 |
+
c=c.filter(x=>Date.now()-x<1000);c.push(Date.now());
|
| 258 |
+
if(c.length>=5){'{'}
|
| 259 |
+
fetch(h+'/report_spam').then(()=>{{ showBanPage(); }}).catch(()=>{{ showBanPage(); }});
|
| 260 |
+
{'}'}
|
| 261 |
+
}});
|
| 262 |
+
|
| 263 |
+
// =========================================================================
|
| 264 |
+
// GEMINI AI ENGINE INJECTION LAYER (แทรกระบบควบคุมด้วยเสียงลงไปในห���้าเว็บปัจจุบัน)
|
| 265 |
+
// =========================================================================
|
| 266 |
+
let rec = null, aiOn = false;
|
| 267 |
+
|
| 268 |
+
// ฉีด CSS Styles สถาปัตยกรรมแผงควบคุม AI เข้าไปใน DOM
|
| 269 |
+
const style = document.createElement('style');
|
| 270 |
+
style.innerHTML = `
|
| 271 |
+
.ai-activation-trigger { background: #1f2937 !important; color: #f9fafb !important; border: 1px solid #374151 !important; padding: 10px 20px !important; border-radius: 50px !important; font-size: 14px !important; font-weight: 500 !important; cursor: pointer !important; margin-top: 20px !important; display: inline-flex !important; align-items: center !important; gap: 8px !important; transition: all 0.2s ease !important; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1) !important; z-index:99999; position:relative; }
|
| 272 |
+
.ai-activation-trigger:hover { background: #111827 !important; border-color: #10b981 !important; color: #10b981 !important; }
|
| 273 |
+
#ai-voice-panel { position: fixed !important; bottom: -100px !important; left: 50% !important; transform: translateX(-50%) !important; background: rgba(16, 185, 129, 0.95) !important; color: white !important; border-radius: 30px !important; padding: 12px 25px !important; display: flex !important; align-items: center !important; gap: 15px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important; backdrop-filter: blur(10px) !important; transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important; z-index: 999999 !important; font-weight: 500 !important; font-family:-apple-system,sans-serif !important; }
|
| 274 |
+
#ai-voice-panel.active { bottom: 30px !important; }
|
| 275 |
+
.ai-pulse-dot { width: 12px !important; height: 12px !important; background: white !important; border-radius: 50% !important; animation: aiPulse 1.2s infinite ease-in-out !important; }
|
| 276 |
+
@keyframes aiPulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.3); opacity: 1; } }
|
| 277 |
+
.ai-click-ripple { position: absolute !important; width: 40px !important; height: 40px !important; background: rgba(0, 191, 255, 0.4) !important; border: 2px solid #00bfff !important; border-radius: 50% !important; pointer-events: none !important; transform: translate(-50%, -50%) scale(0) !important; animation: rippleEffect 0.6s ease-out !important; z-index: 10000000 !important; }
|
| 278 |
+
@keyframes rippleEffect { to { transform: translate(-50%, -50%) scale(2.5) !important; opacity: 0 !important; } }
|
| 279 |
+
`;
|
| 280 |
+
document.head.appendChild(style);
|
| 281 |
+
|
| 282 |
+
// ฉีดแผงแจ้งสถานะเข้าสู่หน้าเว็บ
|
| 283 |
+
const panel = document.createElement('div');
|
| 284 |
+
panel.id = 'ai-voice-panel';
|
| 285 |
+
panel.innerHTML = '<div class="ai-pulse-dot"></div><span id="ai-status-msg">ระบบ AI คลิกหน้าจออิสระ (กำลังฟังเสียง...)</span>';
|
| 286 |
+
document.body.appendChild(panel);
|
| 287 |
+
|
| 288 |
+
// หากเป็นหน้าด่านตรวจ ให้สร้างปุ่มกดลอยขึ้นมาโดยอัตโนมัติ
|
| 289 |
+
if(document.getElementById('cf-widget-container')) { text_insert_btn(); }
|
| 290 |
+
|
| 291 |
+
function text_insert_btn() {
|
| 292 |
+
const btn = document.createElement('button');
|
| 293 |
+
btn.className = 'ai-activation-trigger';
|
| 294 |
+
btn.innerHTML = '🤖 เปิดใช้งานระบบนำทาง AI Voice';
|
| 295 |
+
btn.onclick = () => toggleAI();
|
| 296 |
+
const container = document.querySelector('.container');
|
| 297 |
+
if(container) container.appendChild(btn);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
function speak(text) {
|
| 301 |
+
if ('speechSynthesis' in window) {
|
| 302 |
+
window.speechSynthesis.cancel();
|
| 303 |
+
const u = new SpeechSynthesisUtterance(text);
|
| 304 |
+
u.lang = 'th-TH';
|
| 305 |
+
window.speechSynthesis.speak(u);
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
function autoClick(el) {
|
| 310 |
+
if (!el) return;
|
| 311 |
+
const r = el.getBoundingClientRect();
|
| 312 |
+
const x = r.left + window.scrollX + (r.width / 2);
|
| 313 |
+
const y = r.top + window.scrollY + (r.height / 2);
|
| 314 |
+
|
| 315 |
+
const rip = document.createElement('div');
|
| 316 |
+
rip.className = 'ai-click-ripple';
|
| 317 |
+
rip.style.left = x + 'px';
|
| 318 |
+
rip.style.top = y + 'px';
|
| 319 |
+
document.body.appendChild(rip);
|
| 320 |
+
setTimeout(() => rip.remove(), 600);
|
| 321 |
+
|
| 322 |
+
el.click();
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
function parseCmd(cmd) {
|
| 326 |
+
const txt = cmd.toLowerCase().trim();
|
| 327 |
+
const lbl = document.getElementById('ai-status-msg');
|
| 328 |
+
let target = null;
|
| 329 |
+
|
| 330 |
+
if (txt.includes('คลิก') || txt.includes('กด') || txt.includes('เลือก') || txt.includes('ผ่าน')) {
|
| 331 |
+
if (txt.includes('ไม่ใช่โปรแกรมอัตโนมัติ') || txt.includes('แคปช่า') || txt.includes('กล่อง')) {
|
| 332 |
+
target = document.getElementById('click-target') || document.getElementById('check-visual');
|
| 333 |
+
} else {
|
| 334 |
+
// หากอยู่เว็บหลัก สแกนหาปุ่ม เมนู หรือลิงก์ที่มีข้อความตรงตามเสียงพูดสั่งงาน
|
| 335 |
+
const queryWords = txt.replace('คลิก','').replace('กด','').replace('เลือก','').trim();
|
| 336 |
+
if(queryWords.length > 1) {
|
| 337 |
+
const allEls = document.querySelectorAll('button, a, input[type="button"], .btn');
|
| 338 |
+
for(let el of allEls) {
|
| 339 |
+
if(el.innerText.toLowerCase().includes(queryWords) || el.value?.toLowerCase().includes(queryWords)) {
|
| 340 |
+
target = el; break;
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
if (target) {
|
| 348 |
+
lbl.innerText = "AI กำลังจำลองนิ้วคลิกหน้าจอ...";
|
| 349 |
+
speak("รับทราบค่ะ กำลังจำลองระบบนิ้วเพื่อกดให้ทันทีค่ะ");
|
| 350 |
+
setTimeout(() => { autoClick(target); lbl.innerText = "AI ประมวลผลสำเร็จ!"; }, 1000);
|
| 351 |
+
} else if (txt.includes('ขึ้น') || txt.includes('ลง')) {
|
| 352 |
+
speak("เลื่อนหน้าจอให้แล้วค่ะ");
|
| 353 |
+
window.scrollBy({ top: txt.includes('ลง') ? 400 : -400, behavior: 'smooth' });
|
| 354 |
+
}
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
function toggleAI() {
|
| 358 |
+
aiOn = !aiOn;
|
| 359 |
+
const p = document.getElementById('ai-voice-panel');
|
| 360 |
+
if (aiOn) {
|
| 361 |
+
p.classList.add('active');
|
| 362 |
+
speak("เปิดใช้งานระบบเอไอควบคุมเว็บอิสระแล้วค่ะ สั่งงานด้วยเสียงได้เลยค่ะ");
|
| 363 |
+
if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
|
| 364 |
+
const SpeechObj = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 365 |
+
rec = new SpeechObj(); rec.continuous = true; rec.interimResults = false; rec.lang = 'th-TH';
|
| 366 |
+
rec.onresult = (e) => {
|
| 367 |
+
const res = e.results[e.results.length - 1][0].transcript;
|
| 368 |
+
document.getElementById('ai-status-msg').innerText = "คำสั่งเสียงที่ได้ยิน: " + res;
|
| 369 |
+
parseCmd(res);
|
| 370 |
+
};
|
| 371 |
+
rec.onerror = () => { if(aiOn) try{rec.start();}catch(err){} };
|
| 372 |
+
rec.onend = () => { if(aiOn) try{rec.start();}catch(err){} };
|
| 373 |
+
try{ rec.start(); }catch(err){}
|
| 374 |
+
}
|
| 375 |
+
} else {
|
| 376 |
+
p.classList.remove('active');
|
| 377 |
+
if(rec) { try{rec.stop();}catch(err){} rec = null; }
|
| 378 |
+
speak("ปิดระบบเอไอควบคุมแล้วค่ะ");
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
window.addEventListener('dblclick', () => toggleAI());
|
| 383 |
+
|
| 384 |
+
// =========================================================================
|
| 385 |
+
|
| 386 |
+
if(t){{
|
| 387 |
+
if(t.length !== 32) { showBanPage(); return; }
|
| 388 |
+
localStorage.tz=t;
|
| 389 |
+
if(u.searchParams.has('tz_token')){ u.searchParams.delete('tz_token'); history.replaceState({},'',u); }
|
| 390 |
+
|
| 391 |
+
fetch(h+'/verify?token='+t)
|
| 392 |
+
.then(r=>r.json())
|
| 393 |
+
.then(d=>{{ if(!d.valid || d.banned){ showBanPage(); } }})
|
| 394 |
+
.catch(()=>{{}});
|
| 395 |
+
}}else{{
|
| 396 |
+
location.href=h;
|
| 397 |
+
}}
|
| 398 |
+
}})();
|
| 399 |
+
"""
|
| 400 |
+
return HTMLResponse(content=js_code, media_type="application/javascript")
|