More YTNoTracking Improvements

Planning on trying to focus on YTNoTracking to take care of the other issues related to stripping Tracking Params & URLs.
This commit is contained in:
arichornlover 2023-11-18 17:51:56 -06:00 committed by GitHub
parent 4cb8c9b5da
commit efe8503241
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<NSURLQueryItem *> *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<NSURLQueryItem *> *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 {