-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathsecret-json-generator.html
More file actions
892 lines (816 loc) · 29.2 KB
/
secret-json-generator.html
File metadata and controls
892 lines (816 loc) · 29.2 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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NewAPI.ai Secret Generator</title>
<style>
:root {
/* Palette */
--bg-dark: #020617;
--bg-gradient: radial-gradient(circle at 50% 0%, #1e293b 0%, #020617 100%);
--surface: rgba(15, 23, 42, 0.6);
--surface-hover: rgba(30, 41, 59, 0.8);
--border: rgba(255, 255, 255, 0.08);
--border-focus: rgba(99, 102, 241, 0.5);
--primary: #6366f1;
--primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
--primary-glow: rgba(99, 102, 241, 0.3);
--danger: #ef4444;
--danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
--success: #10b981;
--text-main: #f8fafc;
--text-muted: #94a3b8;
--radius: 12px;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
body {
margin: 0;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: var(--bg-dark);
color: var(--text-main);
line-height: 1.6;
min-height: 100vh;
overflow-x: hidden;
position: relative;
}
/* Animated Background */
.bg-animation {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
z-index: -1;
background: var(--bg-gradient);
overflow: hidden;
}
.bg-animation::before, .bg-animation::after {
content: '';
position: absolute;
width: 600px;
height: 600px;
border-radius: 50%;
filter: blur(80px);
opacity: 0.15;
animation: drift 20s infinite alternate ease-in-out;
}
.bg-animation::before {
background: #4f46e5;
top: -100px;
left: -100px;
}
.bg-animation::after {
background: #06b6d4;
bottom: -100px;
right: -100px;
animation-delay: -10s;
}
@keyframes drift {
0% { transform: translate(0, 0) scale(1); }
100% { transform: translate(50px, 50px) scale(1.1); }
}
/* Layout */
.wrap {
max-width: 900px;
margin: 0 auto;
padding: 40px 20px 80px;
position: relative;
z-index: 1;
}
/* Typography */
h1 {
font-size: 2.25rem;
font-weight: 800;
letter-spacing: -0.025em;
margin: 0 0 8px;
background: linear-gradient(to right, #fff, #94a3b8);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 {
font-size: 1.25rem;
font-weight: 600;
color: var(--text-main);
margin: 0 0 16px;
display: flex;
align-items: center;
gap: 8px;
}
h2::before {
content: '';
display: block;
width: 4px;
height: 1.2em;
background: var(--primary);
border-radius: 2px;
}
p {
color: var(--text-muted);
font-size: 0.95rem;
margin-bottom: 20px;
}
code {
font-family: var(--font-mono);
background: rgba(0,0,0,0.3);
padding: 2px 6px;
border-radius: 4px;
color: #e2e8f0;
font-size: 0.85em;
}
/* Cards */
.card {
background: var(--surface);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 24px;
margin-bottom: 24px;
box-shadow: var(--shadow);
transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
box-shadow: var(--shadow-lg);
border-color: rgba(255,255,255,0.12);
}
/* Header Styles */
.header-section {
text-align: center;
margin-bottom: 40px;
}
.badge {
display: inline-flex;
align-items: center;
padding: 4px 12px;
border-radius: 999px;
background: rgba(16, 185, 129, 0.1);
color: #34d399;
font-size: 0.75rem;
font-weight: 600;
margin-bottom: 16px;
border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge::before {
content: '●';
margin-right: 6px;
font-size: 0.8em;
}
/* Forms */
label {
display: block;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
margin-bottom: 8px;
}
input, select, textarea {
width: 100%;
background: rgba(2, 6, 23, 0.5);
border: 1px solid var(--border);
color: var(--text-main);
padding: 12px 16px;
border-radius: 8px;
font-size: 0.95rem;
transition: all 0.2s;
outline: none;
font-family: inherit;
}
input:focus, select:focus, textarea:focus {
border-color: #6366f1;
box-shadow: 0 0 0 2px var(--primary-glow);
background: rgba(2, 6, 23, 0.8);
}
select {
appearance: none;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
background-position: right 12px center;
background-repeat: no-repeat;
background-size: 20px 20px;
cursor: pointer;
}
textarea {
min-height: 120px;
line-height: 1.5;
}
/* Specific Output Area Styling */
#output {
font-family: var(--font-mono);
font-size: 0.85rem;
background: #0d1117;
border: 1px solid #30363d;
color: #e6edf3;
padding: 16px;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 10px 20px;
border-radius: 8px;
font-weight: 600;
font-size: 0.9rem;
cursor: pointer;
transition: all 0.2s;
border: 1px solid var(--border);
background: rgba(255,255,255,0.03);
color: var(--text-main);
gap: 6px;
}
.btn:hover {
background: rgba(255,255,255,0.08);
transform: translateY(-1px);
}
.btn:active {
transform: translateY(0);
}
.btn.primary {
background: var(--primary-gradient);
border: none;
color: white;
box-shadow: 0 4px 12px var(--primary-glow);
}
.btn.primary:hover {
box-shadow: 0 6px 16px var(--primary-glow);
filter: brightness(1.1);
}
.btn.danger {
background: rgba(239, 68, 68, 0.1);
border-color: rgba(239, 68, 68, 0.3);
color: #fca5a5;
}
.btn.danger:hover {
background: var(--danger-gradient);
color: white;
border-color: transparent;
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
/* Dynamic Grid System from JS */
.grid {
display: grid;
grid-template-columns: repeat(12, 1fr);
gap: 16px;
}
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
/* Dynamic Items */
.item {
background: rgba(0, 0, 0, 0.2);
border: 1px solid var(--border);
border-radius: 8px;
padding: 20px;
margin-bottom: 16px;
position: relative;
}
.item:hover {
border-color: rgba(255,255,255,0.15);
}
/* Action Rows */
.row-actions {
display: flex;
gap: 12px;
margin-top: 20px;
flex-wrap: wrap;
}
/* Status Messages */
.hint {
display: block;
font-size: 0.8rem;
color: var(--text-muted);
margin-top: 8px;
}
.ok {
display: inline-flex;
align-items: center;
color: #34d399;
background: rgba(16, 185, 129, 0.1);
padding: 8px 12px;
border-radius: 6px;
font-size: 0.9rem;
margin-top: 12px;
}
.error {
display: block;
color: #f87171;
background: rgba(239, 68, 68, 0.1);
padding: 12px;
border-radius: 6px;
margin-top: 12px;
font-size: 0.9rem;
white-space: pre-wrap;
border: 1px solid rgba(239, 68, 68, 0.2);
}
/* Step Indicators */
.step-header {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--primary);
font-weight: 700;
margin-bottom: 8px;
display: block;
}
[hidden] { display: none !important; }
/* Responsive */
@media (max-width: 768px) {
.col-3, .col-4, .col-6, .col-8 { grid-column: span 12 !important; }
.wrap { padding: 20px 16px; }
.row-actions { flex-direction: column; }
.btn { width: 100%; }
h1 { font-size: 1.75rem; }
}
</style>
</head>
<body>
<div class="bg-animation"></div>
<div class="wrap">
<!-- Header -->
<header class="header-section">
<div class="badge">本地執行 · 安全加密 · 不上傳資料</div>
<h1>Secret JSON Generator</h1>
<p>為 NewAPI.ai 自動簽到系統產生標準配置檔</p>
</header>
<!-- Step 1: Selection -->
<div class="card">
<span class="step-header">STEP 01 / SELECT TYPE</span>
<h2>選擇 Secret 類型</h2>
<div class="grid">
<div class="col-12">
<label for="generatorType">TARGET SECRET</label>
<select id="generatorType">
<option value="ACCOUNTS">ACCOUNTS (多帳號主配置)</option>
<option value="ACCOUNTS_LINUX_DO">ACCOUNTS_LINUX_DO (Linux.do OAuth)</option>
<option value="ACCOUNTS_GITHUB">ACCOUNTS_GITHUB (GitHub OAuth)</option>
<option value="ACCOUNTS_996">ACCOUNTS_996 (Token 陣列)</option>
<option value="ACCOUNTS_QAQ_AL">ACCOUNTS_QAQ_AL (SID 陣列)</option>
<option value="PROXY">PROXY (代理伺服器)</option>
<option value="PROVIDERS">PROVIDERS (自訂供應商)</option>
</select>
<div class="hint">選擇你需要產生的環境變數名稱,下方表單會自動切換。</div>
</div>
</div>
</div>
<!-- Step 2: Configuration Panels -->
<!-- Note: IDs must match JS exactly -->
<div class="card" id="panel-ACCOUNTS">
<span class="step-header">STEP 02 / CONFIGURE ACCOUNTS</span>
<h2>ACCOUNTS 配置</h2>
<p>新增並配置你的簽到帳號。每筆資料至少需提供 Cookies、Linux.do 或 GitHub 其中一種登入方式。</p>
<div id="accountsList"></div>
<div class="row-actions">
<button class="btn" id="addAccountBtn" type="button">
<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
新增帳號
</button>
</div>
</div>
<div class="card" id="panel-ACCOUNTS_LINUX_DO" hidden>
<span class="step-header">STEP 02 / CONFIGURE OAUTH</span>
<h2>ACCOUNTS_LINUX_DO 配置</h2>
<p>全域 Linux.do 帳號池。格式:<code>[{"username":"...","password":"..."}]</code></p>
<div id="oauthList"></div>
<div class="row-actions">
<button class="btn" id="addOauthBtn" type="button">
<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
新增 OAuth 帳密
</button>
</div>
</div>
<div class="card" id="panel-ACCOUNTS_GITHUB" hidden>
<span class="step-header">STEP 02 / CONFIGURE OAUTH</span>
<h2>ACCOUNTS_GITHUB 配置</h2>
<p>全域 GitHub 帳號池。切換到此項目時,會共用上方的 OAuth 表單內容。</p>
</div>
<div class="card" id="panel-ACCOUNTS_996" hidden>
<span class="step-header">STEP 02 / CONFIGURE TOKENS</span>
<h2>ACCOUNTS_996 配置</h2>
<p>請輸入 Access Token,每行一個。</p>
<textarea id="tokensInput" placeholder="token-1 token-2" style="font-family: var(--font-mono)"></textarea>
</div>
<div class="card" id="panel-ACCOUNTS_QAQ_AL" hidden>
<span class="step-header">STEP 02 / CONFIGURE SIDS</span>
<h2>ACCOUNTS_QAQ_AL 配置</h2>
<p>請輸入 SID,每行一個。</p>
<textarea id="sidsInput" placeholder="sid-1 sid-2" style="font-family: var(--font-mono)"></textarea>
</div>
<div class="card" id="panel-PROXY" hidden>
<span class="step-header">STEP 02 / CONFIGURE PROXY</span>
<h2>PROXY 配置</h2>
<p>適用於 PROXY / PROXY_996 / PROXY_QAQ_AL。若無帳密可只填 Server。</p>
<div class="grid">
<div class="col-12">
<label>Server (必填)</label>
<input id="proxyServer" placeholder="http://proxy.example.com:8080">
</div>
<div class="col-6">
<label>Username (選填)</label>
<input id="proxyUser" placeholder="proxy-user">
</div>
<div class="col-6">
<label>Password (選填)</label>
<input id="proxyPass" placeholder="proxy-password" type="password">
</div>
</div>
</div>
<div class="card" id="panel-PROVIDERS" hidden>
<span class="step-header">STEP 02 / CONFIGURE PROVIDERS</span>
<h2>PROVIDERS (簡化版)</h2>
<p>新增自訂 Provider。至少需填 Provider 名稱 (Key) 與 Origin。</p>
<div id="providersList"></div>
<div class="row-actions">
<button class="btn" id="addProviderBtn" type="button">
<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
新增 Provider
</button>
</div>
</div>
<!-- Step 3: Output -->
<div class="card">
<span class="step-header">STEP 03 / GENERATE & COPY</span>
<h2>產生結果</h2>
<p>將下方產生的 JSON 完整複製,貼到 GitHub Environments Secrets 中。</p>
<div class="row-actions" style="margin-bottom: 20px; margin-top: 0;">
<button class="btn primary" id="generateBtn" type="button">
<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
產生 JSON
</button>
<button class="btn" id="copyBtn" type="button">
<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/></svg>
複製結果
</button>
</div>
<textarea id="output" placeholder="// JSON output will appear here..." spellcheck="false" readonly></textarea>
<div id="status"></div>
<div id="errors" class="error" style="display:none"></div>
<script>
// Observe errors div to toggle visibility
const errorDiv = document.getElementById('errors');
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.target.textContent.trim()) {
mutation.target.style.display = 'block';
} else {
mutation.target.style.display = 'none';
}
});
});
observer.observe(errorDiv, { childList: true, subtree: true, characterData: true });
</script>
</div>
</div>
<!-- ORIGINAL LOGIC PRESERVED 100% -->
<script>
const generatorType = document.getElementById("generatorType");
const output = document.getElementById("output");
const status = document.getElementById("status");
const errors = document.getElementById("errors");
function clearMessages() {
status.textContent = "";
errors.textContent = "";
}
function setPanels(type) {
const panels = [
"ACCOUNTS",
"ACCOUNTS_LINUX_DO",
"ACCOUNTS_GITHUB",
"ACCOUNTS_996",
"ACCOUNTS_QAQ_AL",
"PROXY",
"PROVIDERS"
];
for (const key of panels) {
document.getElementById("panel-" + key).hidden = key !== type;
}
}
function splitLinesToArray(text) {
return text
.split(/\r?\n|,\s*/)
.map(v => v.trim())
.filter(Boolean);
}
function createAccountItem() {
const div = document.createElement("div");
div.className = "item";
div.innerHTML = `
<div class="grid">
<div class="col-4">
<label>name(可選)</label>
<input data-k="name" placeholder="我的帳號">
</div>
<div class="col-4">
<label>provider(可選)</label>
<input data-k="provider" placeholder="anyrouter">
</div>
<div class="col-4">
<label>api_user(cookies 有填時必填)</label>
<input data-k="api_user" placeholder="12345">
</div>
<div class="col-12">
<label>cookies.session(可選)</label>
<input data-k="cookie_session" placeholder="session_value">
</div>
<div class="col-4">
<label>linux.do 模式</label>
<select data-k="linux_mode">
<option value="none">不使用</option>
<option value="global">使用全域(true)</option>
<option value="single">單一帳號</option>
</select>
</div>
<div class="col-4">
<label>linux.do username</label>
<input data-k="linux_user" placeholder="linuxdo-user">
</div>
<div class="col-4">
<label>linux.do password</label>
<input data-k="linux_pass" placeholder="linuxdo-pass">
</div>
<div class="col-4">
<label>github 模式</label>
<select data-k="github_mode">
<option value="none">不使用</option>
<option value="global">使用全域(true)</option>
<option value="single">單一帳號</option>
</select>
</div>
<div class="col-4">
<label>github username</label>
<input data-k="github_user" placeholder="github-user">
</div>
<div class="col-4">
<label>github password</label>
<input data-k="github_pass" placeholder="github-pass">
</div>
<div class="col-6">
<label>proxy.server(可選)</label>
<input data-k="proxy_server" placeholder="http://proxy.example.com:8080">
</div>
<div class="col-6">
<label>額外 JSON 欄位(可選,物件)</label>
<textarea data-k="extra_json" placeholder='{"get_cdk_cookies": {"session": "..."}}'></textarea>
</div>
</div>
<div class="row-actions">
<button class="btn danger" type="button" data-action="remove">移除此帳號</button>
</div>
`;
div.querySelector('[data-action="remove"]').addEventListener("click", () => div.remove());
return div;
}
function createOauthItem() {
const div = document.createElement("div");
div.className = "item";
div.innerHTML = `
<div class="grid">
<div class="col-6">
<label>username</label>
<input data-k="username" placeholder="username">
</div>
<div class="col-6">
<label>password</label>
<input data-k="password" placeholder="password">
</div>
</div>
<div class="row-actions">
<button class="btn danger" type="button" data-action="remove">移除</button>
</div>
`;
div.querySelector('[data-action="remove"]').addEventListener("click", () => div.remove());
return div;
}
function createProviderItem() {
const div = document.createElement("div");
div.className = "item";
div.innerHTML = `
<div class="grid">
<div class="col-4">
<label>provider 名稱(key)</label>
<input data-k="name" placeholder="my_provider">
</div>
<div class="col-8">
<label>origin(必填)</label>
<input data-k="origin" placeholder="https://api.example.com">
</div>
<div class="col-4">
<label>login_path(可選)</label>
<input data-k="login_path" placeholder="/login">
</div>
<div class="col-4">
<label>status_path(可選)</label>
<input data-k="status_path" placeholder="/api/status">
</div>
<div class="col-4">
<label>check_in_path(可選)</label>
<input data-k="check_in_path" placeholder="/api/user/checkin">
</div>
<div class="col-6">
<label>linuxdo_client_id(可選)</label>
<input data-k="linuxdo_client_id" placeholder="client-id">
</div>
<div class="col-6">
<label>github_client_id(可選)</label>
<input data-k="github_client_id" placeholder="client-id">
</div>
</div>
<div class="row-actions">
<button class="btn danger" type="button" data-action="remove">移除</button>
</div>
`;
div.querySelector('[data-action="remove"]').addEventListener("click", () => div.remove());
return div;
}
const accountsList = document.getElementById("accountsList");
const oauthList = document.getElementById("oauthList");
const providersList = document.getElementById("providersList");
document.getElementById("addAccountBtn").addEventListener("click", () => {
accountsList.appendChild(createAccountItem());
});
document.getElementById("addOauthBtn").addEventListener("click", () => {
oauthList.appendChild(createOauthItem());
});
document.getElementById("addProviderBtn").addEventListener("click", () => {
providersList.appendChild(createProviderItem());
});
function parseAccounts() {
const rows = [...accountsList.querySelectorAll(".item")];
if (!rows.length) {
throw new Error("請至少新增 1 筆 ACCOUNTS 設定。");
}
const result = [];
rows.forEach((row, idx) => {
const get = (k) => (row.querySelector(`[data-k="${k}"]`)?.value || "").trim();
const account = {};
const name = get("name");
const provider = get("provider");
const apiUser = get("api_user");
const cookieSession = get("cookie_session");
const linuxMode = get("linux_mode");
const linuxUser = get("linux_user");
const linuxPass = get("linux_pass");
const githubMode = get("github_mode");
const githubUser = get("github_user");
const githubPass = get("github_pass");
const proxyServer = get("proxy_server");
const extraJson = get("extra_json");
if (name) account.name = name;
if (provider) account.provider = provider;
if (cookieSession) {
account.cookies = { session: cookieSession };
if (!apiUser) {
throw new Error(`第 ${idx + 1} 筆:有填 cookies.session 時,api_user 必填。`);
}
}
if (apiUser) account.api_user = apiUser;
if (linuxMode === "global") {
account["linux.do"] = true;
} else if (linuxMode === "single") {
if (!linuxUser || !linuxPass) {
throw new Error(`第 ${idx + 1} 筆:linux.do 選擇單一帳號時,username/password 必填。`);
}
account["linux.do"] = { username: linuxUser, password: linuxPass };
}
if (githubMode === "global") {
account.github = true;
} else if (githubMode === "single") {
if (!githubUser || !githubPass) {
throw new Error(`第 ${idx + 1} 筆:github 選擇單一帳號時,username/password 必填。`);
}
account.github = { username: githubUser, password: githubPass };
}
if (proxyServer) {
account.proxy = { server: proxyServer };
}
const hasAuth = Boolean(account.cookies || account["linux.do"] || account.github);
if (!hasAuth) {
throw new Error(`第 ${idx + 1} 筆:cookies / linux.do / github 至少需要一種。`);
}
if (extraJson) {
let extra;
try {
extra = JSON.parse(extraJson);
} catch (_err) {
throw new Error(`第 ${idx + 1} 筆:額外 JSON 欄位格式錯誤。`);
}
if (!extra || typeof extra !== "object" || Array.isArray(extra)) {
throw new Error(`第 ${idx + 1} 筆:額外 JSON 必須是物件。`);
}
Object.assign(account, extra);
}
result.push(account);
});
return result;
}
function parseOauthList() {
const rows = [...oauthList.querySelectorAll(".item")];
if (!rows.length) {
throw new Error("請至少新增 1 筆 OAuth 帳密。\n可用於 ACCOUNTS_LINUX_DO 或 ACCOUNTS_GITHUB。");
}
return rows.map((row, idx) => {
const username = (row.querySelector('[data-k="username"]')?.value || "").trim();
const password = (row.querySelector('[data-k="password"]')?.value || "").trim();
if (!username || !password) {
throw new Error(`第 ${idx + 1} 筆 OAuth:username/password 皆為必填。`);
}
return { username, password };
});
}
function parseProviders() {
const rows = [...providersList.querySelectorAll(".item")];
if (!rows.length) {
throw new Error("請至少新增 1 筆 provider。");
}
const providers = {};
rows.forEach((row, idx) => {
const get = (k) => (row.querySelector(`[data-k="${k}"]`)?.value || "").trim();
const name = get("name");
const origin = get("origin");
if (!name || !origin) {
throw new Error(`第 ${idx + 1} 筆 provider:名稱與 origin 必填。`);
}
const data = { origin };
const optionalKeys = [
"login_path",
"status_path",
"check_in_path",
"linuxdo_client_id",
"github_client_id"
];
optionalKeys.forEach((k) => {
const v = get(k);
if (v) data[k] = v;
});
providers[name] = data;
});
return providers;
}
function generateByType(type) {
if (type === "ACCOUNTS") return parseAccounts();
if (type === "ACCOUNTS_LINUX_DO" || type === "ACCOUNTS_GITHUB") return parseOauthList();
if (type === "ACCOUNTS_996") {
const arr = splitLinesToArray(document.getElementById("tokensInput").value);
if (!arr.length) throw new Error("請至少輸入 1 個 token。");
return arr;
}
if (type === "ACCOUNTS_QAQ_AL") {
const arr = splitLinesToArray(document.getElementById("sidsInput").value);
if (!arr.length) throw new Error("請至少輸入 1 個 sid。");
return arr;
}
if (type === "PROXY") {
const server = document.getElementById("proxyServer").value.trim();
const username = document.getElementById("proxyUser").value.trim();
const password = document.getElementById("proxyPass").value.trim();
if (!server) throw new Error("proxy.server 為必填。");
const proxy = { server };
if (username) proxy.username = username;
if (password) proxy.password = password;
return proxy;
}
if (type === "PROVIDERS") return parseProviders();
throw new Error("不支援的類型。");
}
document.getElementById("generateBtn").addEventListener("click", () => {
clearMessages();
const type = generatorType.value;
try {
const value = generateByType(type);
output.value = JSON.stringify(value, null, 2);
status.innerHTML = `<span class="ok">✅ 產生完成,對應 secret:<b>${type}</b>(PROXY 類可貼到 PROXY / PROXY_996 / PROXY_QAQ_AL)。</span>`;
} catch (err) {
errors.textContent = err instanceof Error ? err.message : String(err);
}
});
document.getElementById("copyBtn").addEventListener("click", async () => {
clearMessages();
const text = output.value.trim();
if (!text) {
errors.textContent = "請先產生 JSON。";
return;
}
try {
await navigator.clipboard.writeText(text);
status.innerHTML = '<span class="ok">✅ 已複製到剪貼簿。</span>';
} catch (_err) {
output.focus();
output.select();
status.textContent = "無法自動複製,已幫你選取內容,請手動 Ctrl/Cmd+C。";
}
});
generatorType.addEventListener("change", () => {
clearMessages();
setPanels(generatorType.value);
});
accountsList.appendChild(createAccountItem());
oauthList.appendChild(createOauthItem());
providersList.appendChild(createProviderItem());
setPanels(generatorType.value);
</script>
</body>
</html>