diff --git a/packages/marketplace/src/components/Card/Card.tsx b/packages/marketplace/src/components/Card/Card.tsx index 0fb31567..5e9eaaf9 100644 --- a/packages/marketplace/src/components/Card/Card.tsx +++ b/packages/marketplace/src/components/Card/Card.tsx @@ -280,6 +280,11 @@ class Card extends React.Component { @@ -82,6 +86,9 @@ import { const activeScheme = themeManifest.schemes[themeManifest.activeScheme]; injectColourScheme(activeScheme); + // Add to Spicetify.Config + Spicetify.Config.color_scheme = themeManifest.activeScheme; + if (localStorage.getItem(LOCALSTORAGE_KEYS.colorShift) === "true") { initColorShiftLoop(themeManifest.schemes); } @@ -102,6 +109,9 @@ import { const userCSS = await parseCSS(themeManifest); injectUserCSS(userCSS); + // Add to Spicetify.Config + Spicetify.Config.current_theme = themeManifest.manifest?.name; + // Inject any included js if (themeManifest.include && themeManifest.include.length) { // console.log("Including js", installedThemeData.include); @@ -119,12 +129,18 @@ import { newScript.src = `${src}?time=${Date.now()}`; newScript.classList.add("marketplaceScript"); document.body.appendChild(newScript); + + // Add to Spicetify.Config + addExtensionToSpicetifyConfig(script); }); } }; console.log("Loaded Marketplace extension"); + // Save to Spicetify.Config for use when removing a theme + Spicetify.Config.local_theme = Spicetify.Config.current_theme; + Spicetify.Config.local_color_scheme = Spicetify.Config.color_scheme; const installedThemeKey = localStorage.getItem(LOCALSTORAGE_KEYS.themeInstalled); if (installedThemeKey) initializeTheme(installedThemeKey); diff --git a/packages/marketplace/src/logic/Utils.ts b/packages/marketplace/src/logic/Utils.ts index 7825be1a..fa9deea5 100644 --- a/packages/marketplace/src/logic/Utils.ts +++ b/packages/marketplace/src/logic/Utils.ts @@ -445,3 +445,12 @@ export const sanitizeUrl = (url: string) => { return "about:blank"; return url; }; + +export const addExtensionToSpicetifyConfig = (main?: string) => { + if (!main) return; + + const name = main.split("/").pop(); + if (name && Spicetify.Config.extensions.indexOf(name) === -1) { + Spicetify.Config.extensions.push(name); + } +}; diff --git a/packages/marketplace/src/types/spicetify.d.ts b/packages/marketplace/src/types/spicetify.d.ts index 0bea8df3..2ce6fc09 100644 --- a/packages/marketplace/src/types/spicetify.d.ts +++ b/packages/marketplace/src/types/spicetify.d.ts @@ -1371,9 +1371,13 @@ declare namespace Spicetify { */ namespace Config { const version: string; - const current_theme: string; - const color_scheme: string; - const extensions: string[]; + let current_theme: string; + let color_scheme: string; + let extensions: string[]; const custom_apps: string[]; + + // These two are just added by Marketplace so we can save and restore them when removing a theme + let local_theme: string; + let local_color_scheme: string; } }