-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
299 lines (264 loc) · 12.2 KB
/
index.html
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scroll积分批量查询</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
<style>
body {
background-color: #f8f9fa;
}
.container {
max-width: 1000px;
margin-top: 50px;
padding: 30px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
margin-bottom: 20px;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
.info {
margin-bottom: 30px;
}
textarea {
width: 100%;
height: 200px;
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ced4da;
border-radius: 5px;
resize: vertical;
}
button {
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
#result {
margin-top: 30px;
}
.summary {
font-size: 18px;
font-weight: bold;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>Scroll积分批量查询</h1>
<div class="info">
<p><a href="points-s2.html" target="_blank">第2季积分查询入口</a></p>
<p>支持Scroll两种不同的查询模式,更快更安全!</p>
<p>前后端源代码已开源,任何人都可以自己部署:<a href="https://github.com/lyen1688/Scroll" target="_blank">github</a></p>
<p>重要提示:我们不会收集任何用户信息,更不会去举报女巫。你可以不用,但别诋毁。</p>
<p><a href="https://ybot.io" target="_blank">Runes符文批量铸造:ybot.io <i class="bi bi-box-arrow-up-right"></i></a>(全网铸造成本最低,支持无限加速!)</p>
</div>
<div class="mb-3">
<textarea class="form-control" placeholder="输入地址列表,每行一个地址" id="address-input"></textarea>
</div>
<div class="mb-3">
<label class="form-label bold-label mb-2">查询方式:</label>
<div class="form-check mb-2">
<input class="form-check-input" type="radio" name="addressType" id="localQuery" value="local" checked>
<label class="form-check-label" for="localQuery">
本地查询:直连官方API接口,不经过其他任何服务器!你的IP地址对官方可见!
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="addressType" id="proxyQuery" value="proxy">
<label class="form-check-label" for="proxyQuery">
代理查询:通过统一的代理服务器查询,上百万地址都同一个IP!你的IP地址官方不可见!
</label>
</div>
</div>
<div class="d-grid">
<button class="btn btn-primary" type="button" id="query-btn">
<i class="bi bi-search"></i> 批量查询
</button>
</div>
<div id="result"></div>
<p class="author-info">
by:老叶1999.eth 作者推特:<a href="https://twitter.com/1999_eth" target="_blank">https://twitter.com/1999_eth</a>
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const addressInput = document.getElementById('address-input');
const queryBtn = document.getElementById('query-btn');
const resultDiv = document.getElementById('result');
// 初始化累计信息
let totalSummary = {
walletCount: 0,
pointsTotal: 0
};
queryBtn.addEventListener('click', function() {
let addresses = addressInput.value.split('\n').filter(address => address.trim() !== '' && address.startsWith('0x'));
addresses = addresses.map(address => address.toLowerCase());
// 重置累计信息
totalSummary = {
walletCount: addresses.length,
pointsTotal: 0
};
// 清空上一次的结果
resultDiv.innerHTML = '';
// 创建累计余额和导出按钮的容器
let summaryContainer = document.getElementById('total-summary-container');
if (!summaryContainer) {
summaryContainer = document.createElement('div');
summaryContainer.className = 'd-flex justify-content-between align-items-center mb-3 mt-4';
summaryContainer.id = 'total-summary-container';
resultDiv.parentNode.insertBefore(summaryContainer, resultDiv);
} else {
summaryContainer.innerHTML = ''; // 清空之前的内容
}
let totalSummarySpan = document.createElement('span');
totalSummarySpan.id = 'total-summary';
totalSummarySpan.textContent = '正在查询...';
summaryContainer.appendChild(totalSummarySpan);
let resultTable = document.createElement('table');
resultTable.className = 'table table-striped';
resultTable.innerHTML = '<thead><tr><th>编号</th><th>钱包地址</th><th>第1季积分</th><th>最近更新时间</th></thead><tbody>';
addresses.forEach((address, index) => {
let row = resultTable.insertRow(-1);
row.id = 'address-row-' + index;
row.insertCell(0).textContent = index + 1;
row.insertCell(1).textContent = address;
row.insertCell(2).id = 'points-' + index;
row.insertCell(3).id = 'timestamp-' + index;
row.cells[2].textContent = '正在查询...';
row.cells[3].textContent = '正在查询...';
});
resultTable.appendChild(document.createElement('tbody'));
resultDiv.appendChild(resultTable);
const queryType = document.querySelector('input[name="addressType"]:checked').value;
if (queryType === 'local') {
processBatch(addresses, 0, 5); // 并发处理5个地址
} else {
processProxyBatches(addresses, 0, 5); // 通过代理批量处理
}
});
async function processBatch(addresses, startIndex, batchSize) {
const endIndex = Math.min(startIndex + batchSize, addresses.length);
const batch = addresses.slice(startIndex, endIndex);
const requests = batch.map((address, index) => fetchAddressData(address, startIndex + index));
await Promise.all(requests);
if (endIndex < addresses.length) {
processBatch(addresses, endIndex, batchSize);
} else {
updateTotalSummary();
addExportButton();
}
}
async function fetchAddressData(address, index) {
const lowercasedAddress = address.toLowerCase();
try {
// 获取积分和时间戳
const response = await fetch(`https://www.data-openblocklabs.com/scroll/wallet-points?walletAddress=${lowercasedAddress}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const points = parseFloat(data[0].points.toFixed(2));
const timestamp = new Date(data[0].timestamp * 1000).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
document.getElementById('points-' + index).textContent = points;
document.getElementById('timestamp-' + index).textContent = timestamp;
totalSummary.pointsTotal += points;
} catch (error) {
document.getElementById('points-' + index).textContent = 'Error';
document.getElementById('timestamp-' + index).textContent = 'Error';
}
// 实时更新累计信息
updateTotalSummary();
}
async function processProxyBatches(addresses, startIndex, batchSize) {
const endIndex = Math.min(startIndex + batchSize, addresses.length);
const batch = addresses.slice(startIndex, endIndex);
await fetchProxyData(batch, startIndex);
if (endIndex < addresses.length) {
processProxyBatches(addresses, endIndex, batchSize);
} else {
updateTotalSummary();
addExportButton();
}
}
async function fetchProxyData(batch, startIndex) {
try {
const response = await fetch('https://scroll-zldbvooqmg.cn-hangzhou.fcapp.run/getWalletInfo', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ wallet_addresses: batch })
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
data.forEach((result, index) => {
const actualIndex = startIndex + index;
const row = document.getElementById('address-row-' + actualIndex);
if (result.error) {
row.cells[2].textContent = 'Error';
row.cells[3].textContent = 'Error';
} else {
const points = parseFloat(result.points.toFixed(2));
const timestamp = new Date(result.timestamp * 1000).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
row.cells[2].textContent = points;
row.cells[3].textContent = timestamp;
totalSummary.pointsTotal += points;
}
});
updateTotalSummary();
} catch (error) {
console.error('Error:', error);
}
}
function updateTotalSummary() {
document.getElementById('total-summary').innerHTML = `
钱包数量:<span style="color: green;">${totalSummary.walletCount}</span> 个 |
积分累计:<span style="color: green;">${totalSummary.pointsTotal.toFixed(2)}</span> 分`;
}
function addExportButton() {
let exportBtn = document.getElementById('export-btn');
if (!exportBtn) {
exportBtn = document.createElement('button');
exportBtn.className = 'btn btn-secondary';
exportBtn.id = 'export-btn';
exportBtn.textContent = '导出表格';
exportBtn.addEventListener('click', exportToCSV);
document.getElementById('total-summary-container').appendChild(exportBtn);
}
}
function exportToCSV() {
const addresses = addressInput.value.split('\n').filter(address => address.trim() !== '' && address.startsWith('0x'));
let csvContent = "data:text/csv; charset=utf-8," + "编号,钱包地址,积分,最近更新时间\n";
addresses.forEach(function(address, index) {
const points = document.getElementById('points-' + index).textContent;
const timestamp = document.getElementById('timestamp-' + index).textContent;
csvContent += (index + 1) + "," + address + "," + points + "," + timestamp + "\n";
});
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "wallet_points.csv");
document.body.appendChild(link); // Required for FF
link.click();
}
</script>
</body>
</html>