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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GOST 服务监控</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<style>
:root {
--primary-color: #4285f4;
--success-color: #34a853;
--error-color: #ea4335;
--bg-color: #f8f9fa;
--card-bg: #ffffff;
--text-color: #202124;
}

body {
font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
margin: 0;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
}

.container {
max-width: 800px;
width: 100%;
margin: 0 auto;
}

.header {
text-align: center;
margin-bottom: 30px;
}

.card {
background-color: var(--card-bg);
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 25px;
margin-bottom: 20px;
}

.status-card {
display: flex;
flex-direction: column;
margin-bottom: 20px;
}

.status {
display: flex;
align-items: center;
justify-content: space-between;
}

.status-indicator {
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 10px;
}

.status-indicator.active {
background-color: var(--success-color);
animation: pulse 2s infinite;
}

.status-indicator.inactive {
background-color: var(--error-color);
}

.latency {
font-size: 1.2em;
font-weight: 500;
}

.latency-value {
color: var(--primary-color);
font-weight: bold;
}

.content-card {
min-height: 200px;
margin-top: 20px;
}

.url {
color: var(--primary-color);
font-weight: 500;
word-break: break-all;
}

.refresh-info {
color: #5f6368;
font-size: 0.9em;
margin-top: 20px;
text-align: center;
}

@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}

h1 {
color: var(--primary-color);
margin-bottom: 10px;
}

.timestamp {
color: #5f6368;
font-size: 0.9em;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>GOST 服务监控</h1>
</div>

<div id="status-cards"></div>

<div class="refresh-info">
页面每4分钟自动刷新内容 | 最后更新: <span id="last-update"></span>
</div>
</div>

<script>
const urls = [
'https://gost-web.glitch.me',
'https://new-gost.glitch.me'
];

function createStatusCard(url) {
const card = document.createElement('div');
card.className = 'card status-card';
card.innerHTML = `
<div class="status">
<div class="status-indicator" id="status-indicator-${url}"></div>
<div>
<div>服务状态: <span id="status-text-${url}">检测中...</span></div>
<div class="timestamp" id="timestamp-${url}"></div>
</div>
<div class="latency">
延迟: <span class="latency-value" id="latency-value-${url}">-</span> ms
</div>
</div>
<div class="content-card">
<div>监控地址: <span class="url">${url}</span></div>
<div id="content-${url}" style="margin-top: 20px;"></div>
</div>
`;
document.getElementById('status-cards').appendChild(card);
}

function fetchContent(url) {
const startTime = performance.now();
const timestamp = new Date().toLocaleString();

document.getElementById(`status-text-${url}`).textContent = '连接中...';
document.getElementById(`status-indicator-${url}`).className = 'status-indicator';
document.getElementById(`timestamp-${url}`).textContent = timestamp;
document.getElementById('last-update').textContent = timestamp;

fetch(url)
.then(response => {
if (!response.ok) throw new Error('网络响应不正常');
return response.text();
})
.then(data => {
const endTime = performance.now();
const delayTime = (endTime - startTime).toFixed(2);

// 更新状态显示
document.getElementById(`status-indicator-${url}`).className = 'status-indicator active';
document.getElementById(`status-text-${url}`).textContent = '运行正常';
document.getElementById(`latency-value-${url}`).textContent = delayTime;
document.getElementById(`content-${url}`).innerHTML = data;
})
.catch(error => {
console.error('请求失败:', error);
document.getElementById(`status-indicator-${url}`).className = 'status-indicator inactive';
document.getElementById(`status-text-${url}`).textContent = '连接失败';
document.getElementById(`latency-value-${url}`).textContent = '-';
document.getElementById(`content-${url}`).innerHTML = '无法获取内容: ' + error.message;
})
.finally(() => {
// 每隔4分钟(240000毫秒)重新加载内容
setTimeout(() => fetchContent(url), 240000);
});
}

window.onload = () => {
urls.forEach(url => {
createStatusCard(url);
fetchContent(url);
});
};
</script>
</body>
</html>