From 3207240d6d854b9d50971ebb96590b80e223579a Mon Sep 17 00:00:00 2001 From: em Date: Wed, 3 Jul 2024 22:41:21 +0200 Subject: [PATCH] fix: adapt `Cosmos` and `ConfirmDialog` for `1.2.41` (#3089) --- jsHelper/spicetifyWrapper.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 13808aba2b..1a83b2cbe1 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -310,11 +310,13 @@ window.Spicetify = { }; (function addProxyCosmos() { - if (!Spicetify.Player.origin?._cosmos) { + if (!Spicetify.Player.origin?._cosmos && !Spicetify.Platform?.Registry) { setTimeout(addProxyCosmos, 50); return; } + const _cosmos = Spicetify.Player.origin?._cosmos ?? Spicetify.Platform?.Registry._map.get(Symbol.for("Cosmos")).instance; + const corsProxyURL = "https://cors-proxy.spicetify.app"; const allowedMethodsMap = { get: "get", @@ -394,7 +396,7 @@ window.Spicetify = { } }; - Spicetify.Player.origin._cosmos = new Proxy(Spicetify.Player.origin._cosmos, handler); + Spicetify.Player.origin._cosmos = new Proxy(_cosmos, handler); Object.defineProperty(Spicetify, "CosmosAsync", { get: () => { return Spicetify.Player.origin?._cosmos; @@ -697,6 +699,13 @@ window.Spicetify = { } }); + const confirmDialogChunk = chunks.find( + ([, value]) => value.toString().includes("confirmDialog") && value.toString().includes("shouldCloseOnEsc") && value.toString().includes("isOpen") + ); + if (!Spicetify.ReactComponent?.ConfirmDialog && confirmDialogChunk) { + Spicetify.ReactComponent.ConfirmDialog = Object.values(require(confirmDialogChunk[0])).find(m => typeof m === "object"); + } + const contextMenuChunk = chunks.find(([, value]) => value.toString().includes("toggleContextMenu")); if (contextMenuChunk) { Spicetify.ReactComponent.ContextMenu = Object.values(require(contextMenuChunk[0])).find(m => typeof m === "function");