Skip to content

Commit 8a05bef

Browse files
committed
fixes and improvements
1 parent 48c9c50 commit 8a05bef

File tree

6 files changed

+121
-10
lines changed

6 files changed

+121
-10
lines changed

Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
1010
let shouldReplaceLyrics = LyricsGroup.isActive
1111

1212
return (shouldReplaceLyrics && url.isLyrics)
13-
|| (shouldPatchPremium && (url.isCustomize || url.isPremiumPlanRow || url.isPlanOverview))
13+
|| (shouldPatchPremium && (url.isCustomize || url.isPremiumPlanRow || url.isPremiumBadge || url.isPlanOverview))
1414
}
1515

1616
// orion:new
@@ -59,6 +59,11 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
5959
return
6060
}
6161

62+
if url.isPremiumBadge {
63+
respondWithCustomData(try getPremiumPlanBadge(), task: task, session: session)
64+
return
65+
}
66+
6267
var customizeMessage = try CustomizeMessage(serializedBytes: buffer)
6368
modifyRemoteConfiguration(&customizeMessage.response)
6469

Sources/EeveeSpotify/Lyrics/NowPlayingScrollViewControllerInstanceHook.x.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@ class NowPlayingScrollViewControllerInstanceHook: ClassHook<UIViewController> {
2121
return nowPlayingScrollViewController!
2222
}
2323
}
24+
25+
class NowPlayingScrollPrivateServiceImplementationHook: ClassHook<NSObject> {
26+
typealias Group = LyricsGroup
27+
static let targetName = "NowPlaying_ScrollImpl.NowPlayingScrollPrivateServiceImplementation"
28+
29+
func provideScrollViewControllerWithDependencies(_ dependencies: NSObject) -> UIViewController {
30+
// spotify introduced some "nova scroll" with different controllers and logic
31+
// hope they don't remove backward compatibility, i don't want to rewrite ts 😭🙏
32+
33+
if EeveeSpotify.hookTarget != .lastAvailableiOS14 {
34+
Ivars<Bool>(target).$__lazy_storage_$_isNovaScrollEnabled = false
35+
}
36+
37+
return orig.provideScrollViewControllerWithDependencies(dependencies)
38+
}
39+
}

Sources/EeveeSpotify/Premium/DynamicPremium+ModifyingFunctions.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Foundation
2+
import UIKit
23

