From efe8503241cb257ea93eb3c8e6ddd3c2753a41bb Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichorn@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:51:56 -0600 Subject: [PATCH] More YTNoTracking Improvements Planning on trying to focus on YTNoTracking to take care of the other issues related to stripping Tracking Params & URLs. --- uYouPlus.xm | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/uYouPlus.xm b/uYouPlus.xm index 15f28ef..e2b3ba6 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -508,15 +508,62 @@ static void repositionCreateTab(YTIGuideResponse *response) { - (BOOL)enablePlayerBarForVerticalVideoWhenControlsHiddenInFullscreen { return YES; } %end -// YTNoTracking - https://github.com/arichorn/YTNoTracking/ +// YTNoTracking - @arichorn - https://github.com/arichorn/YTNoTracking/ %hook YTICompactLinkRenderer -+ (BOOL)hasTrackingParams { return NO; } ++ (BOOL)hasTrackingParams { + return NO; +} %end %hook YTIReelPlayerOverlayRenderer -+ (BOOL)hasTrackingParams { return NO; } ++ (BOOL)hasTrackingParams { + return NO; +} %end +%hook YTIShareTargetServiceUpdateRenderer ++ (BOOL)hasTrackingParams { + return NO; +} +%new +- (id)removeParameterFromURL:(id)arg1 { + NSURLComponents *components = [NSURLComponents componentsWithURL:arg1 resolvingAgainstBaseURL:NO]; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (name == %@)", @"si"]; + NSArray *filteredQueryItems = [components.queryItems filteredArrayUsingPredicate:predicate]; + components.queryItems = filteredQueryItems; + + NSURL *modifiedURL = components.URL; + if (!modifiedURL) { + modifiedURL = arg1; + } + return modifiedURL; +} +%end + +int main(int argc, char * argv[]) { + @autoreleasepool { + NSURL *originalURL = [NSURL URLWithString:@"https://www.youtube.com/watch?v=your_video_id&si=abcd1234"]; + NSURLComponents *components = [NSURLComponents componentsWithURL:originalURL resolvingAgainstBaseURL:NO]; + NSMutableArray *queryItems = [NSMutableArray arrayWithArray:components.queryItems]; + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (name == 'si' OR name BEGINSWITH 'si=')"]; + [queryItems filterUsingPredicate:predicate]; + components.queryItems = queryItems; + NSURL *cleanedURL = components.URL; + + if (cleanedURL) { + [[UIApplication sharedApplication] openURL:cleanedURL options:@{} completionHandler:^(BOOL success) { + if (success) { + NSLog(@"URL opened successfully!"); + } else { + NSLog(@"Failed to open URL"); + } + }]; + } + } + return 0; +} + // YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo %hook YTMainAppVideoPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data {