diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java index e6c1c1f8..001b4137 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/spoof/SpoofClientPatch.java @@ -18,6 +18,13 @@ public class SpoofClientPatch { private static final String UNREACHABLE_HOST_URI_STRING = "https://127.0.0.0"; private static final Uri UNREACHABLE_HOST_URI = Uri.parse(UNREACHABLE_HOST_URI_STRING); + /** + * Tracking URL authority to use when spoofing the client to iOS, + * because watch history is not working on brand accounts. + * See <a href="https://github.com/LuanRT/YouTube.js/blob/3153375bcaa6c03afba9da8474e6a9d37471ed29/src/core/mixins/MediaInfo.ts#L152">LuanRT/YouTube.js</a>. + */ + private static final String WWW_TRACKING_URL_AUTHORITY = "www.youtube.com"; + /** * Injection point. * Blocks /get_watch requests by returning an unreachable URI. @@ -127,6 +134,19 @@ public class SpoofClientPatch { return original; } + /** + * Injection point. + * When spoofing the client to iOS, history is not working on brand accounts. + * Replace the tracking URL authority to {@link SpoofClientPatch#WWW_TRACKING_URL_AUTHORITY} to fix this. + */ + public static Uri overrideTrackingUrl(Uri trackingUrl) { + if (SPOOF_CLIENT_ENABLED && SPOOF_CLIENT_TYPE == ClientType.IOS) { + return trackingUrl.buildUpon().authority(WWW_TRACKING_URL_AUTHORITY).build(); + } + + return trackingUrl; + } + private enum ClientType { // https://dumps.tadiphone.dev/dumps/oculus/eureka ANDROID_VR(28, "Quest 3", "1.56.21"),