diff --git a/comfy-theme/custom-settings.js b/comfy-theme/custom-settings.js index 3beffd0..ed89bc0 100644 --- a/comfy-theme/custom-settings.js +++ b/comfy-theme/custom-settings.js @@ -22,8 +22,7 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue inputEl.classList.add('inputDefault-_djjkz', 'input-cIJ7To'); inputEl.placeholder = placeholder; inputEl.type = 'text'; - inputEl.value = initialValue ? initialValue : ''; - + inputWrapEl.appendChild(inputEl); // Button field @@ -47,6 +46,16 @@ export function textInputField(text, subtext, placeholder, onApply, initialValue dividerEl.classList.add('divider-3573oO', 'dividerDefault-3rvLe-'); dividerEl.style.marginTop = subtext ? '20px' : '45px'; + // Insertion checker + // A bit hacky... + // But works :) + let insertCheckId = setInterval(() => { + if (el.parentNode != null) { + inputEl.value = initialValue != undefined ? initialValue() : ''; + clearInterval(insertCheckId); + } + }, 1000); + el.appendChild(textEl); el.appendChild(buttonEl); el.appendChild(inputWrapEl); diff --git a/comfy-theme/goosemodModule.json b/comfy-theme/goosemodModule.json index ee7d85a..5056a88 100644 --- a/comfy-theme/goosemodModule.json +++ b/comfy-theme/goosemodModule.json @@ -7,5 +7,5 @@ "authors": ["265924886461939712", "186496078273708033"], - "version": "1.1.0" + "version": "1.2.0" } diff --git a/comfy-theme/index.js b/comfy-theme/index.js index 93c43b4..0918261 100644 --- a/comfy-theme/index.js +++ b/comfy-theme/index.js @@ -112,11 +112,6 @@ export default { type: "header", text: "USRBG settings", }, - { - type: "text", - text: "USRBG modal x offset", - subtext: `Default: ${defaultSettings.usrbgXoff}`, - }, { type: "custom", element: textInputField( @@ -127,23 +122,47 @@ export default { settings.usrbgXoff = value; updateVars(); }, - settings ? settings.usrbgXoff : "" + () => settings.usrbgXoff, ), }, { - type: "text", - text: "USRBG modal y offset", - subtext: `Default: ${defaultSettings.usrbgYoff}`, + type: "custom", + element: textInputField( + "USRBG modal y offset", + `Default: ${defaultSettings.usrbgYoff}`, + defaultSettings.usrbgYoff, + value => { + settings.usrbgYoff = value; + updateVars(); + }, + () => settings.usrbgYoff, + ), }, { - type: "text", - text: "USRBG modal width", - subtext: `Default: ${defaultSettings.usrbgWidth}`, + type: "custom", + element: textInputField( + "USRBG modal width", + `Default: ${defaultSettings.usrbgWidth}`, + defaultSettings.usrbgWidth, + value => { + settings.usrbgWidth = value; + updateVars(); + }, + () => settings.usrbgWidth, + ), }, { - type: "text", - text: "USRBG modal height", - subtext: `Default: ${defaultSettings.usrbgHeight}`, + type: "custom", + element: textInputField( + "USRBG modal height", + `Default: ${defaultSettings.usrbgHeight}`, + defaultSettings.usrbgHeight, + value => { + settings.usrbgHeight = value; + updateVars(); + }, + () => settings.usrbgHeight, + ), }, { @@ -151,19 +170,43 @@ export default { text: "User info settings (avatar, popout and modal)", }, { - type: "text", - text: "Modal avatar roundness", - subtext: `Default: ${defaultSettings.modalAvatarRoundness}`, + type: "custom", + element: textInputField( + "Avatar roundness", + `Default: ${defaultSettings.modalAvatarRoundness}`, + defaultSettings.modalAvatarRoundness, + value => { + settings.modalAvatarRoundness = value; + updateVars(); + }, + () => settings.modalAvatarRoundness, + ), }, { - type: "text", - text: "Modal avatar width", - subtext: `Default: ${defaultSettings.modalAvatarWidth}`, + type: "custom", + element: textInputField( + "Modal avatar width", + `Default: ${defaultSettings.modalAvatarWidth}`, + defaultSettings.modalAvatarWidth, + value => { + settings.modalAvatarWidth = value; + updateVars(); + }, + () => settings.modalAvatarWidth, + ), }, { - type: "text", - text: "Popout role circles' size (0px to remove them)", - subtext: `Default: ${defaultSettings.popoutRoleCircles}`, + type: "custom", + element: textInputField( + "Popout role circles' size (0px to remove them)", + `Default: ${defaultSettings.popoutRoleCircles}`, + defaultSettings.popoutRoleCircles, + value => { + settings.popoutRoleCircles = value; + updateVars(); + }, + () => settings.popoutRoleCircles, + ), }, { @@ -171,9 +214,17 @@ export default { text: "Server list settings", }, { - type: "text", - text: "Server icon roundness", - subtext: `Default: ${defaultSettings.serverIconRoundness}`, + type: "custom", + element: textInputField( + "Server icon roundness", + `Default: ${defaultSettings.serverIconRoundness}`, + defaultSettings.serverIconRoundness, + value => { + settings.serverIconRoundness = value; + updateVars(); + }, + () => settings.serverIconRoundness, + ), }, {