-
Notifications
You must be signed in to change notification settings - Fork 4
/
PrechatGPT.user.js
1854 lines (1838 loc) · 63.7 KB
/
PrechatGPT.user.js
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
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name PreChatGPT - ChatGPT批量提问自动化工具
// @description 使用PreChatGPT来自动化您与ChatGPT的对话。支持批量提交问题,并逐个输入到ChatGPT进行询问,以节省时间并提高会话效率。
// @version 3.8
// @author zizhanovo
// @namespace https://github.com/zizhanovo/Pre-ChatGPT
// @supportURL https://github.com/zizhanovo/Pre-ChatGPT
// @license GPL-2.0-only
// @match *://chatgpt.com
// @match *://chatgpt.com/*
// @grant GM_addStyle
// @icon data:image/svg+xml;utf8,%3Csvg t="1706424916374" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16099" width="48" height="48"%3E%3Cpath d="M851.2 172.8C664.32-14.08 359.68-14.08 172.16 172.8c-186.88 186.88-186.88 491.52 0 679.04A483.52 483.52 0 0 0 512 992c122.88 0 245.76-46.72 339.2-140.16 90.88-90.88 140.8-211.2 140.8-339.2 0-128.64-49.92-249.6-140.8-339.84z m-90.24 588.16a352.448 352.448 0 0 1-497.92 0c-136.96-136.96-136.96-360.32 0-497.92a352.448 352.448 0 0 1 497.92 0A349.44 349.44 0 0 1 864 512c0 94.08-36.48 182.4-103.04 248.96z" fill="%23020202" p-id="16100"%3E%3C/path%3E%3Cpath d="M497.28 256c-2.56 0-4.48 1.28-5.76 3.84L348.8 555.52c-1.28 1.92-0.64 4.48 0.64 6.4 0.64 1.28 3.2 2.56 5.12 2.56h101.76l-24.32 196.48c-0.64 3.2 1.28 5.76 3.84 7.04h2.56c1.92 0 3.84-0.64 5.12-2.56l209.92-300.16c1.28-1.92 1.28-4.48 0.64-6.4a6.72 6.72 0 0 0-5.76-3.2h-89.6l115.84-189.44a5.76 5.76 0 0 0 0-6.4c-0.64-2.56-3.2-3.84-5.12-3.84H497.28z" fill="%23020202" p-id="16101"%3E%3C/path%3E%3C/svg%3E
// ==/UserScript==
(function () {
"use strict";
GM_addStyle(`
:root {
--background-color: #fafafa;
--text-color: #333;
--border-color: #ccc;
--hover-background-color: #e6e6e6;
--button-background-color: #5865f2;
--button-hover-background-color: #4752c4;
--shadow-color: rgba(0, 0, 0, 0.1);
--textarea-border-color: #ccc;
--button-text-color: white;
--summary-background-color: #f5f5f5;
--summary-border-color: #e8e8e8;
--summary-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.08);
--input-background-color: rgba(255, 255, 255, 0.8);
--input-border-color: #ccc;
--input-text-color: #333;
--start-button-background-color: #5865f2;
--start-button-hover-background-color: #4752c4;
}
.my-app-night-mode {
--background-color: #1f1f1f;
--text-color: #e0e0e0;
--border-color: #3a3a3a;
--hover-background-color: #2a2a2a;
--button-background-color: #5865f2;
--button-hover-background-color: #4752c4;
--shadow-color: rgba(0, 0, 0, 0.2);
--textarea-border-color: #555;
--button-text-color: #fff;
--summary-background-color: #2a2a2a;
--summary-border-color: #444;
--summary-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
--input-background-color: #242424;
--input-border-color: #555;
--input-text-color: #ddd;
--start-button-background-color: #5865f2;
--start-button-hover-background-color: #4752c4;
--textarea-background-color-night: #242424;
--textarea-text-color-night: #ddd;
}
.my-app-night-mode #questionInput,
.my-app-night-mode #additionalInput {
background-color: var(--textarea-background-color-night);
color: var(--textarea-text-color-night);
border-color: var(--textarea-border-color);
}
.my-app-night-mode .question-text[readonly] {
background-color: var(--textarea-background-color-night);
color: var(--textarea-text-color-night);
}
.my-app-night-mode #toggleSidebar svg,
.my-app-night-mode .delete-button svg {
fill: #757575;
}
.my-app-night-mode #sidebar h2:hover {
color: #b3b3b3;
background-color: var(--hover-background-color);
}
.my-app-night-mode #settingSidebar h2:hover {
color: #b3b3b3;
background-color: var(--hover-background-color);
}
.my-app-night-mode .question button {
background-color: var(--button-background-color-night);
border: 1px solid var(--button-border-color-night);
color: var(--button-text-color-night);
}
.my-app-night-mode .question button:hover {
background-color: var(--button-hover-background-color-night);
border-color: var(--button-hover-border-color-night);
}
.my-app-night-mode .question button:active {
background-color: var(--button-active-background-color-night);
border-color: var(--button-active-border-color-night);
}
.my-app-night-mode .original-icon svg {
fill: #757575;
}
.my-app-night-mode .button-container button {
background-color: #45a049;
color: white;
border: 1px solid #39843c;
}
.my-app-night-mode .button-container button:hover {
background-color: #39843c;
color: #ddd;
}
.my-app-night-mode .summary-action {
display: inline-flex;
align-items: center;
justify-content: center;
background-color: #45a049;
color: white;
border: 1px solid #39843c;
padding: 5px;
border-radius: 4px;
text-decoration: none;
}
.my-app-night-mode .summary-action:hover {
background-color: #39843c;
color: #ddd;
}
.my-app-night-mode .summary-action svg {
fill: white;
}
.button-container button {
height: 40px;
border: 1px solid var(--border-color);
}
#sidebar {
position: fixed;
right: 0;
top: 45%;
transform: translateY(-50%);
width: 270px;
padding: 20px;
background-color: var(--background-color);
border: 1px solid var(--border-color);
border-radius: 10px;
box-shadow: 0 0 15px var(--shadow-color);
transition: all 0.3s ease-in-out;
overflow: hidden;
z-index: 9999;
}
#toggleSidebar {
position: absolute;
top: 45%;
z-index: 9999;
left: 0;
transform: translateY(-50%);
width: 30px;
height: 30px;
background: var(--background-color);
border: 1px solid var(--border-color);
border-radius: 50%;
box-shadow: 0 0 15px var(--shadow-color);
cursor: pointer;
transition: left 0.3s, border 0.3s, background 0.3s;
display: flex;
align-items: center;
justify-content: center;
}
#sidebar.collapsed #sidebarContent {
display: none;
}
#sidebar.collapsed #toggleSidebar {
left: 15px;
}
#sidebarWrapper {
position: relative;
}
#toggleSidebar:hover {
border-color: var(--hover-border-color);
background: var(--hover-background-color);
}
#toggleSidebar svg {
height: 15px;
width: 15px;
transition: all 0.3s ease-in-out;
}
#sidebar.collapsed {
width: 60px;
}
#sidebar.collapsed #toggleSidebar {
left: 15px;
}
#sidebar h2 {
text-align: center;
color: var(--text-color);
font-size: 1.4em;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
margin-bottom: 10px;
transition: color 0.3s ease, background-color 0.3s ease;
}
#sidebar textarea {
width: 100%;
height: 100px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid var(--textarea-border-color);
border-radius: 5px;
transition: border-color 0.3s;
resize: none;
}
#sidebar textarea:focus {
border-color: var(--focus-border-color);
outline: none;
}
#sidebar button {
width: 100%;
padding: 10px;
margin-bottom: 2px;
border: none;
border-radius: 5px;
color: var(--button-text-color);
cursor: pointer;
transition: background-color 0.3s;
}
#submitQuestion,
#start {
padding: 10px 20px;
border: none;
border-radius: 5px;
color: var(--button-text-color);
font-size: 15px;
cursor: pointer;
transition: all 0.3s ease;
outline: none;
box-shadow: 0px 5px 10px var(--shadow-color);
}
#submitQuestion {
background-color: var(--button-background-color);
}
#submitQuestion:active {
box-shadow: 0px 2px 5px var(--shadow-color);
transform: translateY(3px);
}
#submitQuestion:hover {
background-color: var(--button-hover-background-color);
}
#start {
background-color: var(--start-button-background-color);
}
#start:active {
box-shadow: 0px 2px 5px var(--shadow-color);
transform: translateY(3px);
}
#start:hover {
background-color: var(--start-button-hover-background-color);
}
#questionList {
margin-top: 8px;
max-height: 200px;
overflow-y: auto;
}
.questionContainer {
display: flex;
align-items: center;
}
.question {
margin-bottom: 2px;
padding: 5px;
border: 1px solid var(--border-color);
border-radius: 5px;
background-color: var(--background-color);
color: var(--text-color);
display: flex;
justify-content: space-between;
align-items: center;
transition: background-color 0.3s;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.question:hover {
background-color: var(--hover-background-color);
}
.question:before {
content: "❌";
margin-right: 4px;
color: var(--text-color);
}
.question.answered {
color: #aaa;
}
.question.answered:before {
content: "✅";
}
.question button {
margin-left: 0px;
background: none;
border: 1px solid var(--border-color);
box-sizing: border-box;
cursor: pointer;
transition: color 0.3s;
display: flex;
justify-content: center;
align-items: center;
}
.question button:hover {
color: var(--button-hover-background-color);
}
.question .button-container {
margin-left: auto;
display: flex;
gap: 0px;
}
.button-container button {
width: 24px;
padding: 0;
border: 2px solid red;
}
.delete-button-wrapper {
display: flex;
align-items: center;
height: 100%;
}
.question button svg {
width: 18px;
height: 18px;
margin: auto;
pointer-events: none;
}
.button-group {
display: flex;
justify-content: space-between;
}
.question-text {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border: none;
outline: none;
color: var(--text-color);
}
#questionSummary {
display: flex;
justify-content: space-between;
margin-top: 20px;
padding: 10px;
background-color: var(--summary-background-color);
border-radius: 10px;
box-shadow: var(--summary-box-shadow);
transition: all 0.3s ease-in-out;
height: 90px;
}
.summary-item {
display: flex;
justify-content: space-between;
align-items: flex-start;
width: 45%;
padding: 10px;
background-color: var(--background-color);
border: 1px solid var(--summary-border-color);
border-radius: 10px;
box-shadow: var(--summary-box-shadow);
transition: all 0.3s ease-in-out;
}
.summary-item:hover {
box-shadow: var(--summary-box-shadow);
transform: scale(1.02);
}
.icon-count-container {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
width: 50%;
}
.summary-icon {
font-size: 18px;
margin-right: 10px;
color: var(--text-color);
}
.summary-count {
font-size: 18px;
margin-right: 10px;
color: var(--text-color);
}
.button-container {
display: flex;
justify-content: flex-end;
align-items: center;
width: 50%;
padding: 3px;
height: 100%;
}
.summary-action {
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
border: 1px solid var(--border-color);
color: var(--text-color);
background-color: transparent;
padding: 4px 4px;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease-in-out;
width: 100%;
height: 100%;
}
.summary-action:hover {
background-color: var(--hover-background-color);
}
.vertical-text {
writing-mode: vertical-rl;
text-orientation: upright;
font-size: 20px;
margin: 0 auto;
color: var(--text-color);
}
#settingSidebar {
position: fixed;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 270px;
padding: 20px;
background-color: var(--background-color);
border: 1px solid var(--border-color);
border-radius: 10px;
box-shadow: var(--shadow-color) 0 0 15px;
transition: all 0.3s ease-in-out;
overflow: hidden;
}
#settingSidebar h2 {
text-align: center;
color: var(--text-color);
font-size: 1.4em;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
margin-bottom: 10px;
transition: color 0.3s ease, background-color 0.3s ease;
}
.input-row {
margin-bottom: 10px;
}
.input-row label {
margin-top: 7px;
display: block;
margin-bottom: 5px;
color: var(--text-color);
font-weight: bold;
}
.input-row input[type="text"],
.input-row input[type="number"] {
width: 100%;
padding: 10px;
border: 1px solid var(--border-color);
border-radius: 5px;
transition: border-color 0.3s;
font-size: 14px;
font-family: Arial, sans-serif;
color: var(--input-text-color);
background-color: var(--input-background-color);
}
.input-row input[type="text"]:focus,
.input-row input[type="number"]:focus {
border-color: #007bff;
outline: none;
}
#runMode {
display: flex;
justify-content: space-between;
gap: 10px;
}
#runMode input[type="radio"] {
margin-right: 10px;
}
#delayTime {
width: 80px;
margin-left: 10px;
padding: 5px;
border: 1px solid var(--input-border-color);
border-radius: 5px;
transition: border-color 0.3s;
width: 70px;
text-align: right;
background-color: var(--input-background-color);
color: var(--input-text-color);
}
.mode-option {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 10px;
padding: 10px;
border: 1px solid var(--border-color);
border-radius: 10px;
transition: background-color 0.3s, box-shadow 0.3s;
width: 70%;
margin: 10px auto;
}
.mode-option.selected {
background-color: var(--selected-background-color);
box-shadow: 0px 0px 8px var(--shadow-color);
}
.mode-option:not(.selected):hover {
background-color: var(--hover-background-color);
}
#delayTime {
display: none;
margin-left: 10px;
}
.mode-option.delayed.selected #delayTime {
display: inline-block;
}
.mode-option input[type="number"] {
margin-left: 10px;
border: 1px solid var(--input-border-color);
color: var(--input-text-color);
}
.clear-cache-btn {
width: 100%;
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: var(--button-background-color);
color: var(--button-text-color);
font-size: 15px;
cursor: pointer;
transition: all 0.3s ease;
outline: none;
box-shadow: 0px 5px 10px var(--shadow-color);
}
.clear-cache-btn:active {
box-shadow: 0px 2px 5px var(--shadow-color);
transform: translateY(3px);
}
.clear-cache-btn:hover {
background-color: var(--button-hover-background-color);
}
.button-container1 {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
height: 30px;
}
#openSetting {
font-size: 24px;
color: var(--text-color);
transition: all 0.3s ease;
cursor: pointer;
}
#openSetting:hover {
color: var(--text-color-hover);
text-shadow: 2px 2px 4px var(--shadow-color);
}
#openSetting:active {
transform: scale(0.97);
}
#backToMainSidebar {
font-size: 24px;
color: var(--text-color);
transition: all 0.3s ease;
cursor: pointer;
}
#backToMainSidebar:hover {
color: var(--text-color-hover);
text-shadow: 2px 2px 4px var(--shadow-color);
}
#backToMainSidebar:active {
transform: scale(0.97);
}
.styled-select {
display: block;
font-size: 1em;
width: 100%;
max-width: 600px;
box-sizing: border-box;
margin: 0;
background-color: var(--dropdown-background-color);
color: var(--dropdown-text-color);
border: 1px solid var(--input-border-color);
}
.dropdown {
display: block;
width: 100%;
box-sizing: border-box;
border-radius: 4px;
box-shadow: 0 1px 0 1px var(--shadow-color);
padding: 0.5em 0.75em;
}
.input-flex {
display: flex;
align-items: center;
}
.input-flex label {
margin-right: 10px;
color: var(--text-color);
}
.input-row {
background-color: var(--input-background-color);
box-shadow: 0 2px 5px var(--shadow-color);
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
}
.input-row label {
margin-bottom: 5px;
font-weight: bold;
}
.input-row input[type="text"],
.input-row input[type="number"],
.input-row select {
border: 1px solid var(--input-border-color);
color: var(--input-text-color);
}
.input-row select {
padding: 8px;
}
.button-container1 button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: var(--button-background-color);
color: var(--button-text-color);
font-size: 15px;
cursor: pointer;
transition: all 0.3s ease;
outline: none;
box-shadow: var(--shadow-color) 0px 5px 10px;
}
.button-container1 button:active {
box-shadow: var(--shadow-color) 0px 2px 5px;
transform: translateY(3px);
}
.button-container1 button:hover {
background-color: var(--button-hover-background-color);
}
.dragging {
opacity: 0.5;
}
#delayTime:after {
content: "秒";
margin-left: 5px;
}
.button-group {
display: flex;
flex-direction: row;
gap: 5px;
}
#start {
display: block;
margin-top: 5px;
}
#stepRun {
background-color: var(--button-background-color);
color: var(--button-text-color);
font-size: 16px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s, transform 0.3s;
}
#stepRun:hover {
background-color: var(--button-hover-background-color);
}
#stepRun:active {
background-color: var(--button-active-background-color);
transform: translateY(2px);
box-shadow: var(--shadow-color) 0px 2px 5px;
}
.input-row textarea {
color: var(--input-text-color);
font-size: 14px;
padding: 8px;
border-radius: 5px;
border: 1px solid var(--input-border-color);
width: 100%;
box-sizing: border-box;
resize: none;
min-height: 50px;
overflow-y: auto;
}
.input-row label,
.input-row input[type="text"],
.input-row input[type="number"],
.input-row select,
.input-row textarea {
margin-bottom: 10px;
}
.input-flex label,
.input-flex input,
.input-flex textarea {
display: inline-block;
vertical-align: middle;
}
.feedback-bar {
margin-top: 8px;
margin-bottom: 8px;
padding: 10px;
border-radius: 5px;
text-align: center;
display: none;
font-size: 14px;
}
.feedback-bar.success {
background-color: #a3cfec;
color: #333333;
}
.feedback-bar.error {
background-color: #f6b1b1;
color: #333333;
}
.feedback-bar.normal {
background-color: #e2e2e2;
color: #333333;
}
.theme-switch-wrapper {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.theme-icon {
font-size: 1.2em;
}
.theme-switch {
display: inline-block;
height: 24px;
position: relative;
width: 48px;
margin-top: 10px;
}
.theme-switch input {
display: none;
}
.slider {
background-color: #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: 0.4s;
}
.slider:before {
background-color: white;
bottom: 4px;
content: "";
height: 16px;
left: 4px;
position: absolute;
transition: 0.4s;
width: 16px;
}
input:checked + .slider {
background-color: #2196f3;
}
input:checked + .slider:before {
transform: translateX(24px);
}
.slider.round {
border-radius: 24px;
}
.slider.round:before {
border-radius: 50%;
}
.my-app-night-mode .original-icon svg {
fill: #757575;
}
`);
const GlobalSVG = {
original: `<svg t="1684556652392" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2423" width="20" height="20"><path d="M202.666667 256h-42.666667a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64H266.666667v565.333333a53.333333 53.333333 0 0 0 53.333333 53.333334h384a53.333333 53.333333 0 0 0 53.333333-53.333334V352a32 32 0 0 1 64 0v469.333333c0 64.8-52.533333 117.333333-117.333333 117.333334H320c-64.8 0-117.333333-52.533333-117.333333-117.333334V256z m224-106.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z m-32 288a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z m170.666666 0a32 32 0 0 1 64 0v256a32 32 0 0 1-64 0V437.333333z" fill="#000000" p-id="2424"></path></svg>`, // 原始SVG
deleteConfirm: `<svg t="1705597990331" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4215" width="32" height="32"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024z m250.56-656.768l-40.96-41.152A19.008 19.008 0 0 0 707.84 320a19.008 19.008 0 0 0-13.888 6.08l-246.4 247.68L330.176 455.04a20.032 20.032 0 0 0-13.888-5.44 20.032 20.032 0 0 0-13.824 5.44l-40.96 41.216A20.288 20.288 0 0 0 256 510.208c0 5.248 1.792 9.856 5.44 13.888l172.224 173.824a17.408 17.408 0 0 0 13.568 6.08 17.408 17.408 0 0 0 13.568-6.08l301.76-302.784A20.672 20.672 0 0 0 768 380.8a18.56 18.56 0 0 0-5.44-13.632z" fill="#d81e06" p-id="4216"></path></svg>`, // 确认删除的SVG
};
// 用户界面模块
const UIManager = {
createMainSidebar: function () {
const sidebar = document.createElement("div");
sidebar.id = "sidebar";
sidebar.innerHTML = `
<div id="toggleSidebar">
<svg viewBox="0 0 24 24" id="icon-expand">
<path d="M10 18h4v-2h-4v2zM3 13h18v-2H3v2zm0 7h12v-2H3v2zm0-14v2h18V6H3z"/>
</svg>
<svg viewBox="0 0 24 24" id="icon-collapse" style="display: none;">
<path d="M10 20h4V4h-4v16zm0-18H6v20h4V2zm8 0h-4v20h4V2z"/>
</svg>
</div>
<section id="sidebarContent">
<h2 id="openSetting" style="cursor: pointer;">PreChat 设置</h2>
<textarea id="questionInput" placeholder="请输入您的提示词 , 可批量输入 , 默认 + 为拆分"></textarea>
<div class="button-group">
<button id="submitQuestion">提交</button>
<button id="stepRun">单步运行</button>
</div>
<div class="button-group">
<button id="start">自动运行</button>
</div>
<div id="feedbackBar" class="feedback-bar" style="display: none;"></div>
<ul id="questionList"></ul>
<div id="questionSummary" class="question-summary">
<div class="summary-item">
<div class="icon-count-container">
<div class="icon-container">
<span class="summary-icon">✅</span>
</div>
<div class="count-container">
<span class="summary-count" id="completedCount">0</span>
</div>
</div>
<div class="button-container">
<a href="#" class="summary-action" id="deleteCompleted">
${GlobalSVG.original}
</a>
</div>
</div>
<div class="summary-item">
<div class="icon-count-container">
<div class="icon-container">
<span class="summary-icon">❌</span>
</div>
<div class="count-container">
<span class="summary-count" id="pendingCount">0</span>
</div>
</div>
<div class="button-container">
<a href="#" class="summary-action" id="deletePending">
${GlobalSVG.original}
</a>
</div>
</div>
</div>
</section>
`;
document.body.appendChild(sidebar);
const savedTheme = localStorage.getItem("selectedTheme") || "light";
if (savedTheme === "dark") {
document.documentElement.classList.add("my-app-night-mode");
}
},
createSettingSidebar: function () {
const settingSidebar = document.createElement("div");
settingSidebar.id = "settingSidebar";
settingSidebar.style.display = "none";
settingSidebar.innerHTML = `
<section id="sidebarContent">
<h2 id="backToMainSidebar" style="cursor: pointer;">PreChat 保存</h2>
<!-- 主题切换 -->
<div class="input-row">
<div class="theme-switch-wrapper">
<span class="theme-icon sun-icon">☀️</span>
<label class="theme-switch">
<input type="checkbox" id="themeSwitch">
<div class="slider round"></div>
</label>
<span class="theme-icon moon-icon">🌙</span>
</div>
</div>
<!-- 拆分符号 -->
<div class="input-row">
<label for="splitCharInput">拆分符号:</label>
<input type="text" id="splitCharInput" placeholder="留空则默认为 + " />
</div>
<!-- 输出增强 -->
<div class="input-row">
<label for="additionalInput">输出增强:</label>
<textarea id="additionalInput" placeholder="例如,零样本提示(请一步步思考),少样本提示(提供输出案例),思维链/树(提供思考过程)等"></textarea>
</div>
<!-- 运行模式 -->
<div class="input-row">
<div id="runMode">
<div class="mode-option instant" id="instantOption">
<input type="radio" id="instant" name="mode" value="instant" checked>
<label for="instant">即时</label>
</div>
<div class="mode-option delayed" id="delayedOption">
<input type="radio" id="delayed" name="mode" value="delayed">
<label for="delayed">延时</label>
<input type="number" id="delayTime" placeholder="432">
</div>
</div>
</div>
<!-- 清空缓存按钮 -->
<div class="button-container1" style="display: inline-block;">
<button class="clear-cache-btn">清空缓存</button>
</div>
</section>
`;
document.body.appendChild(settingSidebar);
const clearCacheBtn = document.querySelector(".clear-cache-btn");
clearCacheBtn.addEventListener("click", Utils.clearCache);
},
createButton: function (type, clickHandler) {
const button = document.createElement("button");
button.className = `${type}-button`;
switch (type) {
case "delete":
button.innerHTML = GlobalSVG.original;
break;
}
if (clickHandler) {
button.addEventListener("click", clickHandler);
}
return button;
},
showFeedback: function (message, type = "normal") {
const feedbackBar = document.getElementById("feedbackBar");
if (!feedbackBar) {
UIManager.showFeedback("找不到反馈栏元素", "error");
return;
}
feedbackBar.textContent = message;
feedbackBar.style.display = "block";
feedbackBar.className = `feedback-bar ${type}`;
// 根据消息类型调整显示时间
let displayDuration = 3000; // 默认显示时间为3秒
if (type === "error") {
displayDuration = 5000; // 错误消息显示时间长一些
}
// 定时隐藏通知栏
setTimeout(() => {
feedbackBar.style.display = "none";
}, displayDuration);
},
createQuestionDiv: function (question, answered) {
const div = document.createElement("div");
div.className = "question";
div.draggable = true;
const questionContainer = document.createElement("div");
questionContainer.style.display = "flex";
questionContainer.style.justifyContent = "center";
const questionText = document.createElement("textarea");
questionText.className = "question-text";
questionText.value = question;
questionText.readOnly = true;
questionText.style.border = "none";
questionText.style.height = "42px";
questionText.style.resize = "none";
questionText.style.margin = "auto";
questionText.style.width = "140px";
questionContainer.appendChild(questionText);
div.appendChild(questionContainer);
const buttonContainer = document.createElement("div");
buttonContainer.className = "button-container";
// 创建一个新的 div 用于包裹删除按钮
const deleteButtonWrapper = document.createElement("div");
deleteButtonWrapper.className = "delete-button-wrapper";
const deleteButton = this.createButton(
"delete",
EventHandler.handleDeleteButtonClick
);
deleteButtonWrapper.appendChild(deleteButton);
buttonContainer.appendChild(deleteButtonWrapper);
div.appendChild(buttonContainer);
if (answered) {
div.classList.add("answered");
}
div.addEventListener("dragstart", function (e) {
e.dataTransfer.setData("text/plain", this.outerHTML);
this.classList.add("dragging");
});
div.addEventListener("dragend", function () {
this.classList.remove("dragging");
});
return div;
},
addQuestionToList: function (question, answered, uuid) {
if (question.trim() === "") {
return null;
}
const questionDiv = this.createQuestionDiv(question, answered); // 确保使用this引用
questionDiv.dataset.id = uuid;
const questionList = document.getElementById("questionList");
if (questionList) {
questionList.appendChild(questionDiv);
if (answered) {
questionDiv.classList.add("answered");
}
this.updateQuestionCounts();
return questionDiv;
} else {
UIManager.showFeedback("未找到问题列表元素", "error");
}
},
clearInput: function () {
// 清除原始输入框的内容
const input = document.getElementById("questionInput");
if (input) {
input.value = "";
} else {
UIManager.showFeedback("Input element not found", "error");
}
// 清除文本区域的内容
const textarea = document.getElementById("prompt-textarea");
if (textarea) {
textarea.value = "";
} else {
UIManager.showFeedback("Prompt textarea element not found", "error");
}