diff --git a/src/api/mods.js b/src/api/mods.js index fb51fc4..8818b51 100644 --- a/src/api/mods.js +++ b/src/api/mods.js @@ -24,15 +24,15 @@ const getMods = async () => { }, getThemes = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("themes/")); + return mods.filter(({ _src }) => _src.startsWith("themes/")); }, getExtensions = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("extensions/")); + return mods.filter(({ _src }) => _src.startsWith("extensions/")); }, getIntegrations = async () => { const mods = await getMods(); - return mods.find(({ _src }) => _src.startsWith("integrations/")); + return mods.filter(({ _src }) => _src.startsWith("integrations/")); }; const getProfile = async () => { diff --git a/src/core/client.mjs b/src/core/client.mjs index 9d54d90..bd4ffe6 100644 --- a/src/core/client.mjs +++ b/src/core/client.mjs @@ -7,8 +7,17 @@ const notionSidebar = `.notion-sidebar-container .notion-sidebar > :nth-child(3) > div > :nth-child(2)`; export default async (api, db) => { - const { platform, enhancerUrl, onMessage, sendMessage } = api, - { html, addMutationListener, addKeyListener } = api, + const { + html, + platform, + getThemes, + isEnabled, + enhancerUrl, + onMessage, + sendMessage, + addMutationListener, + addKeyListener, + } = api, openMenuHotkey = await db.get("openMenuHotkey"), menuButtonIconStyle = await db.get("menuButtonIconStyle"), loadThemeOverrides = await db.get("loadThemeOverrides"), @@ -16,7 +25,12 @@ export default async (api, db) => { // appearance - if (loadThemeOverrides) { + const enabledThemes = (await getThemes()).map((theme) => isEnabled(theme.id)), + forceLoadOverrides = loadThemeOverrides === "Enabled", + autoLoadOverrides = + loadThemeOverrides === "Auto" && + (await Promise.all(enabledThemes)).some((enabled) => enabled); + if (forceLoadOverrides || autoLoadOverrides) { document.head.append(html` { >