| 2916 | const text = await workflowResponse.text(); | 2916 | const text = await workflowResponse.text(); |
| 2917 | toastr.error(`Failed to load workflow.\n\n${text}`); | 2917 | toastr.error(`Failed to load workflow.\n\n${text}`); |
| 2918 | } | 2918 | } |
| 2919 | let workflow = (await workflowResponse.json()).replace('"%prompt%"', JSON.stringify(prompt)); | 2919 | let workflow = (await workflowResponse.json()).replaceAll('"%prompt%"', JSON.stringify(prompt)); |
| 2920 | workflow = workflow.replace('"%negative_prompt%"', JSON.stringify(negativePrompt)); | 2920 | workflow = workflow.replaceAll('"%negative_prompt%"', JSON.stringify(negativePrompt)); |
| 2921 | | 2921 | |
| 2922 | const seed = extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : Math.round(Math.random() * Number.MAX_SAFE_INTEGER); | 2922 | const seed = extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : Math.round(Math.random() * Number.MAX_SAFE_INTEGER); |
| 2923 | workflow = workflow.replaceAll('"%seed%"', JSON.stringify(seed)); | 2923 | workflow = workflow.replaceAll('"%seed%"', JSON.stringify(seed)); |
| 2924 | placeholders.forEach(ph => { | 2924 | placeholders.forEach(ph => { |
| 2925 | workflow = workflow.replace(`"%${ph}%"`, JSON.stringify(extension_settings.sd[ph])); | 2925 | workflow = workflow.replaceAll(`"%${ph}%"`, JSON.stringify(extension_settings.sd[ph])); |
| 2926 | }); | 2926 | }); |
| 2927 | (extension_settings.sd.comfy_placeholders ?? []).forEach(ph => { | 2927 | (extension_settings.sd.comfy_placeholders ?? []).forEach(ph => { |
| 2928 | workflow = workflow.replace(`"%${ph.find}%"`, JSON.stringify(substituteParams(ph.replace))); | 2928 | workflow = workflow.replaceAll(`"%${ph.find}%"`, JSON.stringify(substituteParams(ph.replace))); |
| 2929 | }); | 2929 | }); |
| 2930 | if (/%user_avatar%/gi.test(workflow)) { | 2930 | if (/%user_avatar%/gi.test(workflow)) { |
| 2931 | const response = await fetch(getUserAvatarUrl()); | 2931 | const response = await fetch(getUserAvatarUrl()); |
| 2932 | if (response.ok) { | 2932 | if (response.ok) { |
| 2933 | const avatarBlob = await response.blob(); | 2933 | const avatarBlob = await response.blob(); |
| 2934 | const avatarBase64 = await getBase64Async(avatarBlob); | 2934 | const avatarBase64 = await getBase64Async(avatarBlob); |
| 2935 | workflow = workflow.replace('"%user_avatar%"', JSON.stringify(avatarBase64)); | 2935 | workflow = workflow.replaceAll('"%user_avatar%"', JSON.stringify(avatarBase64)); |
| 2936 | } else { | 2936 | } else { |
| 2937 | workflow = workflow.replace('"%user_avatar%"', JSON.stringify(PNG_PIXEL)); | 2937 | workflow = workflow.replaceAll('"%user_avatar%"', JSON.stringify(PNG_PIXEL)); |
| 2938 | } | 2938 | } |
| 2939 | } | 2939 | } |
| 2940 | if (/%char_avatar%/gi.test(workflow)) { | 2940 | if (/%char_avatar%/gi.test(workflow)) { |