From d938ad3a87ab0eb8547d5d71a6fa25561293ef29 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 4 Apr 2025 09:19:21 -0400 Subject: [PATCH] Fix BetterFolders For QuickCSS --- src/utils/quickCss.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 94c7a5e0..f6c74bfb 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -44,15 +44,36 @@ export async function toggle(isEnabled: boolean) { if (!style) { if (isEnabled) { style = createStyle("vencord-custom-css"); + VencordNative.quickCss.addChangeListener(css => { + css = patchSidebar(css); style.textContent = css; - // At the time of writing this, changing textContent resets the disabled state style.disabled = !Settings.useQuickCss; }); - style.textContent = await VencordNative.quickCss.get(); + + const css = await VencordNative.quickCss.get(); + style.textContent = patchSidebar(css); } - } else + } else { style.disabled = !isEnabled; + } +} + +function patchSidebar(css: string): string { + if ( + css.includes("grid-template-columns") || + css.includes("grid-template-areas") + ) { + css = css.replace( + /(["'])([^"']*?)guildsList\s+/g, + (_, quote, pre) => `${quote}${pre}guildsList sidebar ` + ); + css = css.replace( + /guildsEnd\]/g, + "guildsEnd] min-content [sidebarEnd]" + ); + } + return css; } async function initThemes() {