-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.4: fixed settings issue, implemented popup on data reload, blocked…
… store review
- Loading branch information
Showing
9 changed files
with
226 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Orion | ||
import UIKit | ||
import StoreKit | ||
|
||
// uncomment if you're building for jailbreak, cause ipa crashes: | ||
// Fatal error: Error in tweak EeveeSpotify: Failed to hook method -[SKStoreReviewController requestReview:] (Could not hook method) | ||
// Fatal error: Error in tweak EeveeSpotify: Failed to hook method -[SKStoreReviewController requestReviewInScene:] (Could not hook method) | ||
|
||
// class SKStoreReviewControllerHook: ClassHook<SKStoreReviewController> { | ||
// func requestReview() { } | ||
// func requestReviewInScene(_ scene: UIWindowScene) { } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Foundation | ||
|
||
class OfflineHelper { | ||
|
||
static let persistentCachePath = FileManager.default.urls( | ||
for: .applicationSupportDirectory, in: .userDomainMask | ||
) | ||
.first! | ||
.appendingPathComponent("PersistentCache") | ||
|
||
// | ||
|
||
static var offlineBnkPath: URL { | ||
persistentCachePath.appendingPathComponent("offline.bnk") | ||
} | ||
|
||
static var eeveeBnkPath: URL { | ||
persistentCachePath.appendingPathComponent("eevee.bnk") | ||
} | ||
|
||
static var offlineBnkData: Data { | ||
get throws { try Data(contentsOf: offlineBnkPath) } | ||
} | ||
|
||
static var eeveeBnkData: Data { | ||
get throws { try Data(contentsOf: eeveeBnkPath) } | ||
} | ||
|
||
// | ||
|
||
private static func writeOfflineBnkData(_ data: Data) throws { | ||
try data.write(to: offlineBnkPath) | ||
} | ||
|
||
private static func writeEeveeBnkData(_ data: Data) throws { | ||
try data.write(to: eeveeBnkPath) | ||
} | ||
|
||
// | ||
|
||
static func restoreFromEeveeBnk() throws { | ||
try writeOfflineBnkData(try eeveeBnkData) | ||
} | ||
|
||
static func backupToEeveeBnk() throws { | ||
try writeEeveeBnkData(try offlineBnkData) | ||
} | ||
|
||
static func patchOfflineBnk() throws { | ||
|
||
let fileData = try offlineBnkData | ||
|
||
let usernameLength = Int(fileData[8]) | ||
let username = Data(fileData[9..<9 + usernameLength]) | ||
|
||
var blankData = try BundleHelper.shared.premiumBlankData() | ||
|
||
blankData.insert(UInt8(usernameLength), at: 8) | ||
blankData.insert(contentsOf: username, at: 9) | ||
|
||
try writeOfflineBnkData(blankData) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Orion | ||
|
||
class HookedInstances { | ||
static var productState: SPTCoreProductState? | ||
} | ||
|
||
class SPTCoreProductStateInstanceHook: ClassHook<NSObject> { | ||
|
||
static let targetName = "SPTCoreProductState" | ||
|
||
func stringForKey(_ key: String) -> String { | ||
|
||
HookedInstances.productState = Dynamic.convert( | ||
target, | ||
to: SPTCoreProductState.self | ||
) | ||
return orig.stringForKey(key) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
@objc protocol SPTCoreProductState { | ||
func stringForKey(_ key: String) -> String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Foundation | ||
import UIKit | ||
|
||
func exitApplication() { | ||
|
||
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil) | ||
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { _ in | ||
exit(EXIT_SUCCESS) | ||
} | ||
} | ||
|
||
class OfflineObserver: NSObject, NSFilePresenter { | ||
|
||
var presentedItemURL: URL? | ||
var presentedItemOperationQueue: OperationQueue | ||
|
||
override init() { | ||
presentedItemURL = OfflineHelper.offlineBnkPath | ||
presentedItemOperationQueue = .main | ||
} | ||
|
||
func presentedItemDidChange() { | ||
|
||
let productState = HookedInstances.productState! | ||
|
||
if productState.stringForKey("player-license") == "premium" { | ||
|
||
do { | ||
try OfflineHelper.backupToEeveeBnk() | ||
NSLog("[EeveeSpotify] Settings has changed, updated eevee.bnk") | ||
} | ||
catch { | ||
NSLog("[EeveeSpotify] Unable to update eevee.bnk: \(error)") | ||
} | ||
|
||
return | ||
} | ||
|
||
PopUpHelper.showPopUp( | ||
message: "Spotify has just reloaded user data, and you've been switched to the Free plan. It's fine; simply restart the app, and the tweak will patch the data again. If this doesn't work, there might be a problem with the saved data. You can reset it and restart the app. Note: after resetting, you need to restart the app twice.", | ||
buttonText: "Restart App", | ||
secondButtonText: "Reset Data and Restart App", | ||
onPrimaryClick: { | ||
exitApplication() | ||
}, | ||
onSecondaryClick: { | ||
try! FileManager.default.removeItem(at: OfflineHelper.persistentCachePath) | ||
exitApplication() | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters