aboutsummaryrefslogtreecommitdiff
path: root/src/utils/quickCss.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-12-01 03:01:44 +0100
committerVendicated <vendicated@riseup.net>2022-12-01 03:01:44 +0100
commitf94cbfb2f498a121a5dbb3a22acdb74b446c952b (patch)
tree5f0ca0cc8f6483309e40a7d00587b0d57ca5fd47 /src/utils/quickCss.ts
parentfc09460d82dc30e7393a659411f40bc011528294 (diff)
downloadVencord-f94cbfb2f498a121a5dbb3a22acdb74b446c952b.tar.gz
Vencord-f94cbfb2f498a121a5dbb3a22acdb74b446c952b.tar.bz2
Vencord-f94cbfb2f498a121a5dbb3a22acdb74b446c952b.zip
Add basic themes tab
Diffstat (limited to 'src/utils/quickCss.ts')
-rw-r--r--src/utils/quickCss.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts
index 1f9f235..de4eaef 100644
--- a/src/utils/quickCss.ts
+++ b/src/utils/quickCss.ts
@@ -21,6 +21,7 @@ import { addSettingsListener, Settings } from "@api/settings";
import IpcEvents from "./IpcEvents";
let style: HTMLStyleElement;
+let themesStyle: HTMLStyleElement;
export async function toggle(isEnabled: boolean) {
if (!style) {
@@ -35,7 +36,22 @@ export async function toggle(isEnabled: boolean) {
style.disabled = !isEnabled;
}
+async function initThemes() {
+ if (!themesStyle) {
+ themesStyle = document.createElement("style");
+ themesStyle.id = "vencord-themes";
+ document.head.appendChild(themesStyle);
+ }
+
+ const { themeLinks } = Settings;
+ const links = themeLinks.map(link => `@import url("${link.trim()}");`).join("\n");
+ themesStyle.textContent = links;
+}
+
document.addEventListener("DOMContentLoaded", () => {
toggle(Settings.useQuickCss);
addSettingsListener("useQuickCss", toggle);
+
+ initThemes();
+ addSettingsListener("themeLinks", initThemes);
});