34
func modifyRemoteConfiguration(_ configuration: inout UcsResponse) {
45
if UserDefaults.overwriteConfiguration {
@@ -17,10 +18,6 @@ func modifyAttributes(_ attributes: inout [String: AccountAttribute]) {
1718
attributes["ads"] = AccountAttribute.with {
1819
$0.boolValue = false
1920
}
20-
21-
attributes["audio-quality"] = AccountAttribute.with {
22-
$0.stringValue = "1"
23-
}
2421

2522
attributes["can_use_superbird"] = AccountAttribute.with {
2623
$0.boolValue = true
@@ -34,10 +31,6 @@ func modifyAttributes(_ attributes: inout [String: AccountAttribute]) {
3431
$0.stringValue = "pr:premium,tc:0"
3532
}
3633

37-
attributes["high-bitrate"] = AccountAttribute.with {
38-
$0.boolValue = true
39-
}
40-
4134
attributes["is-eligible-premium-unboxing"] = AccountAttribute.with {
4235
$0.boolValue = true
4336
}

Sources/EeveeSpotify/Premium/DynamicPremium+PremiumPlanRow.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import Foundation
22

3+
func getPremiumPlanBadge() throws -> Data {
4+
let badge = YourPremiumBadge.with {
5+
$0.name = "Eevee"
6+
$0.version = 2
7+
$0.colorCode = "#FFD2D7"
8+
}
9+
10+
return try badge.serializedData()
11+
}
12+
313
func getPremiumPlanRowData(originalPremiumPlanRow: PremiumPlanRow) throws -> Data {
414
var premiumPlanRow = originalPremiumPlanRow
515

@@ -14,7 +24,7 @@ func getPlanOverviewData() throws -> Data {
1424
let plan = SpotifyPlan.with {
1525
$0.notice = SpotifyPlan.Notice.with {
1626
$0.message = "payment_notice".localized
17-
$0.status = 2 // 0 - trial, 1 - prepaid, 2 - subsription
27+
$0.status = 2 // 0 - trial, 1 - prepaid, 2 - subsсription
1828
}
1929
$0.subscription = SpotifyPlan.SubscriptionInfo.with {
2030
$0.planVariant = 2
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// DO NOT EDIT.
2+
// swift-format-ignore-file
3+
// swiftlint:disable all
4+
//
5+
// Generated by the Swift generator plugin for the protocol buffer compiler.
6+
// Source: YourPremiumBadge.proto
7+
//
8+
// For information on using the generated types, please see the documentation:
9+
// https://github.com/apple/swift-protobuf/
10+
11+
import SwiftProtobuf
12+
13+
// If the compiler emits an error on this type, it is because this file
14+
// was generated by a version of the `protoc` Swift plug-in that is
15+
// incompatible with the version of SwiftProtobuf to which you are linking.
16+
// Please ensure that you are building against the same version of the API
17+
// that was used to generate this file.
18+
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
19+
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
20+
typealias Version = _2
21+
}
22+
23+
struct YourPremiumBadge: Sendable {
24+
// SwiftProtobuf.Message conformance is added in an extension below. See the
25+
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
26+
// methods supported on all messages.
27+
28+
var name: String = String()
29+
30+
var version: Int32 = 0
31+
32+
var colorCode: String = String()
33+
34+
var unknownFields = SwiftProtobuf.UnknownStorage()
35+
36+
init() {}
37+
}
38+
39+
// MARK: - Code below here is support for the SwiftProtobuf runtime.
40+
41+
extension YourPremiumBadge: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
42+
static let protoMessageName: String = "YourPremiumBadge"
43+
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
44+
1: .same(proto: "name"),
45+
2: .same(proto: "version"),
46+
3: .standard(proto: "color_code"),
47+
]
48+
49+
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
50+
while let fieldNumber = try decoder.nextFieldNumber() {
51+
// The use of inline closures is to circumvent an issue where the compiler
52+
// allocates stack space for every case branch when no optimizations are
53+
// enabled. https://github.com/apple/swift-protobuf/issues/1034
54+
switch fieldNumber {
55+
case 1: try { try decoder.decodeSingularStringField(value: &self.name) }()
56+
case 2: try { try decoder.decodeSingularInt32Field(value: &self.version) }()
57+
case 3: try { try decoder.decodeSingularStringField(value: &self.colorCode) }()
58+
default: break
59+
}
60+
}
61+
}
62+
63+
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
64+
if !self.name.isEmpty {
65+
try visitor.visitSingularStringField(value: self.name, fieldNumber: 1)
66+
}
67+
if self.version != 0 {
68+
try visitor.visitSingularInt32Field(value: self.version, fieldNumber: 2)
69+
}
70+
if !self.colorCode.isEmpty {
71+
try visitor.visitSingularStringField(value: self.colorCode, fieldNumber: 3)
72+
}
73+
try unknownFields.traverse(visitor: &visitor)
74+
}
75+
76+
static func ==(lhs: YourPremiumBadge, rhs: YourPremiumBadge) -> Bool {
77+
if lhs.name != rhs.name {return false}
78+
if lhs.version != rhs.version {return false}
79+
if lhs.colorCode != rhs.colorCode {return false}
80+
if lhs.unknownFields != rhs.unknownFields {return false}
81+
return true
82+
}
83+
}

Sources/EeveeSpotify/Shared/Models/Extensions/URL+Extension.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ extension URL {
1212
var isPremiumPlanRow: Bool {
1313
self.path.contains("v1/GetPremiumPlanRow")
1414
}
15+
16+
var isPremiumBadge: Bool {
17+
self.path.contains("GetYourPremiumBadge")
18+
}
1519

1620
var isOpenSpotifySafariExtension: Bool {
1721
self.host == "eevee"

0 commit comments

Comments
 (0)