-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
424 lines (388 loc) · 19.8 KB
/
script.js
File metadata and controls
424 lines (388 loc) · 19.8 KB
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
document.addEventListener('DOMContentLoaded', function() {
const cardInput = document.getElementById('cardInput');
const resultSection = document.getElementById('resultSection');
// 添加输入事件监听
cardInput.addEventListener('input', function() {
const content = this.value.trim();
if (content) {
const result = parseCardContent(content);
updateDisplay(result);
} else {
// 当输入为空时,重置所有值为 '-' 而不是隐藏结果区域
const emptyResult = {
cardType: '-',
gameType: '-',
accountType: '-',
banStatus: '-',
banTime: '-',
lobbyLevel: '-',
gameAccount: '-',
accountPassword: '-',
accountId: '-',
accountUuid: '-', // 添加 UUID 字段
accessToken: '-', // 添加 AccessToken 字段
bedwarsLevel: '-',
arcadeCoins: '-',
mwCoins: '-',
sbCoins: '-'
};
updateDisplay(emptyResult);
}
});
// 解析卡密内容
// 在 parseCardContent 函数中添加 UUID 字段
function parseCardContent(content) {
const result = {
cardType: '-',
gameType: '-',
accountType: '-',
banStatus: '-',
banTime: '-',
lobbyLevel: '-',
gameAccount: '-',
accountPassword: '-',
accountId: '-',
accountUuid: '-',
accessToken: '-',
bedwarsLevel: '-',
arcadeCoins: '-',
mwCoins: '-',
sbCoins: '-'
};
// 检查是否为Token卡格式
const isTokenCard = content.includes('Minecraft_Name:') && content.includes('Minecraft_UUID:') && content.includes('Accesstoken:');
if (isTokenCard) {
// Token卡格式解析
result.cardType = 'Token卡';
result.gameType = 'Minecraft';
// 解析Minecraft_Name
const minecraftNameMatch = content.match(/Minecraft_Name:([^\s\n]+)/);
if (minecraftNameMatch) {
result.accountId = minecraftNameMatch[1];
}
// 解析Minecraft_UUID
const minecraftUuidMatch = content.match(/Minecraft_UUID:([^\s\n]+)/);
if (minecraftUuidMatch) {
result.accountUuid = minecraftUuidMatch[1];
}
// 解析AccessToken
const accessTokenMatch = content.match(/Accesstoken:([^\s\n]+)/);
if (accessTokenMatch) {
// 如果Token包含管道符分隔的额外信息,只取第一部分
const fullToken = accessTokenMatch[1];
const tokenParts = fullToken.split('|');
result.accessToken = tokenParts[0]; // 只取第一部分作为AccessToken
}
// 解析原版卡密信息(如果存在)
if (content.includes('[Microsoft_Hit]')) {
result.accountType = '微软账户';
}
if (content.includes('[XGP]')) {
result.accountType = 'XGP';
}
if (content.includes('[Banned]')) {
result.banStatus = 'Banned';
// 解析封禁时间
const banTimeMatch = content.match(/BanTime:(\d+)d\s*(\d+)h\s*(\d+)m\s*(\d+)s/);
if (banTimeMatch) {
const [_, days, hours, minutes, seconds] = banTimeMatch;
result.banTime = `${days}天 ${hours}小时 ${minutes}分 ${seconds}秒`;
}
} else if (content.includes('[unban]')) {
result.banStatus = 'Unban';
result.banTime = '-';
} else {
result.banStatus = '未检查封禁状态';
result.banTime = '-';
}
// 解析等级信息
const levelMatch = content.match(/\[(\d+)\]/);
if (levelMatch) result.lobbyLevel = levelMatch[1];
// 解析账号信息
const accountMatch = content.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+):([^:|]+)(?::([^|\s]+))?/);
if (accountMatch) {
result.gameAccount = accountMatch[1];
result.accountPassword = accountMatch[2];
}
// 解析其他信息
const bwMatch = content.match(/BW:(\d+)/);
if (bwMatch) result.bedwarsLevel = bwMatch[1];
const arcadeMatch = content.match(/Arcade:(\d+)/);
if (arcadeMatch) result.arcadeCoins = arcadeMatch[1];
const mwMatch = content.match(/MW_Coins:(\d+)/);
if (mwMatch) result.mwCoins = mwMatch[1];
const sbMatch = content.match(/SB_Coins:(\d+)/);
if (sbMatch) result.sbCoins = sbMatch[1];
// 不直接返回,让后续的updateDisplay函数处理省略逻辑
}
// 原版卡密格式解析
if (content.includes('[Microsoft_Hit]')) result.cardType = '微软账户';
if (content.includes('[MC]')) result.gameType = 'Minecraft';
if (content.includes('[XGP]')) result.accountType = 'XGP';
if (content.includes('[MineCon]')) result.accountType = '含有MineCon披风';
if (content.includes('[SkyBlock]')) result.accountType = 'SkyBlock';
// 添加 NoMcname 和 SetName 处理
if (content.includes('[NoMcname]')) {
result.accountId = 'XGP未设置游戏ID';
} else {
const setNameMatch = content.match(/SetName:([^\s|]+)/);
if (setNameMatch && content.includes('[XGP]')) {
result.accountId = setNameMatch[1] + ' (XGP已设置ID)';
} else {
// 原有的 Name: 格式处理
const nameMatch = content.match(/Name:([^\s]+)/);
if (nameMatch) result.accountId = nameMatch[1];
}
}
// 修改封禁状态判断
if (content.includes('[unban]')) {
result.banStatus = 'Unban';
result.banTime = '-';
result.banStatusNote = '';
} else if (content.includes('[Banned]')) {
result.banStatus = 'Banned';
result.banStatusNote = '';
// 解析封禁时间
const banTimeMatch = content.match(/BanTime:(\d+)d\s*(\d+)h\s*(\d+)m\s*(\d+)s/);
if (banTimeMatch) {
const [_, days, hours, minutes, seconds] = banTimeMatch;
result.banTime = `${days}天 ${hours}小时 ${minutes}分 ${seconds}秒`;
}
} else if (content.includes('[Nobc]') || !content.includes('[unban]') && !content.includes('[Banned]')) {
result.banStatus = '未检查封禁状态';
result.banTime = '-';
result.banStatusNote = '(当然大部分应该是Unban的)';
}
// 解析等级信息
const levelMatch = content.match(/\[(\d+)\]/);
if (levelMatch) result.lobbyLevel = levelMatch[1];
// 解析账号信息 - 修改这部分以支持新格式
const accountMatch = content.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+):([^:|]+)(?::([^|\s]+))?/);
if (accountMatch) {
result.gameAccount = accountMatch[1];
result.accountPassword = accountMatch[2];
// 如果存在第三部分(游戏ID),则使用它
if (accountMatch[3]) {
result.accountId = accountMatch[3];
} else {
// 否则尝试原有的 Name: 格式
const nameMatch = content.match(/Name:([^\s]+)/);
if (nameMatch) result.accountId = nameMatch[1];
}
} else {
// 如果不匹配新格式,尝试原有的 Name: 格式
const nameMatch = content.match(/Name:([^\s]+)/);
if (nameMatch) result.accountId = nameMatch[1];
}
// 解析ID
const nameMatch = content.match(/Name:([^\s]+)/);
if (nameMatch) result.accountId = nameMatch[1];
// 解析其他信息
const bwMatch = content.match(/BW:(\d+)/);
if (bwMatch) result.bedwarsLevel = bwMatch[1];
const arcadeMatch = content.match(/Arcade:(\d+)/);
if (arcadeMatch) result.arcadeCoins = arcadeMatch[1];
const mwMatch = content.match(/MW_Coins:(\d+)/);
if (mwMatch) result.mwCoins = mwMatch[1];
// 添加 SkyBlock 硬币解析
const sbMatch = content.match(/SB_Coins:(\d+)/);
if (sbMatch) result.sbCoins = sbMatch[1];
// 在成功解析到 accountId 后获取 UUID
if (result.accountId !== '-') {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
// 使用自己的代理服务器
fetch(`https://api.milkawa.xyz/api/minecraft/uuid/${result.accountId}`, {
method: 'GET',
headers: {
'Accept': 'application/json'
},
signal: controller.signal
})
.then(async response => {
clearTimeout(timeoutId);
if (response.status === 404) {
throw new Error('player-not-found');
}
if (!response.ok) {
throw new Error('network-error');
}
return response.json();
})
.then(data => {
const uuidElement = document.getElementById('accountUuid');
if (uuidElement && data && data.id) {
uuidElement.textContent = data.id;
uuidElement.classList.remove('uuid-error', 'uuid-not-found');
} else {
throw new Error('invalid-data');
}
})
.catch(error => {
const uuidElement = document.getElementById('accountUuid');
if (uuidElement) {
uuidElement.classList.remove('uuid-error', 'uuid-not-found');
if (error.name === 'AbortError') {
uuidElement.textContent = '请求超时';
} else if (error.message === 'player-not-found') {
uuidElement.textContent = '玩家不存在';
uuidElement.classList.add('uuid-not-found');
} else if (error.message === 'invalid-data') {
uuidElement.textContent = '数据无效';
} else {
console.error('UUID 获取错误:', error);
uuidElement.textContent = '网络错误';
}
uuidElement.classList.add('uuid-error');
}
});
}
return result;
}
// 更新页面显示
function updateDisplay(result) {
for (const [key, value] of Object.entries(result)) {
const element = document.getElementById(key);
if (element) {
if (key === 'banStatus') {
// 清除之前的提示信息
const parentElement = element.parentElement;
const oldNote = parentElement.querySelector('.ban-status-note');
if (oldNote) {
oldNote.remove();
}
element.textContent = value;
element.classList.remove('ban-status-unban', 'ban-status-banned', 'ban-status-nobc');
if (value === 'Unban') {
element.classList.add('ban-status-unban');
} else if (value === 'Banned') {
element.classList.add('ban-status-banned');
} else if (value === '未检查封禁状态') {
element.classList.add('ban-status-nobc');
// 添加提示信息
if (result.banStatusNote) {
const noteSpan = document.createElement('span');
noteSpan.className = 'ban-status-note';
noteSpan.textContent = result.banStatusNote;
element.parentElement.appendChild(noteSpan);
}
}
} else if (key === 'accessToken') {
// 特殊处理AccessToken显示
if (value && value !== '-' && value.length > 50) {
// 显示前20个字符 + ... + 后20个字符
const displayValue = value.substring(0, 20) + '...' + value.substring(value.length - 20);
element.textContent = displayValue;
element.title = value; // 悬停显示完整内容
element.style.cursor = 'help';
} else {
element.textContent = value;
element.title = '';
element.style.cursor = 'default';
}
} else {
element.textContent = value;
}
}
}
resultSection.style.display = 'block';
}
// 复制功能
function setupCopyButtons() {
document.querySelectorAll('.copy-btn').forEach(button => {
button.addEventListener('click', function() {
const section = this.dataset.section;
const singleCopy = this.dataset.copy;
let textToCopy = '';
if (singleCopy) {
// 复制单个值
if (singleCopy === 'accessToken') {
// 对于AccessToken,复制完整内容而不是显示用的省略版本
textToCopy = document.getElementById(singleCopy).title || document.getElementById(singleCopy).textContent;
} else {
textToCopy = document.getElementById(singleCopy).textContent;
}
} else {
// 原有的复制逻辑
switch(section) {
case 'main':
textToCopy = `卡密类型: ${document.getElementById('cardType').textContent}\n` +
`游戏类型: ${document.getElementById('gameType').textContent}\n` +
`账号类型: ${document.getElementById('accountType').textContent}\n` +
`Hypixel封禁情况: ${document.getElementById('banStatus').textContent}\n` +
`封禁剩余时间: ${document.getElementById('banTime').textContent}\n` +
`Hypixel大厅等级: ${document.getElementById('lobbyLevel').textContent}`;
break;
case 'account':
textToCopy = `游戏账号: ${document.getElementById('gameAccount').textContent}\n` +
`账号密码: ${document.getElementById('accountPassword').textContent}\n` +
`账号ID: ${document.getElementById('accountId').textContent}\n` +
`UUID: ${document.getElementById('accountUuid').textContent}\n` +
`AccessToken: ${document.getElementById('accessToken').title || document.getElementById('accessToken').textContent}`;
break;
case 'extra':
textToCopy = `Bedwars等级: ${document.getElementById('bedwarsLevel').textContent}\n` +
`街机硬币: ${document.getElementById('arcadeCoins').textContent}\n` +
`战墙硬币: ${document.getElementById('mwCoins').textContent}\n` +
`SkyBlock硬币: ${document.getElementById('sbCoins').textContent}`;
break;
case 'all':
textToCopy = `卡密类型: ${document.getElementById('cardType').textContent}\n` +
`游戏类型: ${document.getElementById('gameType').textContent}\n` +
`账号类型: ${document.getElementById('accountType').textContent}\n` +
`Hypixel封禁情况: ${document.getElementById('banStatus').textContent}\n` +
`封禁剩余时间: ${document.getElementById('banTime').textContent}\n` +
`Hypixel大厅等级: ${document.getElementById('lobbyLevel').textContent}\n\n` +
`游戏账号: ${document.getElementById('gameAccount').textContent}\n` +
`账号密码: ${document.getElementById('accountPassword').textContent}\n` +
`账号ID: ${document.getElementById('accountId').textContent}\n` +
`UUID: ${document.getElementById('accountUuid').textContent}\n` +
`AccessToken: ${document.getElementById('accessToken').title || document.getElementById('accessToken').textContent}\n\n` +
`Bedwars等级: ${document.getElementById('bedwarsLevel').textContent}\n` +
`街机硬币: ${document.getElementById('arcadeCoins').textContent}\n` +
`战墙硬币: ${document.getElementById('mwCoins').textContent}\n` +
`SkyBlock硬币: ${document.getElementById('sbCoins').textContent}`;
break;
}
}
navigator.clipboard.writeText(textToCopy).then(() => {
button.classList.add('copied');
button.textContent = '已复制';
setTimeout(() => {
button.classList.remove('copied');
if (singleCopy) {
switch(singleCopy) {
case 'gameAccount':
button.textContent = '复制账号';
break;
case 'accountPassword':
button.textContent = '复制密码';
break;
case 'accessToken':
button.textContent = '复制Token';
break;
default:
button.textContent = '复制';
}
} else {
button.textContent = '复制';
}
}, 2000);
});
});
});
}
// 初始化复制按钮
setupCopyButtons();
// 获取最新的 commit ID
fetch('https://api.github.com/repos/Michaelwucoc/account-copier/commits/main')
.then(response => response.json())
.then(data => {
const commitId = document.getElementById('commitId');
commitId.textContent = data.sha.substring(0, 7); // 只显示前6位
})
.catch(error => {
const commitId = document.getElementById('commitId');
commitId.textContent = ''; // 出错时不显示
});
});