From 7f649dae6f1a04d6a7c76c381da8a436d6990576 Mon Sep 17 00:00:00 2001 From: ririxi Date: Wed, 5 Feb 2025 16:07:03 +0100 Subject: [PATCH 1/4] feat: migrate state folders --- spicetify.go | 1 + src/utils/path-utils.go | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/spicetify.go b/spicetify.go index 59de163f32..1a6ee47b4f 100644 --- a/spicetify.go +++ b/spicetify.go @@ -111,6 +111,7 @@ func init() { } utils.MigrateConfigFolder() + utils.MigrateFolders() cmd.InitConfig(quiet) if len(commands) < 1 { diff --git a/src/utils/path-utils.go b/src/utils/path-utils.go index c158d66cea..fbb259e4d6 100644 --- a/src/utils/path-utils.go +++ b/src/utils/path-utils.go @@ -24,6 +24,52 @@ func MigrateConfigFolder() { } } +func MigrateFolders() { + backupPath := filepath.Join(GetSpicetifyFolder(), "Backup") + extractedPath := filepath.Join(GetSpicetifyFolder(), "Extracted") + + if _, err := os.Stat(backupPath); err == nil { + newBackupPath := GetStateFolder("Backup") + oldAbs, err := filepath.Abs(backupPath) + if err != nil { + Fatal(err) + } + newAbs, err := filepath.Abs(newBackupPath) + if err != nil { + Fatal(err) + } + + if oldAbs != newAbs { + PrintBold("Migrating spicetify state (Backup, Extracted) folders") + err := Copy(backupPath, newBackupPath, true, nil) + if err != nil { + Fatal(err) + } + os.RemoveAll(backupPath) + } + } + + if _, err := os.Stat(extractedPath); err == nil { + newExtractedPath := GetStateFolder("Extracted") + oldAbs, err := filepath.Abs(extractedPath) + if err != nil { + Fatal(err) + } + newAbs, err := filepath.Abs(newExtractedPath) + if err != nil { + Fatal(err) + } + if oldAbs != newAbs { + PrintBold("Migrating spicetify state (Backup, Extracted) folders") + err := Copy(extractedPath, newExtractedPath, true, nil) + if err != nil { + Fatal(err) + } + os.RemoveAll(extractedPath) + } + } +} + func ReplaceEnvVarsInString(input string) string { var replacements []string for _, v := range os.Environ() { From 741bcc112b81d4de8a7c1d872bab32abb21c247c Mon Sep 17 00:00:00 2001 From: ririxi Date: Wed, 5 Feb 2025 23:50:09 +0100 Subject: [PATCH 2/4] fix(expFeatures): make it work on versions without `RemoteConfigDebugAPI` --- jsHelper/expFeatures.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsHelper/expFeatures.js b/jsHelper/expFeatures.js index f8eff46ba3..a7e6f78f00 100644 --- a/jsHelper/expFeatures.js +++ b/jsHelper/expFeatures.js @@ -166,7 +166,8 @@ } isFallback = false; notice.remove(); - remoteConfiguration = Spicetify?.RemoteConfigResolver?.remoteConfiguration ?? (await Spicetify.Platform?.RemoteConfigDebugAPI.getProperties()); + remoteConfiguration = + Spicetify?.RemoteConfigResolver.value?.remoteConfiguration ?? (await Spicetify.Platform?.RemoteConfigDebugAPI.getProperties()); })(); for (const key of Object.keys(overrideList)) { From 923669e79ba6d14b57574f48d624d8b740cefc09 Mon Sep 17 00:00:00 2001 From: ririxi Date: Wed, 5 Feb 2025 23:50:27 +0100 Subject: [PATCH 3/4] feat(wrapper): add smooth scrolling for Spotify 1.2.56 --- jsHelper/spicetifyWrapper.js | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 988ff2c874..aa68a5fec1 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -306,6 +306,51 @@ window.Spicetify = { Platform: {}, }; +// Based on https://blog.aziz.tn/2025/01/spotify-fix-lagging-issue-on-scrolling.html +function applyScrollingFix() { + const scrollableElements = Array.from(document.querySelectorAll("*")).filter((el) => { + if ( + el.id === "context-menu" || + el.closest("#context-menu") || + el.getAttribute("role") === "dialog" || + el.classList.contains("popup") || + el.getAttribute("aria-haspopup") === "true" + ) + return false; + + const style = window.getComputedStyle(el); + return style.overflow === "auto" || style.overflow === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll"; + }); + + for (const el of scrollableElements) { + if (!el.hasAttribute("data-scroll-optimized")) { + el.style.willChange = "transform"; + el.style.transform = "translate3d(0, 0, 0)"; + el.setAttribute("data-scroll-optimized", "true"); + } + } +} + +const observer = new MutationObserver(applyScrollingFix); + +observer.observe(document.body, { + childList: true, + subtree: true, + attributes: false, +}); + +const originalPushState = history.pushState; +history.pushState = function (...args) { + originalPushState.apply(this, args); + setTimeout(applyScrollingFix, 100); +}; + +window.addEventListener("popstate", () => { + setTimeout(applyScrollingFix, 100); +}); + +applyScrollingFix(); + (function waitForPlatform() { if (!Spicetify._platform) { setTimeout(waitForPlatform, 50); From 7a53725144472b7e66bf2c3d0a0082715847ea48 Mon Sep 17 00:00:00 2001 From: ririxi Date: Thu, 6 Feb 2025 00:14:30 +0100 Subject: [PATCH 4/4] fix(homeConfig): make the regex work on more versions --- src/apply/apply.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apply/apply.go b/src/apply/apply.go index 945f67c6bc..7c424ba2aa 100644 --- a/src/apply/apply.go +++ b/src/apply/apply.go @@ -361,10 +361,10 @@ func insertHomeConfig(jsPath string, flags Flag) { return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3]) }) - // >= 1.2.45 + // >= 1.2.40 utils.ReplaceOnce( &content, - `(&&"HomeShortsSectionData".*\],)([a-zA-Z])(\}\)\()`, + `(&&"HomeShortsSectionData".*?[\],}])([a-zA-Z])(\}\)?\()`, func(submatches ...string) string { return fmt.Sprintf("%sSpicetifyHomeConfig.arrange(%s)%s", submatches[1], submatches[2], submatches[3]) })