// ==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 Negative prompt: a1: b1, a2: b2, etc Template: