-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdupechecksingle.html
More file actions
388 lines (356 loc) · 16 KB
/
dupechecksingle.html
File metadata and controls
388 lines (356 loc) · 16 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Mario Kart Wii – PID Duplicate Checker</title>
<style>
:root {
--bg: #0b0f14; --panel:#121822; --muted:#8aa0b6; --text:#e6eef8; --accent:#4cc3ff; --warn:#ff6b6b;
--ok:#2ecc71; --border:#1b2430; --chip:#1a2533; --shadow:0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin:0; font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
color: var(--text); background: radial-gradient(1400px 1400px at 10% -10%, #152033 0%, #0b0f14 60%) fixed, #0b0f14;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 1400px 1400px, auto;
}
header { padding: 20px 24px; position: sticky; top:0; background: linear-gradient(180deg, rgba(11,15,20,.95), rgba(11,15,20,.85)); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); z-index: 3; }
h1 { margin: 0; font-weight: 700; letter-spacing: .3px; font-size: 18px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
main { max-width: 1100px; margin: 24px auto; padding: 0 20px 40px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.card .hd { display:flex; align-items:center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card .hd h2 { margin:0; font-size: 14px; letter-spacing:.2px; }
.card .bd { padding: 14px 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.files { border: 1px dashed #29405c; background: #0e141e; padding: 14px; border-radius: 12px; }
input[type="file"] { color: var(--muted); }
button { appearance: none; border:1px solid var(--border); background: linear-gradient(180deg, #1a2533, #141c28); color: var(--text); padding: 10px 14px; border-radius: 10px; cursor: pointer; transition: transform .04s ease; font-weight:600; }
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
.btn-quiet { background: #0f1622; }
.btn-warn { background: #2a0f14; border-color: #3a141c; color: #ffb4b4; }
.stat { display:inline-flex; gap:8px; align-items:center; padding:6px 10px; background: var(--chip); border:1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; }
.grid { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: #111824; z-index: 2; font-size:12px; color: #a0b5cc; text-transform: uppercase; letter-spacing: .06em; }
tr:hover td { background: #0e1622; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.pill { display:inline-block; padding:2px 8px; border-radius:999px; border:1px solid var(--border); background:#0e1622; font-size:12px; }
.warn { color: #ffc9c9; }
.ok { color: #a6f3c6; }
.row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
details > summary { cursor: pointer; }
.footer { color: var(--muted); font-size: 12px; padding: 14px 16px; border-top: 1px solid var(--border); background: #0f1520; }
</style>
</head>
<body>
<header>
<h1>Lunacy in License Land – Duplicate Pseudo/Authentic Player ID Checker <span class="mono">(RKP version)</span></h1>
<div class="sub">Client-side. No dependencies. Reads multiple <span class="mono">*.rkp</span> license files and flags duplicate PID pairs across licenses & uploads.</div>
</header>
<main>
<div class="card">
<div class="hd"><h2>Upload save files</h2></div>
<div class="bd">
<div class="controls">
<label class="files">
<input id="fileInput" type="file" multiple accept=".rkp" />
</label>
<button id="scanBtn">Scan for duplicates</button>
<button id="clearBtn" class="btn-quiet">Clear</button>
<span class="stat" id="fileCount">No files loaded</span>
<label class="stat"><input id="ignoreZeros" type="checkbox" checked> Ignore (0,0) pairs</label>
</div>
</div>
</div>
<div class="card" id="dupesCard" style="display:none">
<div class="hd">
<h2>Duplicate PID pairs</h2>
<div class="row">
<span class="stat"><span id="dupeCount">0</span> groups</span>
<details><summary class="pill">How duplicates are defined</summary>
<div class="muted" style="margin-top:8px">A duplicate is when both the <em>Pseudo Player ID</em> and <em>Authentic Player ID</em> are exactly equal between two or more licenses. Single‑field matches are not reported.</div>
</details>
</div>
</div>
<div class="bd" id="dupesList"></div>
<div class="footer ok" id="noDupesMsg" style="display:none">No duplicate PID pairs found across the uploaded files. Nice!</div>
</div>
<div class="card" id="resultsCard" style="display:none">
<div class="hd"><h2>Licenses parsed</h2><span class="stat"><span id="licenseCount">0</span> licenses</span></div>
<div class="bd grid">
<table id="licenseTable">
<thead>
<tr>
<th>#</th>
<th>Upload</th>
<th>File</th>
<th>License</th>
<th>RKPD @</th>
<th>Pseudo Player ID</th>
<th>Authentic Player ID</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="footer">Numbers are parsed as big‑endian 32‑bit unsigned integers from each RKP license's DWC block.</div>
</div>
</main>
<script>
(function(){
// RKP-only parser (single license per file)
const LICENSE_SIZE = 0x8CC0; // bytes
const DWC_OFFSET = 0x40; // within license
const PSEUDO_PLAYER_ID_OFF = 0x0C; // relative to DWC block
const AUTH_PLAYER_ID_OFF = 0x18; // relative to DWC block
function $(id){ return document.getElementById(id); }
const fileInput = $("fileInput");
const fileCount = $("fileCount");
const scanBtn = $("scanBtn");
const clearBtn = $("clearBtn");
const ignoreZeros = $("ignoreZeros");
const licenseTableBody = document.querySelector('#licenseTable tbody');
const licenseCount = $("licenseCount");
const resultsCard = $("resultsCard");
const dupesCard = $("dupesCard");
const dupesList = $("dupesList");
const dupeCount = $("dupeCount");
const noDupesMsg = $("noDupesMsg");
let selectedFiles = [];
fileInput.addEventListener('change', function(){
selectedFiles = Array.from(fileInput.files || []);
if (selectedFiles.length) {
fileCount.textContent = String(selectedFiles.length) + ' file' + (selectedFiles.length>1?'s':'') + ' ready';
} else {
fileCount.textContent = 'No files loaded';
}
});
clearBtn.addEventListener('click', function(){
fileInput.value = '';
selectedFiles = [];
fileCount.textContent = 'No files loaded';
resultsCard.style.display = 'none';
dupesCard.style.display = 'none';
licenseTableBody.innerHTML = '';
dupesList.innerHTML = '';
});
scanBtn.addEventListener('click', async function(){
if (!selectedFiles.length) { alert('Choose one or more RKP license files first.'); return; }
const parsed = await parseAll(selectedFiles);
renderLicenses(parsed.entries);
renderDupes(parsed.entries);
});
async function parseAll(files){
const entries = [];
let uploadIdx = 0;
for (const f of files){
uploadIdx++;
const buf = new Uint8Array(await f.arrayBuffer());
const view = new DataView(buf.buffer);
const filename = f.name;
// Require RKPD magic at 0x00
if (buf.length < 4) continue;
const magic = String.fromCharCode(buf[0]) + String.fromCharCode(buf[1]) + String.fromCharCode(buf[2]) + String.fromCharCode(buf[3]);
if (magic !== 'RKPD') continue;
const base = 0; // RKP is a single license starting at 0
const ppid = view.getUint32(base + DWC_OFFSET + PSEUDO_PLAYER_ID_OFF, false);
const apid = view.getUint32(base + DWC_OFFSET + AUTH_PLAYER_ID_OFF, false);
const ignored = !!(ignoreZeros.checked && ppid===0 && apid===0);
entries.push({ uploadIdx: uploadIdx, filename: filename, licenseKind: 'RKP', baseOff: base, ppid: ppid, apid: apid, ignored: ignored });
}
return { entries: entries };
}
function renderLicenses(entries){
resultsCard.style.display = '';
licenseTableBody.innerHTML = '';
let idx = 0;
for (const e of entries){
idx++;
const tr = document.createElement('tr');
const tdIdx = document.createElement('td'); tdIdx.className = 'mono muted'; tdIdx.textContent = String(idx); tr.appendChild(tdIdx);
const tdUp = document.createElement('td'); tdUp.innerHTML = '<span class="pill">Upload ' + e.uploadIdx + '</span>'; tr.appendChild(tdUp);
const tdFile = document.createElement('td'); tdFile.className = 'mono'; tdFile.textContent = e.filename; tr.appendChild(tdFile);
const tdLic = document.createElement('td'); tdLic.textContent = e.licenseKind; tr.appendChild(tdLic);
const tdOff = document.createElement('td'); tdOff.className = 'mono muted'; tdOff.textContent = '0x' + e.baseOff.toString(16).toUpperCase(); tr.appendChild(tdOff);
const tdP = document.createElement('td'); tdP.className = 'mono'; tdP.textContent = String(e.ppid); tr.appendChild(tdP);
const tdA = document.createElement('td'); tdA.className = 'mono'; tdA.textContent = String(e.apid); tr.appendChild(tdA);
licenseTableBody.appendChild(tr);
}
licenseCount.textContent = String(entries.length);
}
function renderDupes(entries){
dupesCard.style.display = '';
dupesList.innerHTML = '';
const valid = entries.filter(function(e){ return !e.ignored; });
// exact duplicates (PPID + APID)
const exactMap = new Map();
for (const e of valid){
const key = String(e.ppid) + '|' + String(e.apid);
if (!exactMap.has(key)) exactMap.set(key, []);
exactMap.get(key).push(e);
}
const exactGroups = [];
for (const kv of exactMap.entries()){
const arr = kv[1];
if (arr.length >= 2) exactGroups.push({ key: kv[0], arr: arr });
}
exactGroups.sort(function(a,b){ return b.arr.length - a.arr.length; });
dupeCount.textContent = String(exactGroups.length);
// same APID different PPID
const apidMap = new Map();
for (const e of valid){
const key = String(e.apid);
if (!apidMap.has(key)) apidMap.set(key, []);
apidMap.get(key).push(e);
}
const sameAuthGroups = [];
for (const kv of apidMap.entries()){
const apid = kv[0];
const arr = kv[1];
if (arr.length < 2) continue;
const setP = new Set(arr.map(function(x){ return x.ppid; }));
if (setP.size >= 2) sameAuthGroups.push({ apid: apid, arr: arr, distinctCount: setP.size });
}
sameAuthGroups.sort(function(a,b){ return b.arr.length - a.arr.length; });
// same PPID different APID
const ppidMap = new Map();
for (const e of valid){
const key = String(e.ppid);
if (!ppidMap.has(key)) ppidMap.set(key, []);
ppidMap.get(key).push(e);
}
const samePseudoGroups = [];
for (const kv of ppidMap.entries()){
const ppid = kv[0];
const arr = kv[1];
if (arr.length < 2) continue;
const setA = new Set(arr.map(function(x){ return x.apid; }));
if (setA.size >= 2) samePseudoGroups.push({ ppid: ppid, arr: arr, distinctCount: setA.size });
}
samePseudoGroups.sort(function(a,b){ return b.arr.length - a.arr.length; });
const anyGroups = exactGroups.length + sameAuthGroups.length + samePseudoGroups.length;
if (!anyGroups){
noDupesMsg.style.display = '';
return;
}
noDupesMsg.style.display = 'none';
// helpers
function sectionHeader(label, count){
const h = document.createElement('div');
h.className = 'bd muted';
h.style.marginTop = '6px';
const pill = document.createElement('div');
pill.className = 'pill';
pill.innerHTML = label + ': <b>' + count + '</b> group' + (count===1?'':'s');
h.appendChild(pill);
return h;
}
function makeCard(title, chips, arr){
const div = document.createElement('div');
div.className = 'card';
div.style.margin = '8px 0';
const head = document.createElement('div');
head.className = 'hd';
const h2 = document.createElement('h2');
h2.className = 'warn';
h2.textContent = title;
head.appendChild(h2);
const body = document.createElement('div');
body.className = 'bd';
const row = document.createElement('div');
row.className = 'row';
row.style.marginBottom = '8px';
for (const chip of chips){
const s = document.createElement('span');
s.className = chip.mono ? 'pill mono' : 'pill';
s.textContent = chip.text;
row.appendChild(s);
}
const list = document.createElement('div');
for (let i=0; i<arr.length; i++){
const e = arr[i];
const item = document.createElement('span');
const fileSpan = document.createElement('span'); fileSpan.className = 'mono'; fileSpan.textContent = e.filename; item.appendChild(fileSpan);
const up = document.createElement('span'); up.className = 'muted'; up.textContent = ' (Upload ' + e.uploadIdx + ')'; item.appendChild(document.createTextNode(' ')); item.appendChild(up);
// RKP: no license index to display
// separator
list.appendChild(item);
if (i !== arr.length - 1){
const sep = document.createElement('span'); sep.className = 'muted'; sep.textContent = ' • ';
list.appendChild(document.createTextNode(' '));
list.appendChild(sep);
list.appendChild(document.createTextNode(' '));
}
}
body.appendChild(row);
body.appendChild(list);
div.appendChild(head);
div.appendChild(body);
return div;
}
// render sections
if (exactGroups.length){
dupesList.appendChild(sectionHeader('Exact duplicates (both IDs match)', exactGroups.length));
for (const g of exactGroups){
const parts = g.key.split('|');
const ppid = parts[0];
const apid = parts[1];
dupesList.appendChild(
makeCard(
'Duplicate Pseudo & Authentic Player ID pair',
[
{text: 'Pseudo Player ID = ' + ppid, mono: true},
{text: 'Authentic Player ID = ' + apid, mono: true},
{text: String(g.arr.length) + ' occurrences', mono: false}
],
g.arr
)
);
}
}
if (sameAuthGroups.length){
dupesList.appendChild(sectionHeader('Same Authentic Player ID (different Pseudo)', sameAuthGroups.length));
for (const g of sameAuthGroups){
dupesList.appendChild(
makeCard(
'Shared Authentic Player ID across different licenses',
[
{text: 'Authentic Player ID = ' + g.apid, mono: true},
{text: String(g.arr.length) + ' occurrences', mono: false},
{text: String(g.distinctCount) + ' distinct Pseudo IDs', mono: false}
],
g.arr
)
);
}
}
if (samePseudoGroups.length){
dupesList.appendChild(sectionHeader('Same Pseudo Player ID (different Authentic)', samePseudoGroups.length));
for (const g of samePseudoGroups){
dupesList.appendChild(
makeCard(
'Shared Pseudo Player ID across different licenses',
[
{text: 'Pseudo Player ID = ' + g.ppid, mono: true},
{text: String(g.arr.length) + ' occurrences', mono: false},
{text: String(g.distinctCount) + ' distinct Authentic IDs', mono: false}
],
g.arr
)
);
}
}
}
})();
</script>
</body>
</html>