Skip to content

Instantly share code, notes, and snippets.

@paradoxally
Last active July 25, 2024 23:53
Show Gist options
  • Save paradoxally/008ab041ecb4e558d2396bbb2278c5b4 to your computer and use it in GitHub Desktop.
Save paradoxally/008ab041ecb4e558d2396bbb2278c5b4 to your computer and use it in GitHub Desktop.
Apollo User Agent Intercept
@interface __NSCFLocalSessionTask : NSObject <NSCopying, NSProgressReporting>
@end
%hook __NSCFLocalSessionTask
- (void)_onqueue_resume {
NSURLRequest *request = [self valueForKey:@"_originalRequest"];
NSString *requestURL = request.URL.absoluteString;
if ([requestURL containsString:@"reddit.com"]) {
NSMutableURLRequest *mutableRequest = [request mutableCopy];
// Change this to whatever you like
[mutableRequest setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36" forHTTPHeaderField:@"User-Agent"];
[self setValue:mutableRequest forKey:@"_originalRequest"];
[self setValue:mutableRequest forKey:@"_currentRequest"];
}
%orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment