-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathworker.js
87 lines (85 loc) · 2.05 KB
/
worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
export default {
async fetch(request) {
const body = `
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>my ip info</title>
<style>
body {
font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
background-color: #F5F5F5;
color: #333;
}
.container {
margin: 0 auto;
max-width: 800px;
padding: 20px;
}
h1 {
text-align: center;
font-size: 2em;
margin-bottom: 1em;
}
table {
margin: 0 auto;
border-collapse: separate;
border-spacing: 0;
width: 100%;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 10px;
overflow: hidden;
}
table td {
border-top: 1px solid #ddd;
padding: 12px 15px;
text-align: left;
border-right: 1px solid #ddd;
}
table td:last-child {
border-right: 0;
}
@media (max-width: 768px) {
h1 {
font-size: 1.5em;
}
table td {
padding: 8px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>My Ip Info</h1>
<table>
<tr><td>IP</td><td>${request.headers.get("X-Real-IP")}</td></tr>
<tr><td>城市</td><td>${request.cf.city}</td></tr>
<tr><td>国家/地区</td><td>${request.cf.country}</td></tr>
<tr><td>ASN</td><td>${request.cf.asn}</td></tr>
<tr><td>ASN组织</td><td>${request.cf.asOrganization}</td></tr>
<tr><td>数据中心代码</td><td>${request.cf.colo}</td></tr>
<tr><td>HTTP</td><td>${request.cf.httpProtocol}</td></tr>
<tr><td>经度</td><td>${request.cf.longitude}</td></tr>
<tr><td>纬度</td><td>${request.cf.latitude}</td></tr>
<tr><td>邮编</td><td>${request.cf.postalCode}</td></tr>
<tr><td>机器人指数</td><td>${request.cf.botManagement.score}</td></tr>
<tr><td>友好机器人</td><td>${request.cf.botManagement.verifiedBot}</td></tr>
<tr><td>时区</td><td>${request.cf.timezone}</td></tr>
<tr><td>UA</td><td>${request.headers.get("User-Agent")}</td></tr>
</table>
</div>
</body>
</html>
`
const newResponse = new Response(body, {
headers: {
"content-type": "text/html;charset=UTF-8",
},
});
return newResponse;
},
};