| 4548 | 4550 | |
| 4549 | 4551 | await loadSettings(); |
| 4550 | 4552 | $('body').addClass('sd'); |
| 4553 | + |
| 4554 | + const getMacroValue = ({ isNegative }) => { |
| 4555 | + if (selected_group || this_chid === undefined) { |
| 4556 | + return ''; |
| 4557 | + } |
| 4558 | + |
| 4559 | + const key = getCharaFilename(this_chid); |
| 4560 | + let characterPrompt = key ? (extension_settings.sd.character_prompts[key] || '') : ''; |
| 4561 | + let negativePrompt = key ? (extension_settings.sd.character_negative_prompts[key] || '') : ''; |
| 4562 | + |
| 4563 | + const context = getContext(); |
| 4564 | + const sharedPromptData = context?.characters[this_chid]?.data?.extensions?.sd_character_prompt; |
| 4565 | + |
| 4566 | + if (typeof sharedPromptData?.positive === 'string' && !characterPrompt && sharedPromptData.positive) { |
| 4567 | + characterPrompt = sharedPromptData.positive || ''; |
| 4568 | + } |
| 4569 | + if (typeof sharedPromptData?.negative === 'string' && !negativePrompt && sharedPromptData.negative) { |
| 4570 | + negativePrompt = sharedPromptData.negative || ''; |
| 4571 | + } |
| 4572 | + |
| 4573 | + return isNegative ? negativePrompt : characterPrompt; |
| 4574 | + }; |
| 4575 | + |
| 4576 | + MacrosParser.registerMacro('charPrefix', () => getMacroValue({ isNegative: false }), t`Character's positive positive Image Generation prompt prefix`); |
| 4577 | + MacrosParser.registerMacro('charNegativePrefix', () => getMacroValue({ isNegative: true }), t`Character's negative Image Generation prompt prefix`); |
| 4551 | 4578 | }); |