-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSDAtom-WebUi-us.user.js
1933 lines (1716 loc) · 112 KB
/
SDAtom-WebUi-us.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 SDAtom-WebUi-us
// @namespace SDAtom-WebUi-us
// @version 1.4.1
// @description Queue for AUTOMATIC1111 WebUi and an option to saving settings
// @author Kryptortio
// @homepage https://github.com/Kryptortio/SDAtom-WebUi-us
// @match http://127.0.0.1:7860/*
// @updateURL https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js
// @downloadURL https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
const c_scriptVersion = typeof GM_info == 'undefined' ? '1.3.2' : GM_info.script.version;
const c_scriptHandeler = typeof GM_info == 'undefined' ? '(not user script)' : GM_info.scriptHandler;
// ----------------------------------------------------------------------------- Config
let conf = {
shadowDOM:{sel:"gradio-app"},
commonData: {
t2iContainer:{sel:"#tab_txt2img"},
i2iContainer:{sel:"#tab_img2img"},
extContainer:{sel:"#tab_extras"},
sdModelCheckpoint:{grad:"setting_sd_model_checkpoint"},
versionContainer:{sel:"#footer .versions"},
working:false,
processing:false,
waiting:false,
},
t2i: {
controls:{
tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(1)"},
genrateButton: {sel:"#txt2img_generate"},
skipButton: {sel:"#txt2img_skip"},
},
prompt: {sel:"#txt2img_prompt textarea"},
negPrompt: {sel:"#txt2img_neg_prompt textarea"},
sample: {sel:"#txt2img_steps [id^=range_id]",sel2:"#txt2img_steps input"},
sampleMethod: {grad:"txt2img_sampling"},
width: {sel:"#txt2img_width [id^=range_id]",sel2:"#txt2img_width input"},
height: {sel:"#txt2img_height [id^=range_id]",sel2:"#txt2img_height input"},
restoreFace: {sel:"#txt2img_settings #setting_face_restoration input"},
tiling: {sel:"#txt2img_settings #setting_tiling input"},
highresFix: {sel:"#txt2img_hr"},
hrFixUpscaler: {grad:"txt2img_hr_upscaler"},
hrFixSteps: {sel:"#txt2img_hires_steps [id^=range_id]",sel2:"#txt2img_hires_steps input"},
hrFixdenoise: {sel:"#txt2img_denoising_strength [id^=range_id]",sel2:"#txt2img_denoising_strength input"},
hrFixUpscaleBy: {sel:"#txt2img_hr_scale [id^=range_id]",sel2:"#txt2img_hr_scale input"},
hrFixWidth: {sel:"#txt2img_hr_resize_x [id^=range_id]",sel2:"#txt2img_hr_resize_x input"},
hrFixHeight: {sel:"#txt2img_hr_resize_y [id^=range_id]",sel2:"#txt2img_hr_resize_y input"},
batchCount: {sel:"#txt2img_batch_count [id^=range_id]",sel2:"#txt2img_batch_count input"},
batchSize: {sel:"#txt2img_batch_size [id^=range_id]",sel2:"#txt2img_batch_size input"},
cfg: {sel:"#txt2img_cfg_scale [id^=range_id]",se2:"#txt2img_cfg_scale input"},
seed: {sel:"#txt2img_seed input"},
extra: {sel:"#txt2img_subseed_show input"},
varSeed: {sel:"#txt2img_subseed input"},
varStr: {sel:"#txt2img_subseed_strength [id^=range_id]",sel2:"#txt2img_subseed_strength input"},
varRSFWidth: {sel:"#txt2img_seed_resize_from_w [id^=range_id]",sel2:"#txt2img_seed_resize_from_w input"},
varRSFHeight: {sel:"#txt2img_seed_resize_from_h [id^=range_id]",sel2:"#txt2img_seed_resize_from_h input"},
script: {grad:"script_list",gradIndex:0},
scriptPromptMatrixPutVar: {sel:"#script_txt2img_prompt_matrix_put_at_start input"},
scriptPromptMatrixUseDiff: {sel:"#script_txt2img_prompt_matrix_different_seeds input"},
scriptXYZXtype:{grad:"script_txt2img_xyz_plot_x_type"},
scriptXYZXVals:{sel:"#script_txt2img_xyz_plot_x_values textarea"},
scriptXYZYtype:{grad:"script_txt2img_xyz_plot_y_type"},
scriptXYZYVals:{sel:"#script_txt2img_xyz_plot_y_values textarea"},
scriptXYZZtype:{grad:"script_txt2img_xyz_plot_z_type"},
scriptXYZZVals:{sel:"#script_txt2img_xyz_plot_z_values textarea"},
scriptXYZDrawLeg:{sel:"#script_txt2img_xyz_plot_draw_legend input"},
scriptXYZIncludeSubImg:{sel:"#script_txt2img_xyz_plot_include_lone_images input"},
scriptXYZIncludeSubGrid:{sel:"#script_txt2img_xyz_plot_include_sub_grids input"},
scriptXYZKeepMOne:{sel:"#script_txt2img_xyz_plot_no_fixed_seeds input"},
scriptXYZGridMargin: {sel:"#script_txt2img_xyz_plot_margin_size [id^=range_id]",sel2:"#script_txt2img_xyz_plot_margin_size input"},
},
i2i:{
controls:{
tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(2)"},
genrateButton: {sel:"#img2img_generate"},
skipButton: {sel:"#img2img_skip"},
i2iMode:[
{name:"i2i", buttonSel:"#mode_img2img button:nth-child(1)", containerSel:"#img2img_img2img_tab"},
{name:"sketch", buttonSel:"#mode_img2img button:nth-child(2)", containerSel:"#img2img_img2img_sketch_tab"},
{name:"inpaint", buttonSel:"#mode_img2img button:nth-child(3)", containerSel:"#img2img_inpaint_tab"},
{name:"inpaintSketch", buttonSel:"#mode_img2img button:nth-child(4)", containerSel:"#img2img_inpaint_sketch_tab"},
{name:"inpaintUpload", buttonSel:"#mode_img2img button:nth-child(5)", containerSel:"#img2img_inpaint_upload_tab"},
{name:"batch", buttonSel:"#mode_img2img button:nth-child(6)", containerSel:"#img2img_batch_tab"},
],
},
prompt: {sel:"#img2img_prompt textarea"},
negPrompt: {sel:"#img2img_neg_prompt textarea"},
resizeMode: {sel:"#resize_mode"},
inpaintBlur: {sel:"#img2img_mask_blur [id^=range_id]",sel2:"#img2img_mask_blur"},
inpaintMaskMode: {sel:"#img2img_mask_mode"},
inpaintMaskContent: {sel:"#img2img_inpainting_fill"},
inpaintArea: {sel:"#img2img_inpaint_full_res"},
inpaintPadding: {sel:"#img2img_inpaint_full_res_padding [id^=range_id]",sel2:"#img2img_inpaint_full_res_padding"},
i2iBatchInputDir: {sel:"#img2img_batch_input_dir textarea"},
i2iBatchOutputDir: {sel:"#img2img_batch_output_dir textarea"},
i2iBatchMaskDir: {sel:"#img2img_batch_inpaint_mask_dir textarea"},
sample: {sel:"#img2img_steps [id^=range_id]",sel2:"#img2img_steps input"},
sampleMethod: {grad:"img2img_sampling"},
width: {sel:"#img2img_width [id^=range_id]",sel2:"#img2img_width input"},
height: {sel:"#img2img_height [id^=range_id]",sel2:"#img2img_height input"},
restoreFace: {sel:"#img2img_settings #setting_face_restoration input"},
tiling: {sel:"#img2img_settings #setting_tiling input"},
batchCount: {sel:"#img2img_batch_count [id^=range_id]",sel2:"#img2img_batch_count input"},
batchSize: {sel:"#img2img_batch_size [id^=range_id]",sel2:"#img2img_batch_size input"},
cfg: {sel:"#img2img_cfg_scale [id^=range_id]",se2:"#img2img_cfg_scale input"},
denoise: {sel:"#img2img_denoising_strength [id^=range_id]",se2:"#img2img_denoising_strength input"},
seed: {sel:"#img2img_seed input"},
extra: {sel:"#txt2img_subseed_show input"},
varSeed: {sel:"#img2img_subseed input"},
varStr: {sel:"#img2img_subseed_strength input",sel2:"#img2img_subseed_strength [id^=range_id]"},
varRSFWidth: {sel:"#img2img_seed_resize_from_w input",sel2:"#img2img_seed_resize_from_w [id^=range_id]"},
varRSFHeight: {sel:"#img2img_seed_resize_from_h input",sel2:"#img2img_seed_resize_from_h [id^=range_id]"},
script: {grad:"script_list",gradIndex:1},
scriptPromptMatrixPutVar: {sel:"#script_img2img_prompt_matrix_put_at_start input"},
scriptPromptMatrixUseDiff: {sel:"#script_img2img_prompt_matrix_different_seeds input"},
scriptXYZXtype:{grad:"script_img2img_xyz_plot_x_type"},
scriptXYZXVals:{sel:"#script_img2img_xyz_plot_x_values textarea"},
scriptXYZYtype:{grad:"script_img2img_xyz_plot_y_type"},
scriptXYZYVals:{sel:"#script_img2img_xyz_plot_y_values textarea"},
scriptXYZZtype:{grad:"script_img2img_xyz_plot_z_type"},
scriptXYZZVals:{sel:"#script_img2img_xyz_plot_z_values textarea"},
scriptXYZDrawLeg:{sel:"#script_img2img_xyz_plot_draw_legend input"},
scriptXYZIncludeSubImg:{sel:"#script_img2img_xyz_plot_include_lone_images input"},
scriptXYZIncludeSubGrid:{sel:"#script_img2img_xyz_plot_include_sub_grids input"},
scriptXYZKeepMOne:{sel:"#script_img2img_xyz_plot_no_fixed_seeds input"},
scriptXYZGridMargin: {sel:"#script_img2img_xyz_plot_margin_size [id^=range_id]",sel2:"#script_img2img_xyz_plot_margin_size input"},
scripti2iAltTestOverrideSampM:{sel:"#script_img2img_alternative_test_override_sampler input"},
scripti2iAltTestOverrideProm:{sel:"#script_img2img_alternative_test_override_prompt input"},
scripti2iAltTestOrigProm:{sel:"#script_img2img_alternative_test_original_prompt textarea"},
scripti2iAltTestOrigNProm:{sel:"#script_img2img_alternative_test_original_negative_prompt textarea"},
scripti2iAltTestOverrideSampS:{sel:"#script_img2img_alternative_test_override_steps input"},
scripti2iAltTestDecStep:{sel:"#script_img2img_alternative_test_st input",sel2:"#script_img2img_alternative_test_st [id^=range_id]"},
scripti2iAltTestOverrideDenoi:{sel:"#script_img2img_alternative_test_override_strength input"},
scripti2iAltTestDecCFG:{sel:"#script_img2img_alternative_test_cfg input",sel2:"#script_img2img_alternative_test_cfg [id^=range_id]"},
scripti2iAltTestRand:{sel:"#script_img2img_alternative_test_randomness input",sel2:"#script_img2img_alternative_test_randomness [id^=range_id]"},
scripti2iAltTestSigma:{sel:"#script_img2img_alternative_test_sigma_adjustment input"},
scriptLoopbackLoops:{sel:"#script_loopback_loops input",sel2:"#script_loopback_loops [id^=range_id]"},
scriptLoopbackDenoStr:{sel:"#script_loopback_final_denoising_strength input",sel2:"#script_loopback_final_denoising_strength [id^=range_id]"},
scriptLoopbackDenoStrCurve:{gradLab:"Denoising strength curve"},
scriptLoopbackAppend:{gradLab:"Append interrogated prompt at each iteration"},
scriptOutPMK2Pixels:{sel:"#script_outpainting_mk2_pixels input",sel2:"#script_outpainting_mk2_pixels [id^=range_id]"},
scriptOutPMK2MaskBlur:{sel:"#script_outpainting_mk2_mask_blur input",sel2:"#script_outpainting_mk2_mask_blur [id^=range_id]"},
scriptOutPMK2Left:{sel:"#script_outpainting_mk2_direction label:nth-child(1) input"},
scriptOutPMK2Right:{sel:"#script_outpainting_mk2_direction label:nth-child(2) input"},
scriptOutPMK2Up:{sel:"#script_outpainting_mk2_direction label:nth-child(3) input"},
scriptOutPMK2Down:{sel:"#script_outpainting_mk2_direction label:nth-child(4) input"},
scriptOutPMK2FallOff:{sel:"#script_outpainting_mk2_noise_q input",sel2:"#script_outpainting_mk2_noise_q [id^=range_id]"},
scriptOutPMK2ColorVar:{sel:"#script_outpainting_mk2_color_variation input",sel2:"#script_outpainting_mk2_color_variation [id^=range_id]"},
scriptPoorManPixels:{sel:"#script_poor_mans_outpainting_pixels input",sel2:"#script_poor_mans_outpainting_pixels [id^=range_id]"},
scriptPoorManMaskBlur:{sel:"#script_poor_mans_outpainting_mask_blur input",sel2:"#script_poor_mans_outpainting_mask_blur [id^=range_id]"},
scriptPoorManMaskCont:{sel:"#script_poor_mans_outpainting_inpainting_fill"},
scriptPoorManLeft:{sel:"#script_poor_mans_outpainting_direction label:nth-child(1) input"},
scriptPoorManRight:{sel:"#script_poor_mans_outpainting_direction label:nth-child(2) input"},
scriptPoorManUp:{sel:"#script_poor_mans_outpainting_direction label:nth-child(3) input"},
scriptPoorManDown:{sel:"#script_poor_mans_outpainting_direction label:nth-child(4) input"},
scriptSDUpTile:{sel:"#script_sd_upscale_overlap input",sel2:"#script_sd_upscale_overlap [id^=range_id]"},
scriptSDUpScale:{sel:"#script_sd_upscale_scale_factor input",sel2:"#script_sd_upscale_scale_factor [id^=range_id]"},
scriptSDUpUpcaler:{sel:"#script_sd_upscale_upscaler_index"},
},
ext:{
controls:{
tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(3)"},
genrateButton: {sel:"#extras_generate"},
loadingElement:{sel:"#html_info_x_extras .wrap"},
extrasResizeMode:[
{name:"scaleBy",buttonSel:"#extras_resize_mode button:nth-child(1)",containerSel:"#extras_scale_by_tab"},
{name:"scaleTo",buttonSel:"#extras_resize_mode button:nth-child(2)",containerSel:"#extras_scale_to_tab"},
],
extrasMode:[
{name:"singleImg",buttonSel:"#mode_extras button:nth-child(1)",containerSel:"#extras_single_tab"},
{name:"batchProcess",buttonSel:"#mode_extras button:nth-child(2)",containerSel:"#extras_batch_process_tab"},
{name:"batchDir",buttonSel:"#mode_extras button:nth-child(3)",containerSel:"#extras_batch_directory_tab"},
],
},
scaleByResize:{sel:"#extras_upscaling_resize input",sel2:"#extras_upscaling_resize [id^=range_id]"},
scaleToWidth:{sel:"#extras_upscaling_resize_w input"},
scaleToHeight:{sel:"#extras_upscaling_resize_h input"},
scaleToCropToFit:{sel:"#extras_upscaling_crop input"},
batchDirInput:{sel:"#extras_batch_input_dir textarea"},
batchDirOutput:{sel:"#extras_batch_output_dir textarea"},
batchDirShowImg:{sel:"#extras_show_extras_results input"},
upscaler1:{grad:"extras_upscaler_1"},
upscaler2:{grad:"extras_upscaler_2"},
upscale2Vis:{sel:"#extras_upscaler_2_visibility input",sel2:"#extras_upscaler_2_visibility [id^=range_id]"},
GFPGANVis:{sel:"#extras_gfpgan_visibility input",sel2:"#extras_gfpgan_visibility [id^=range_id]"},
CodeFormVis:{sel:"#extras_codeformer_visibility input",sel2:"#extras_codeformer_visibility [id^=range_id]"},
CodeFormWeight:{sel:"#extras_codeformer_weight input",sel2:"#extras_codeformer_weight [id^=range_id]"},
},
extensions: {
iBrowser: {
name:"stable-diffusion-webui-images-browser",
existCheck:{sel:"#tab_image_browser"},
guiElems: {
iBrowserContainer:{sel:"#tab_image_browser"},
generationInfo: {sel: "#image_browser_tab_txt2img_image_browser_file_info textarea"},
txt2img:{sel:'#image_browser_tab_txt2img_image_browser_file_info textarea'},
img2img:{sel:'#image_browser_tab_img2img_image_browser_file_info textarea'},
txt2imgG:{sel:'#image_browser_tab_txt2img-grids_image_browser_file_info textarea'},
img2imgG:{sel:'#image_browser_tab_img2img-grids_image_browser_file_info textarea'},
extras:{sel:'#image_browser_tab_extras_image_browser_file_info textarea'},
favorites:{sel:'#image_browser_tab_favorites_image_browser_file_info textarea'},
},
ui:{},
text:{
queueVariationsButtonText:'Add 5 variations',
queueHiResVersionButtonText:'Add HiRes version',
},
functions: {
getValueJSON: function () {
awqLog('iBrowser.getValueJSON: parsing data');
let valueJSON = {type:'t2i'};
let currentTab = document.querySelector('#image_browser_tabs_container button.selected').innerHTML;
currentTab = currentTab.replace(/\s/g,'');
currentTab = currentTab.replace('-grids','G').toLowerCase();
let generationInfoValue = conf.extensions.iBrowser.guiElems[currentTab].el.value;
//Used when loading prompt from image browser
/*
Kind of using the logic from generation_parameters_copypaste.py/parse_generation_parameters (but not really, because that doesn't account for Template/Negative Template)
Structure
<prompt>
Negative prompt: <negative prompt>
a1: b1, a2: b2, etc
Template: <template>
Negative Template: <negative template>
<prompt>, <negative prompt>, <template> and <negative template> can all be multiline, or missing.
Maybe assume that <prompt> is never missing?
*/
let lines = generationInfoValue.split(/\r?\n/);
let whichLine=0; //0=prompt, 1=negPrompt, 2=template, 3=negTemplate, 4: dictionary
valueJSON['prompt']='';
valueJSON['negPrompt']='';
for (let l of lines) {
if (l.startsWith("Negative prompt: ")) {
whichLine=1;
l=l.substring(17);
}
else if (l.startsWith("Template: ")) {
whichLine=2;
l=l.substring(10);
}
else if (l.startsWith("Negative Template: ")) {
whichLine=3;
l=l.substring(19);
}
else if (l.startsWith("Steps: ")) {
whichLine=4;
}
switch (whichLine) {
case 0:
valueJSON['prompt']+=l;
break;
case 1:
valueJSON['negPrompt']+=l;
break;
case 2:
//ignore template
break;
case 3:
//ignore neg template
break;
case 4:
for (let v of l.split(/, /)) {
let kv=v.split(/: /);
let key=kv[0];
switch (kv[0]){
case "Steps":
valueJSON['sample']=kv[1];
break;
case "Sampler":
valueJSON['sampleMethod']=kv[1];
break;
case "CFG scale":
valueJSON['cfg']=kv[1];
break;
case "Seed":
valueJSON['seed']=kv[1];
break;
case "Size":
let wh=kv[1].split(/x/)
valueJSON['width']=wh[0];
valueJSON['height']=wh[1];
break;
case "Model":
valueJSON['sdModelCheckpoint']=kv[1];
break;
case "Denoising strength":
valueJSON['hrFixdenoise']=kv[1];
break;
case "Hires upscale":
valueJSON['hrFixUpscaleBy']=kv[1];
valueJSON['highresFix']=true;
break;
case "Hires upscaler":
valueJSON['hrFixUpscaler']=kv[1];
break;
}
}
break;
} // End of switch
} // End of for
return JSON.stringify(valueJSON);
},
}, // End of functions
}, // End of iBrowser
},
ui:{},
scriptSettings: {
defaultQuantity:{name:"Default queue quantity", description:"Default number of times to execute each queue item", type:"numeric",value:"1"},
rememberQueue:{name:"Remember queue", description:"Remember the queue if you reload the page", type:"boolean",value:true},
notificationSound:{name:"Notification sound", description:"Sound to be played when processing of queue items stops", type:"boolean",value:true},
extensionScript:{name:"Extension script(s)", description:"https://github.com/Kryptortio/SDAtom-WebUi-us#script-extensions", type:"text",value:""},
promptFilter:{name:"Prompt filter(s)", description:"https://github.com/Kryptortio/SDAtom-WebUi-us#prompt-filter", type:"text",value:""},
promptFilterNegative:{name:"Filter negative prompt", description:"Apply the prompt filter to the negative filter as well", type:"boolean",value:false},
autoscrollOutput:{name:"Autoscroll console", description:"Scroll console automatically when new lines appear", type:"boolean",value:true},
verboseLog:{name:"Verbose console", description:"Log as much as possible to the console", type:"boolean",value:false},
maxOutputLines:{name:"Max console lines", description:"The maximum number of lines that can be shown in the console box", type:"numeric",value:"500"},
overwriteQueueSettings1:{name:"Alt 1 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 1 button to add to queue (same format as in the queue)", type:"text",value:'{"width":"768","height":"768"}'},
overwriteQueueSettings2:{name:"Alt 2 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 2 button to add to queue (same format as in the queue)", type:"text",value:'{"width":"1024","height":"1024"}'},
overwriteQueueSettings3:{name:"Alt 3 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 3 button to add to queue (same format as in the queue)", type:"text",value:'{"sample":"20","sampleMethod":"Euler a","width":"512","height":"512","restoreFace": false,"tiling": false,"batchCount": "1","batchSize": "1","cfg": "7","seed": "-1","extra": false, "varSeed": "-1","varStr": "0"}'},
buttonOpacity:{name:"Button transparency", description:"Change how visible the floating buttons in the corner should be", type:"numeric",value:0.7},
},
savedSetting: JSON.parse(localStorage.awqSavedSetting || '{}'),
currentQueue: JSON.parse(localStorage.awqCurrentQueue || '[]'),
};
if(localStorage.hasOwnProperty("awqNotificationSound") &&
!localStorage.hasOwnProperty("awqScriptSettings")) { // Tmp settings migration
awqLog('Copying settings from old storage');
if (localStorage.hasOwnProperty("awqNotificationSound"))
conf.scriptSettings.notificationSound.value = localStorage.awqNotificationSound == 1 ? true : false;
if (localStorage.hasOwnProperty("awqAutoscrollOutput"))
conf.scriptSettings.autoscrollOutput.value = localStorage.awqAutoscrollOutput == 1 ? true : false;
if (localStorage.hasOwnProperty("awqVerboseLog"))
conf.scriptSettings.verboseLog.value = localStorage.awqVerboseLog == 1 ? true : false;
if (localStorage.hasOwnProperty("awqMaxOutputLines"))
conf.scriptSettings.maxOutputLines.value = localStorage.awqMaxOutputLines;
if (localStorage.hasOwnProperty("awqPromptFilter"))
conf.scriptSettings.promptFilter.value = localStorage.awqPromptFilter;
if (localStorage.hasOwnProperty("awqExtensionScript"))
conf.scriptSettings.extensionScript.value = localStorage.awqExtensionScript;
}
const c_emptyQueueString = 'Queue is empty';
const c_addToQueueButtonText = 'Add to queue';
const c_processButtonText = 'Process queue';
const c_defaultTextStoredSettings = "Stored settings";
const c_innerUIWidth = 'calc(100vw - 20px)';
const c_uiElemntHeight = '25px';
const c_uiElemntHeightSmall = '18px';
const c_audio_base64 = new Audio('data:audio/mpeg;base64,//PkZAAAAAGkAAAAAAAAA0gAAAAATEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV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VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV');
const c_defaultOtputConsoleText = "Here you will see some information about what the script is doing";
const c_defaultOtputConsoleTextHTML = `<span class="console-description" style="color:darkgray">${c_defaultOtputConsoleText}</span>`;
const c_extraResizeModeScaleByType = 1;
const c_extraResizeModeScaleToType = 2;
const c_wait_tick_duration = 200;
const c_any_value = '<ANY VALUE>';
// ----------------------------------------------------------------------------- Logging
function preAwqLog(p_message) {
console.log(`SDAtom-WebUi-us: ${p_message}`);
}
preAwqLog(`Running SDAtom-WebUi-us version ${c_scriptVersion} using ${c_scriptHandeler} with browser ${window.navigator.userAgent}`);
function awqLog(p_message) {
if(conf.scriptSettings.verboseLog.value) {
awqLogPublishMsg(p_message, 'lightgray');
}
}
function awqLogPublishMsg(p_message, p_color) {
if(!conf.ui.outputConsole) return;
if(conf.ui.outputConsole.innerHTML.match('console-description')) {
let ASDWUIVerText = '<span style="font-size: 0.9em;">' + conf.commonData.versionContainer.el.textContent + '</span>';
conf.ui.outputConsole.innerHTML = `* Running SDAtom-WebUi-us version ${c_scriptVersion} using ${c_scriptHandeler} with browser ${window.navigator.userAgent} stable-diffusion-webui version ${ASDWUIVerText}`;
}
let lines = conf.ui.outputConsole.querySelectorAll('div');
let line = document.createElement('div');
line.className = 'awq-console-line';
const timestamp = (new Date()).toLocaleTimeString([], {hour: '2-digit',minute: '2-digit',second: '2-digit', hour12: false});
line.innerHTML = '<span style="' + (p_color ? 'color:'+p_color : '') + '">' + timestamp + ': ' + p_message + '</span>';
conf.ui.outputConsole.appendChild(line);
if(lines.length >= conf.scriptSettings.maxOutputLines.value) {
lines[0].parentNode.removeChild(lines[0]);
}
if(conf.scriptSettings.autoscrollOutput.value) conf.ui.outputConsole.scrollTo(0, conf.ui.outputConsole.scrollHeight);
}
function awqLogPublishError(p_message) { awqLogPublishMsg(p_message, 'red') }
window.addEventListener("error", (event) => {
if(conf.scriptSettings.verboseLog.value) {
awqLogPublishMsg(
`Javascript error (can be caused by something other than this script): ${event.message} source:${event.filename} line:${event.lineno} col:${event.colno} Error:${event.error ? JSON.stringify(event.error) : '' }`,
'darkorange'
);
}
},true);
window.addEventListener("unhandledrejection", (event) => {
if(conf.scriptSettings.verboseLog.value) {
awqLogPublishMsg(
`Javascript promise error (can be caused by something other than this script): ${event.reason}`,
'darkorange'
);
}
},true);
let oldWarn = window.console.warn,oldInfo = window.console.info,oldLog = window.console.log,oldError = window.console.error;
window.console.warn = function(p_msg) {
if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (warn) message (can be caused by something other than this script):' + p_msg +`<br>Call stack:<pre>${getCallStack()}</pre>`, 'lightgray'); oldWarn(p_msg);
}
window.console.info = function(p_msg) {
if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (info) message (can be caused by something other than this script):' + p_msg +`<br>Call stack:<pre>${getCallStack()}</pre>`, 'lightgray'); oldInfo(p_msg);
}
window.console.log = function(p_msg) {
if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (log) message (can be caused by something other than this script):' + p_msg +`<br>Call stack:<pre>${getCallStack()}</pre>`, 'lightgray'); oldLog(p_msg);
}
// ----------------------------------------------------------------------------- Wait for content to load
let waitForLoadInterval = setInterval(initAWQ, c_wait_tick_duration);
function initAWQ() {
window.awqConf = conf;
conf.shadowDOM.root = document.querySelector(conf.shadowDOM.sel);
if(!conf.shadowDOM.root || !conf.shadowDOM.root.querySelector('#txt2img_prompt')) return;
clearInterval(waitForLoadInterval);
conf.commonData.versionContainer.el = conf.shadowDOM.root.querySelector('#footer .versions');
// Check for extensions
for(let ext in conf.extensions) {
if(!document.querySelector(conf.extensions[ext].existCheck.sel)) {
preAwqLog(`Extension ${conf.extensions[ext].name} not found, disabling`);
conf.extensions[ext] = false;
} else {
preAwqLog(`Extension ${conf.extensions[ext].name} found`);
}
}
loadScriptSettings();
generateMainUI();
try { throw new Error(); } catch(e) { awqLog(`initAWQ: stack = ${e.stack.replace(/^(.*?)\binitAWQ/s,'')}`) }
try { eval(conf.scriptSettings.extensionScript.value);} catch(e) { awqLogPublishMsg(`Failed to load extension script, error: <pre>${e.message} l:${e.lineNumber} c:${e.columnNumber}\n${e.stack}</pre>`,'darkorange')}
function mapElementsToConf(p_object, p_info) {
for (let prop in p_object) {
if(p_object[prop].sel) {
p_object[prop].el = conf.shadowDOM.root.querySelector(p_object[prop].sel);
if(!p_object[prop].el) awqLogPublishError(`Failed to find the ${p_info} ${prop}`);
}
if(p_object[prop].sel2) {
p_object[prop].el2 = conf.shadowDOM.root.querySelector(p_object[prop].sel2);
if(!p_object[prop].el2) awqLogPublishError(`Failed to find the secondary ${p_info} ${prop}`);
}
if(p_object[prop].grad) {
let gradIndex = p_object[prop].gradIndex ? p_object[prop].gradIndex : 0;
p_object[prop].gradEl = findGradioComponentState(p_object[prop].grad)[gradIndex];
if(!p_object[prop].gradEl) awqLogPublishError(`Failed to find the gradio element ${p_info} ${prop}`);
}
if(p_object[prop].gradLab) {
p_object[prop].gradEl = findGradioComponentStateByLabel(p_object[prop].gradLab)[0];
if(!p_object[prop].gradEl) awqLogPublishError(`Failed to find the gradio element ${p_info} ${prop}`);
}
}
}
mapElementsToConf(conf.commonData, 'main object');
mapElementsToConf(conf.t2i, 't2i object');
mapElementsToConf(conf.t2i.controls, 't2i control');
mapElementsToConf(conf.i2i, 'i2i object');
mapElementsToConf(conf.i2i.controls, 'i2i control');
mapElementsToConf(conf.ext, 'ext object');
mapElementsToConf(conf.ext.controls, 'ext control');
if(conf.extensions.iBrowser) waitForElm(conf.extensions.iBrowser.guiElems.txt2img.sel).then(function() {mapElementsToConf(conf.extensions.iBrowser.guiElems, 'iBrowser objects')});
setInterval(updateStatus, c_wait_tick_duration);
}
function appendAddToQueueButton(container, top, innerHTML, onclick, title, right) {
let button = document.createElement('button');
button.innerHTML = innerHTML;
button.style.height = c_uiElemntHeight;
button.style.color = 'black';
button.style.position = 'fixed';
button.style.top = top + 'px';
button.style.right = right ? right + 'px' : 0;
button.style.opacity = conf.scriptSettings.buttonOpacity.value;
button.onclick = onclick;
button.style.cursor = "pointer";
button.title = title;
button.style.display = 'none';
button.classList.add('awq-hover-button');
container.appendChild(button);
return button;
}
function generateMainUI() {
let awqCSSElem = document.createElement('style');
awqCSSElem.innerHTML = `
#AWQ-container {
background:var(--background-fill-primary);
}
#AWQ-container button {
border:var(--button-border-width) solid var(--button-secondary-border-color);
background:var(--button-secondary-background-fill);
color:var(--button-secondary-text-color);
}
#AWQ-container input, #AWQ-container select, #AWQ-container .awq-console-line,
#awq-script-settings-popup input, #awq-script-settings-popup textarea {
box-shadow: var(--input-shadow);
border: var(--input-border-width) solid var(--input-border-color);
border-radius: var(--input-radius);
background: var(--input-background-fill);
color: var(--body-text-color);
}
#AWQ-container input.completed-queue-item {
background:var(--button-secondary-background-fill);
color:var(--button-secondary-text-color);
}
#AWQ-container .awq-console-line {
border-radius: unset;
}
#awq-script-settings-popup {
background:var(--background-fill-primary);
}
#awq-script-settings-popup label, #awq-script-settings-popup span {
color: var(--block-title-text-color);
}
`;
document.head.appendChild(awqCSSElem);
let container = document.createElement('div');
container.id = 'AWQ-container';
container.className = document.querySelector('gradio-app > div').classList.contains('dark') ? 'dark' : '';
container.style.width = c_innerUIWidth;
container.style.border = "1px solid white";
container.style.position = "relative";
container.style.zIndex = "2147483647";
document.body.appendChild(container);
let addToQueueButton = appendAddToQueueButton(container, 0, c_addToQueueButtonText, appendQueueItem, "Add an item to the queue according to current tab and settings");
let addToQueueButtonA1 = appendAddToQueueButton(container, 25, 'A1', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings1.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 1",63);
let addToQueueButtonA2 = appendAddToQueueButton(container, 25, 'A2', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings2.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 2",32);
let addToQueueButtonA3 = appendAddToQueueButton(container, 25, 'A3', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings3.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 3",1);
let unsupportedButton = appendAddToQueueButton(container, 0, 'Tab not supported', function(){}, "Not supported");
unsupportedButton.disabled = true;
unsupportedButton.innerHTML = 'Tab not supported';
unsupportedButton.style.cursor = 'not-allowed';
let defaultQueueQuantity = document.createElement('input');
defaultQueueQuantity.placeholder = 'Def #';
defaultQueueQuantity.style.height = c_uiElemntHeightSmall;
defaultQueueQuantity.style.width = '50px';
defaultQueueQuantity.type = 'number';
defaultQueueQuantity.title = "How many items of each will be added to the queue (default is 1)";
defaultQueueQuantity.value = conf.scriptSettings.defaultQuantity.value;
defaultQueueQuantity.onchange = function() {conf.scriptSettings.defaultQuantity.value = this.value;};
defaultQueueQuantity.onfocus = function() {this.select();};
container.appendChild(defaultQueueQuantity);
let assignDefaultToAll = document.createElement('button');
assignDefaultToAll.innerHTML = ' ⤵';
assignDefaultToAll.style.cursor = "pointer";
assignDefaultToAll.title = "Assign the default value to all queue items";
assignDefaultToAll.style.height = c_uiElemntHeight;
assignDefaultToAll.style.marginRight = '10px';
assignDefaultToAll.onclick = function() {
if(conf.scriptSettings.defaultQuantity.value >= 0) {
document.querySelectorAll('.AWQ-item-quantity').forEach((inp) => {inp.value = conf.scriptSettings.defaultQuantity.value});
updateQueueState();
}
};
container.appendChild(assignDefaultToAll);
let processButton = document.createElement('button');
processButton.innerHTML = c_processButtonText;
processButton.style.height = c_uiElemntHeight;
processButton.style.cursor = "pointer";
processButton.title = "Start processing the queue, click again to stop";
processButton.onclick = function() {
toggleProcessButton();
}
conf.ui.processButton = processButton;
container.appendChild(processButton);
let clearButton = document.createElement('button');
clearButton.innerHTML = "Clear queue";
clearButton.style.marginLeft = "5px";
clearButton.style.height = c_uiElemntHeight;
clearButton.style.cursor = "pointer";
clearButton.title = "Empty the queue completely";
clearButton.onclick = function() {
if(!confirm('Are you sure you want to remove everything in your queue?')) return;
queueContainer.innerHTML = c_emptyQueueString;
let oldQueueLength = conf.currentQueue.length;
conf.currentQueue = [];
updateQueueState();
awqLogPublishMsg(`Queue has been cleared, ${oldQueueLength} items removed`);
}
container.appendChild(clearButton);
let scriptSettingsButton = document.createElement('button');
scriptSettingsButton.innerHTML = "Script settings";
scriptSettingsButton.style.float = 'right';
scriptSettingsButton.style.height = c_uiElemntHeight;
scriptSettingsButton.style.cursor = "pointer";
scriptSettingsButton.title = "Open the settings popup for the script";
scriptSettingsButton.onclick = openScriptSettingsPopup;
container.appendChild(scriptSettingsButton);
let queueContainer = document.createElement('div');
queueContainer.style.width = c_innerUIWidth;
queueContainer.style.border = "1px solid white";
queueContainer.style.color = "gray";
queueContainer.style.marginBottom = "5px";
queueContainer.innerHTML = c_emptyQueueString;
container.appendChild(queueContainer);
let clearSettingButton = document.createElement('button');
clearSettingButton.innerHTML = "❌";
clearSettingButton.style.height = c_uiElemntHeight;
clearSettingButton.style.background = 'none';
clearSettingButton.onclick = function() {clearSetting(); }
clearSettingButton.style.cursor = "pointer";
clearSettingButton.title = "Remove the currently selected setting";
container.appendChild(clearSettingButton);
let settingsStorage = document.createElement('select');
settingsStorage.style.height = c_uiElemntHeight;
settingsStorage.title = "List of stored settings (template of all settings)";
container.appendChild(settingsStorage);
let editSettingButton = document.createElement('button');
editSettingButton.innerHTML = "✏️";
editSettingButton.style.height = c_uiElemntHeight;
editSettingButton.onclick = function() {editSetting(); }
editSettingButton.style.cursor = "pointer";
editSettingButton.title = "Edit the currently selected setting (a property can be removed to not change it when loading)";
container.appendChild(editSettingButton);
let loadSettingButton = document.createElement('button');
loadSettingButton.innerHTML = "Load";
loadSettingButton.style.height = c_uiElemntHeight;
loadSettingButton.onclick = function() {loadSetting(); }
loadSettingButton.style.cursor = "pointer";
loadSettingButton.title = "Load the currently selected setting (replacing current settings)";
container.appendChild(loadSettingButton);
let settingName =document.createElement('input');
settingName.placeholder = "Setting name";
settingName.style.height = c_uiElemntHeightSmall;
settingName.title = "Name to use when saving a new setting (duplicates not allowed)";
settingName.onfocus = function() {this.select();};
container.appendChild(settingName);
let saveSettingButton = document.createElement('button');
saveSettingButton.innerHTML = "Save";
saveSettingButton.style.height = c_uiElemntHeight;
saveSettingButton.onclick = function() {saveSettings(); }
saveSettingButton.style.cursor = "pointer";
saveSettingButton.title = "Save currently selected settings so that you can load them again later";
container.appendChild(saveSettingButton);
let outputConsole = document.createElement('div');
outputConsole.title = c_defaultOtputConsoleText;
outputConsole.innerHTML = c_defaultOtputConsoleTextHTML;
outputConsole.style.width = 'calc(100vw - 50px)';
outputConsole.style.border = "1px solid black";
outputConsole.style.color = "gray";
outputConsole.style.padding = "2px";
outputConsole.style.marginTop = "5px";
outputConsole.style.marginBottom = "5px";
outputConsole.style.marginLeft = "15px";
outputConsole.style.marginRight = "15px";
outputConsole.style.height = (16*10)+"px";
outputConsole.style.overflow = "auto";
//outputConsole.style.backgroundColor = "white";
outputConsole.style.boxShadow = 'inset 0px 1px 4px #666';
container.appendChild(outputConsole);
let outputConsoleClearButton = document.createElement('button');
outputConsoleClearButton.innerHTML = "Clear";
outputConsoleClearButton.style.height = c_uiElemntHeight;
outputConsoleClearButton.onclick = function() {conf.ui.outputConsole.innerHTML = c_defaultOtputConsoleTextHTML; }
outputConsoleClearButton.style.cursor = "pointer";
outputConsoleClearButton.style.marginLeft = "10px";
outputConsoleClearButton.title = "Clear the console above";
container.appendChild(outputConsoleClearButton);
conf.ui.addToQueueButton = addToQueueButton;
conf.ui.addToQueueButtonA1 = addToQueueButtonA1;
conf.ui.addToQueueButtonA2 = addToQueueButtonA2;
conf.ui.addToQueueButtonA3 = addToQueueButtonA3;
conf.ui.unsupportedButton = unsupportedButton;
conf.ui.queueContainer = queueContainer;
conf.ui.clearButton = clearButton;
conf.ui.loadSettingButton = loadSettingButton;
conf.ui.settingName = settingName;
conf.ui.settingsStorage = settingsStorage;
conf.ui.defaultQueueQuantity = defaultQueueQuantity;
conf.ui.outputConsole = outputConsole;
document.querySelector('.gradio-container').style.overflow = 'visible'; // Fix so that a dropdown menu can overlap the queue
refreshSettings();
if(conf.currentQueue.length > 0) {
awqLog('Loaded saved queue:'+conf.currentQueue.length);
for(let i = 0; i < conf.currentQueue.length; i++) {
appendQueueItem(conf.currentQueue[i].quantity, conf.currentQueue[i].value, conf.currentQueue[i].type);
}
updateQueueState();
}
awqLog('generateMainUI: Completed');
}
function appendQueueItem(p_quantity, p_value, p_type, p_overwrite_data) {
awqLog('appendQueueItem: quantity:' + p_quantity + ' type:' + p_type);
let quantity = isNaN(p_quantity) || p_quantity == null ?
(parseInt(conf.ui.defaultQueueQuantity.value) > 0 ?
parseInt(conf.ui.defaultQueueQuantity.value) : 1) : p_quantity;
let queueItem = document.createElement('div');
queueItem.style.width = c_innerUIWidth;
let itemType =document.createElement('input');
itemType.classList = 'AWQ-item-type';
itemType.style.display = "50px";
itemType.style.height = c_uiElemntHeightSmall;
itemType.style.width = "20px";
itemType.title = "This is the type/tab for the queue item";
itemType.disabled = true;
let itemQuantity = document.createElement('input');
function updateItemQuantityBG() {
if(itemQuantity.value.length == 0) { itemQuantity.style.color = 'red'; }
else if(itemQuantity.value < 1) { itemQuantity.style.color = 'rgb(0, 225, 0)'; itemQuantity.classList.add('completed-queue-item') }
else if(itemQuantity.value > 0) { itemQuantity.style.color = 'white'; itemQuantity.classList.remove('completed-queue-item')}
}
itemQuantity.classList = 'AWQ-item-quantity';
itemQuantity.value = quantity;
itemQuantity.style.width = "50px";
itemQuantity.type = 'number';
itemQuantity.style.height = c_uiElemntHeightSmall;
itemQuantity.onchange = function() {
updateItemQuantityBG();
updateQueueState();
};
updateItemQuantityBG();
itemQuantity.onfocus = function() {this.select();};
itemQuantity.title = "This is how many times this item should be executed";
let itemJSON =document.createElement('input');
itemJSON.classList = 'AWQ-item-JSON';
itemJSON.value = p_value || getValueJSON(p_type);
if(p_overwrite_data) {
awqLog(`appendQueueItem: Adding to queue with Overwriting: ${JSON.stringify(p_overwrite_data)}`);
let jsonData = JSON.parse(itemJSON.value);
for(let setKey in p_overwrite_data) {
jsonData[setKey] = p_overwrite_data[setKey];
}
itemJSON.value = JSON.stringify(jsonData);
}
itemJSON.style.width = "calc(100vw - 290px)";
itemJSON.style.height = "18px";
itemJSON.onchange = function() {
updateQueueState();
// Update itemType if needed
let newType = itemJSON.value.match(/"type":"([^"]+)"/);
newType = newType ? newType[1] : null;
if(newType != itemType.value) itemType.value = newType;
}
itemJSON.title = "This is a JSON string with all the settings to be used for this item. Can be changed while processing the queue but will fail if you enter invalid values.";
let JSONType = itemJSON.value.match(/"type":"([^"]+)"/);
JSONType = JSONType ? JSONType[1] : conf.commonData.activeType;
itemType.value = p_type || JSONType;
let removeItem =document.createElement('button');
removeItem.innerHTML = '❌';
removeItem.style.height = c_uiElemntHeight;
removeItem.style.background = 'none';
removeItem.style.cursor = "pointer";
removeItem.title = "Remove this item from the queue";
removeItem.onclick = function() {
this.parentNode.parentNode.removeChild(this.parentNode);
updateQueueState();
awqLogPublishMsg(`Removed queue item`);
};
let moveItemUp =document.createElement('button');
moveItemUp.innerHTML = '⇧';
moveItemUp.style.height = c_uiElemntHeight;
moveItemUp.style.cursor = "pointer";
moveItemUp.title = "Move this item up in the queue";
moveItemUp.onclick = function() {
let tar = this.parentNode;
if(tar.previousSibling) {
tar.parentNode.insertBefore(tar, tar.previousSibling);
awqLogPublishMsg(`Rearranged queue`);
updateQueueState();
}
};
let moveItemDown =document.createElement('button');
moveItemDown.innerHTML = '⇩';
moveItemDown.style.height = c_uiElemntHeight;
moveItemDown.style.cursor = "pointer";
moveItemDown.title = "Move this item down in the queue";
moveItemDown.onclick = function() {
let tar = this.parentNode;
if(tar.nextSibling) {
tar.parentNode.insertBefore(tar.nextSibling, tar);
awqLogPublishMsg(`Rearranged queue`);
updateQueueState();
}
};
let moveItemBottom =document.createElement('button');
moveItemBottom.innerHTML = '⤓';
moveItemBottom.style.height = c_uiElemntHeight;
moveItemBottom.style.cursor = "pointer";
moveItemBottom.title = "Move this item to the bottom of the queue";
moveItemBottom.onclick = function() {
let tar = this.parentNode;
if(tar.parentNode.lastChild !== tar) {
tar.parentNode.appendChild(tar);
updateQueueState();
}
};
let moveItemTop =document.createElement('button');
moveItemTop.innerHTML = '⤒';
moveItemTop.style.height = c_uiElemntHeight;
moveItemTop.style.cursor = "pointer";
moveItemTop.title = "Move this item to the top of the queue";
moveItemTop.onclick = function() {
let tar = this.parentNode;
let parentFirstChild = tar.parentNode.firstChild;
if(parentFirstChild && parentFirstChild !== tar) {
tar.parentNode.insertBefore(tar, parentFirstChild);
awqLogPublishMsg(`Rearranged queue`);
updateQueueState();
}
};
let loadItem =document.createElement('button');
loadItem.innerHTML = 'Load';
loadItem.style.height = c_uiElemntHeight;
loadItem.style.cursor = "pointer";
loadItem.title = "Load the settings from this item";
loadItem.onclick = async function() {
let itemRow = this.parentNode;
await loadJson(itemRow.querySelector('.AWQ-item-JSON').value);
};
queueItem.appendChild(removeItem);
queueItem.appendChild(moveItemUp);
queueItem.appendChild(moveItemDown);
queueItem.appendChild(moveItemBottom);
queueItem.appendChild(moveItemTop);
queueItem.appendChild(loadItem);
queueItem.appendChild(itemType);
queueItem.appendChild(itemQuantity);
queueItem.appendChild(itemJSON);
if(conf.ui.queueContainer.innerHTML == c_emptyQueueString) conf.ui.queueContainer.innerHTML = "";
conf.ui.queueContainer.appendChild(queueItem);
awqLogPublishMsg(`Added new ${itemType.value} queue item (${quantity}x)`);
// Wait with updating state while loading a predefined queue
if(isNaN(p_quantity)) updateQueueState();
}
function saveScriptSettings() {
awqLog('Saving script settings');
let scriptSettingsCopy = structuredClone(conf.scriptSettings);
// Delete data that does not need to be saved
for(let ssk in scriptSettingsCopy) {
for(let ssk2 in scriptSettingsCopy[ssk]) {
if(ssk2 != 'value') delete scriptSettingsCopy[ssk][ssk2];
}
}
conf.ui.defaultQueueQuantity.value = conf.scriptSettings.defaultQuantity.value; // Update beacuse this one is in two places
localStorage.awqScriptSettings = JSON.stringify(scriptSettingsCopy);
}
function loadScriptSettings(p_scriptSettings) {
if(!localStorage.hasOwnProperty("awqScriptSettings") || !isJsonString(localStorage.awqScriptSettings)) return;
awqLog('Loding saved script settings');
let savedSettings = p_scriptSettings || JSON.parse(localStorage.awqScriptSettings);
for(let ssk in conf.scriptSettings) {
if(savedSettings.hasOwnProperty(ssk)) conf.scriptSettings[ssk].value = savedSettings[ssk].value;
}
}
function openScriptSettingsPopup() {
let dialog = document.createElement('span');
dialog.id = 'awq-script-settings-popup';
dialog.className = document.querySelector('gradio-app > div').classList.contains('dark') ? 'dark' : '';
dialog.style.minWidth = '90%';
dialog.style.minHeight = '90%';
dialog.style.marginLeft = '5%';
dialog.style.marginTop = '5%';
dialog.style.top = '0';
dialog.style.position = 'fixed';
dialog.style.zIndex = '1000';
dialog.style.borderRadius = '15px';
dialog.style.boxShadow = '3px 3px 100px black,3px 3px 500px black, 3px 3px 25px black, inset 0 0 10px black';
let titleText = document.createElement('span');
titleText.innerHTML = '<b>Script settings</b> - <i>hold your mouse over an item for a description</i>';
titleText.style.top = '5px';
titleText.style.left = '10px';
titleText.style.position = 'absolute';
let closeButton = document.createElement('span');
closeButton.style.position = 'absolute';
closeButton.style.top = '5px';
closeButton.style.right = '10px';
closeButton.style.textShadow = '#292929 2px 3px 5px';
closeButton.style.cursor = 'pointer';
closeButton.onclick = function() {document.body.removeChild(dialog); saveScriptSettings();};
closeButton.innerHTML = '⛌';
let dialogBody = document.createElement('span');
dialogBody.style.width = '90%';
dialogBody.style.height = '90%';
dialogBody.style.marginLeft = '5%';
dialogBody.style.marginTop = 'max(5%,45px)';
dialogBody.style.top = '0';
dialogBody.style.position = 'absolute';
dialogBody.style.overflow = 'auto';
dialogBody.style.display = 'grid';
dialogBody.style.gridAutoFlow = 'row';
dialogBody.style.gridTemplateColumns = 'repeat(auto-fit, minmax(200px, 1fr))';
dialog.appendChild(titleText);
dialog.appendChild(closeButton);
dialog.appendChild(dialogBody);
// Create input for each script setting
for(let ssKey in conf.scriptSettings) {
let ssObj = conf.scriptSettings[ssKey];
let ssElem = document.createElement(ssObj.type == 'text' ? 'textarea' : 'input');
ssElem.id = 'awq-ss-'+ssKey;
ssElem.placeholder = ssObj.name;
ssElem.value = ssObj.value;
ssElem.style.height = ssObj.type == 'text' ? '40px' : '20px';
ssElem.style.marginRight = '20px';