From 5bc24a5d78ad32a7eae40cb76b09c5cfd3b8a4de Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Mon, 25 Sep 2023 19:00:03 +0100 Subject: [PATCH] feat: guards to prevent compiling this on web --- src/utils/quickCss.ts | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 344fdf5e..44b7946b 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -60,13 +60,12 @@ export async function toggle(isEnabled: boolean) { async function initThemes() { themesStyle ??= createStyle("vencord-themes"); - const { themeLinks, enabledThemes, userCssVars } = Settings; + const { themeLinks, enabledThemes } = Settings; const links: string[] = [...themeLinks]; if (IS_WEB) { - // UserCSS handled separately - for (const theme of enabledThemes) if (!theme.endsWith(".user.css")) { + for (const theme of enabledThemes) { const themeData = await VencordNative.themes.getThemeData(theme); if (!themeData) continue; @@ -79,24 +78,26 @@ async function initThemes() { } } - for (const theme of enabledThemes) if (theme.endsWith(".user.css")) { - // UserCSS goes through a compile step first - const css = await compileUsercss(theme); - if (!css) { - // let's not leave the user in the dark about this and point them to where they can find the error - Toasts.show({ - message: `Failed to compile ${theme}, check the console for more info.`, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); - continue; - } + if (!IS_WEB || "armcord" in window) { + for (const theme of enabledThemes) if (theme.endsWith(".user.css")) { + // UserCSS goes through a compile step first + const css = await compileUsercss(theme); + if (!css) { + // let's not leave the user in the dark about this and point them to where they can find the error + Toasts.show({ + message: `Failed to compile ${theme}, check the console for more info.`, + type: Toasts.Type.FAILURE, + id: Toasts.genId(), + options: { + position: Toasts.Position.BOTTOM + } + }); + continue; + } - const blob = new Blob([css], { type: "text/css" }); - links.push(URL.createObjectURL(blob)); + const blob = new Blob([css], { type: "text/css" }); + links.push(URL.createObjectURL(blob)); + } } themesStyle.textContent = links.map(link => `@import url("${link.trim()}");`).join("\n");