diff --git a/public/scripts/extensions/gallery/index.js b/public/scripts/extensions/gallery/index.js index a39634603..94b8c30c7 100644 --- a/public/scripts/extensions/gallery/index.js +++ b/public/scripts/extensions/gallery/index.js @@ -277,7 +277,7 @@ function makeMovable(id = 'gallery') { const newElement = $(template); newElement.css('background-color', 'var(--SmartThemeBlurTintColor)'); newElement.attr('forChar', id); - newElement.attr('id', `${id}`); + newElement.attr('id', `draggable_${id}`); newElement.find('.drag-grabber').attr('id', `${id}header`); newElement.find('.dragTitle').text('Image Gallery'); //add a div for the gallery diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 1e69d3608..c25f275c7 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -3962,6 +3962,95 @@ $(document).ready(() => { `, })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ + name: 'css-var', + /** @param {{to: string, varname: string }} args @param {string} value @returns {string} */ + callback: (args, value) => { + // Map enum to target selector + const targetSelector = { + chat: '#chat', + background: '#bg1', + gallery: '#draggable_gallery', + zoomedAvatar: 'div.zoomed_avatar', + }[args.to || 'chat']; + + if (!targetSelector) { + toastr.error(`Invalid target: ${args.to}`); + return; + } + + if (!args.varname) { + toastr.error('CSS variable name is required'); + return; + } + if (!args.varname.startsWith('--')) { + toastr.error('CSS variable names must start with "--"'); + return; + } + + const elements = document.querySelectorAll(targetSelector); + if (elements.length === 0) { + toastr.error(`No elements found for ${args.to ?? 'chat'} with selector "${targetSelector}"`); + return; + } + + elements.forEach(element => { + element.style.setProperty(args.varname, value); + }); + + console.info(`Set CSS variable "${args.varname}" to "${value}" on "${targetSelector}"`); + }, + namedArgumentList: [ + SlashCommandNamedArgument.fromProps({ + name: 'varname', + description: 'CSS variable name (starting with double dashes)', + typeList: [ARGUMENT_TYPE.STRING], + isRequired: true, + }), + SlashCommandNamedArgument.fromProps({ + name: 'to', + description: 'The target element to which the CSS variable will be applied', + typeList: [ARGUMENT_TYPE.STRING], + enumList: [ + new SlashCommandEnumValue('chat', null, enumTypes.enum, enumIcons.message), + new SlashCommandEnumValue('background', null, enumTypes.enum, enumIcons.image), + new SlashCommandEnumValue('zoomedAvatar', null, enumTypes.enum, enumIcons.character), + new SlashCommandEnumValue('gallery', null, enumTypes.enum, enumIcons.image), + ], + defaultValue: 'chat', + }), + ], + unnamedArgumentList: [ + SlashCommandArgument.fromProps({ + description: 'CSS variable value', + typeList: [ARGUMENT_TYPE.STRING], + isRequired: true, + }), + ], + helpString: ` +
+ Sets a CSS variable to a specified value on a target element. +
+ Only setting of variable names is supported. They have to be prefixed with double dashes ("--exampleVar"). + Setting actual CSS properties is not supported. Custom CSS in the theme settings can be used for that. +

+ This value will be gone after a page reload! +
+
+ Example: + +
+ `, + })); SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'movingui', callback: setmovingUIPreset, diff --git a/public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js b/public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js index b96b83a53..9003cb754 100644 --- a/public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js +++ b/public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js @@ -37,6 +37,7 @@ export const enumIcons = { voice: '🎤', server: '🖥️', popup: '🗔', + image: '🖼️', true: '✔️', false: '❌',