diff --git a/Sources/EeveeSpotify/Models/Extensions/URL+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/URL+Extension.swift index 44e4276..0ef6302 100644 --- a/Sources/EeveeSpotify/Models/Extensions/URL+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/URL+Extension.swift @@ -4,4 +4,8 @@ extension URL { var isLyrics: Bool { self.path.contains("color-lyrics/v2") } + + var isOpenSpotifySafariExtension: Bool { + self.host == "eevee" + } } \ No newline at end of file diff --git a/Sources/EeveeSpotify/OpenSpotify.x.swift b/Sources/EeveeSpotify/OpenSpotify.x.swift index 76cdae9..8f0aa2a 100644 --- a/Sources/EeveeSpotify/OpenSpotify.x.swift +++ b/Sources/EeveeSpotify/OpenSpotify.x.swift @@ -1,27 +1,17 @@ import Orion import UIKit -class SpotifySceneDelegateHook: ClassHook { +class UIOpenURLContextHook: ClassHook { - static let targetName = "MusicApp_ContainerWiring.SpotifySceneDelegate" + static let targetName = "UIOpenURLContext" - func scene(_ scene: UIScene, continueUserActivity userActivity: NSUserActivity) { - orig.scene(scene, continueUserActivity: userActivity) - } + func URL() -> URL { + let url = orig.URL() - func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { - - let url = URLContexts.first!.url - - if url.host == "eevee" { - - let userActivity = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb) - userActivity.webpageURL = URL(string: "https:/\(url.path)") - - orig.scene(scene, continueUserActivity: userActivity) - return + if url.isOpenSpotifySafariExtension { + return Foundation.URL(string: "https:/\(orig.URL().path)")! } - - orig.scene(scene, openURLContexts: URLContexts) + + return url } }