@@ -55,16 +55,37 @@ static OSStatus SecItemUpdate_replacement(CFDictionaryRef query, CFDictionaryRef
55
55
});
56
56
}
57
57
58
+ // Reddit API Credentials
58
59
Class _RDKOAuthCredential = objc_getClass (" RDKOAuthCredential" );
59
60
if (_RDKOAuthCredential) {
60
61
61
62
Method clientIdMethod = class_getInstanceMethod (_RDKOAuthCredential, sel_registerName (" clientIdentifier" ));
62
63
IMP replacementImp = imp_implementationWithBlock (^NSString *(id _self) {
63
64
return [[NSUserDefaults standardUserDefaults ] valueForKey: @" ApolloRedditAPIClientID" ];
64
65
});
66
+
65
67
method_setImplementation (clientIdMethod, replacementImp);
66
68
}
67
69
70
+ // Randomize User-Agent
71
+ Class _RDKClient = objc_getClass (" RDKClient" );
72
+ if (_RDKClient) {
73
+
74
+ Method userAgentMethod = class_getInstanceMethod (_RDKClient, sel_registerName (" userAgent" ));
75
+ IMP userAgentReplacementImp = imp_implementationWithBlock (^NSString *(id _self) {
76
+ static dispatch_once_t once;
77
+ static NSString *newUserAgent;
78
+ dispatch_once (&once, ^{
79
+ newUserAgent = [NSString stringWithFormat: @" iOS: com.%@ .%@ v%d .%d .%d (by /u/%@ )" , RANDSTRING, RANDSTRING, RANDINT, RANDINT, RANDINT, RANDSTRING];
80
+ });
81
+
82
+ return newUserAgent;
83
+ });
84
+
85
+ method_setImplementation (userAgentMethod, userAgentReplacementImp);
86
+ }
87
+
88
+ // Imgur API credentials
68
89
Class _NSURLSessionConfiguration = objc_getClass (" NSURLSessionConfiguration" );
69
90
Method setHeadersMethod = class_getInstanceMethod (_NSURLSessionConfiguration, sel_registerName (" setHTTPAdditionalHeaders:" ));
70
91
IMP originalSetHeadersImp = method_getImplementation (setHeadersMethod);
@@ -84,7 +105,7 @@ static OSStatus SecItemUpdate_replacement(CFDictionaryRef query, CFDictionaryRef
84
105
headers = newHeaders;
85
106
}
86
107
87
- ((void (*)(id , SEL , id ))originalSetHeadersImp)(_self, NSSelectorFromString ( @ " setHTTPAdditionalHeaders:" ), headers);
108
+ ((void (*)(id , SEL , id ))originalSetHeadersImp)(_self, sel_registerName ( " setHTTPAdditionalHeaders:" ), headers);
88
109
});
89
110
90
111
method_setImplementation (setHeadersMethod, replacementSetHeadersImp);
0 commit comments