Skip to content

Commit febac2e

Browse files
committed
feat: add partial support for Spotify 1.2.64
1 parent 63e77e6 commit febac2e

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

jsHelper/spicetifyWrapper.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ applyScrollingFix();
732732
const listOfComponents = [
733733
"ScrollableContainer",
734734
"Slider",
735+
"Dropdown",
735736
"Toggle",
736737
"Cards.Artist",
737738
"Cards.Audiobook",
@@ -782,6 +783,18 @@ applyScrollingFix();
782783
);
783784
Object.assign(Spicetify.ReactComponent.Cards, Object.fromEntries(cards));
784785

786+
// chunks
787+
const dropdownChunk = chunks.find(([, value]) => value.toString().includes("dropDown") && value.toString().includes("isSafari"));
788+
if (dropdownChunk) {
789+
Spicetify.ReactComponent.Dropdown =
790+
Object.values(require(dropdownChunk[0]))?.[0]?.render ?? Object.values(require(dropdownChunk[0])).find((m) => typeof m === "function");
791+
}
792+
793+
const toggleChunk = chunks.find(([, value]) => value.toString().includes("onSelected") && value.toString().includes('type:"checkbox"'));
794+
if (toggleChunk && !Spicetify.ReactComponent.Toggle) {
795+
Spicetify.ReactComponent.Toggle = Object.values(require(toggleChunk[0]))[0].render;
796+
}
797+
785798
if (!listOfComponents.every((component) => Spicetify.ReactComponent[component] !== undefined)) {
786799
setTimeout(waitForChunks, 100);
787800
return;
@@ -888,11 +901,6 @@ applyScrollingFix();
888901
);
889902
}
890903

891-
const dropdownChunk = chunks.find(([, value]) => value.toString().includes("dropDown") && value.toString().includes("isSafari"));
892-
if (dropdownChunk) {
893-
Spicetify.ReactComponent.Dropdown = Object.values(require(dropdownChunk[0])).find((m) => typeof m === "function");
894-
}
895-
896904
const infiniteQueryChunk = chunks.find(
897905
([_, value]) => value.toString().includes("fetchPreviousPage") && value.toString().includes("getOptimisticResult")
898906
);

src/preprocess/preprocess.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func Start(version string, spotifyBasePath string, extractedAppsPath string, fla
215215
content = exposeAPIs_vendor(content, printPatch)
216216
}
217217

218-
content = exposeGraphQL(content, printPatch)
218+
content = additionalPatches(content, printPatch)
219219
}
220220
printPatch("CSS (JS): Patching our mappings into file")
221221
for k, v := range cssTranslationMap {
@@ -239,7 +239,7 @@ func Start(version string, spotifyBasePath string, extractedAppsPath string, fla
239239
printPatch("Remove RTL")
240240
content = removeRTL(content)
241241
}
242-
if fileName == "xpui.css" {
242+
if fileName == "xpui.css" || fileName == "xpui-snapshot.css" {
243243
printPatch("Extra CSS Patch")
244244
content = content + `
245245
.main-gridContainer-fixedWidth{grid-template-columns: repeat(auto-fill, var(--column-width));width: calc((var(--column-count) - 1) * var(--grid-gap)) + var(--column-count) * var(--column-width));}.main-cardImage-imageWrapper{background-color: var(--card-color, #333);border-radius: 6px;-webkit-box-shadow: 0 8px 24px rgba(0, 0, 0, .5);box-shadow: 0 8px 24px rgba(0, 0, 0, .5);padding-bottom: 100%;position: relative;width:100%;}.main-cardImage-image,.main-card-imagePlaceholder{height: 100%;left: 0;position: absolute;top: 0;width: 100%};.main-content-view{height:100%;}
@@ -798,7 +798,7 @@ func removeRTL(input string) string {
798798
return applyPatches(input, rtlPatches)
799799
}
800800

801-
func exposeGraphQL(input string, report logPatch) string {
801+
func additionalPatches(input string, report logPatch) string {
802802
graphQLPatches := []Patch{
803803
{
804804
Name: "GraphQL definitions (<=1.2.30)",
@@ -814,13 +814,20 @@ func exposeGraphQL(input string, report logPatch) string {
814814
return fmt.Sprintf(`=Spicetify.GraphQL.Definitions["%s"]%s`, submatches[2], submatches[1])
815815
},
816816
},
817+
{
818+
Name: "Search bug fix (1.2.57<= and >=1.2.28)",
819+
Regex: `(typeName\\])`,
820+
Replacement: func(submatches ...string) string {
821+
return fmt.Sprintf(`%s || []`, submatches[1])
822+
},
823+
},
817824
}
818825

819826
return applyPatches(input, graphQLPatches, report)
820827
}
821828

822829
func exposeAPIs_main(input string, report logPatch) string {
823-
inputContextMenu := utils.FindFirstMatch(input, `.*value:"contextmenu"`)
830+
inputContextMenu := utils.FindFirstMatch(input, `.*(?:value:"contextmenu"|"[^"]*":"context-menu")`)
824831
if len(inputContextMenu) > 0 {
825832
croppedInput := inputContextMenu[0]
826833
react := utils.FindLastMatch(croppedInput, `([a-zA-Z_\$][\w\$]*)\.useRef`)[1]
@@ -841,7 +848,7 @@ func exposeAPIs_main(input string, report logPatch) string {
841848
target = "e.triggerRef"
842849
}
843850

844-
utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\([\w_$]+\.[\w_$]+,\{value:"contextmenu"[^\}]+\}\)\}\)`, func(submatches ...string) string {
851+
utils.Replace(&input, `\(0,([\w_$]+)\.jsx\)\((?:[\w_$]+\.[\w_$]+,\{value:"contextmenu"[^}]+\}\)\}\)|"[\w-]+",\{[^}]+:"context-menu"[^}]+\}\))`, func(submatches ...string) string {
845852
return fmt.Sprintf("(0,%s.jsx)((Spicetify.ContextMenuV2._context||(Spicetify.ContextMenuV2._context=%s.createContext(null))).Provider,{value:{props:%s?.props,trigger:%s,target:%s},children:%s})", submatches[1], react, menu, trigger, target, submatches[0])
846853
})
847854
}

0 commit comments

Comments
 (0)