- Fix BunnyLog compile error in Sideloading.x (leftover from Bunny->Revenge rename; only RevengeLog is defined) - Remove duplicated -loadConfig/+defaultConfig methods in LoaderConfig.m - Repoint CI's ipa-patcher download at a live mirror with a pinned checksum (Cristiandis/ipa-patcher was deleted upstream) - Add a second injection hook on RCTInstance/-_loadScriptFromSource: for React Native's Bridgeless mode, alongside the existing RCTCxxBridge hook. Discord's Android build already runs Bridgeless (confirmed via revenge-xposed's hook targets) and revenge-bundle now pins RN 0.81, which defaults to it - so the legacy bridge hook this tweak relied on was very likely dead. Unverified against a real device; see AUDIT.md. See AUDIT.md for the full iOS-vs-Android comparison and remaining gaps.
99 lines
3.3 KiB
Objective-C
99 lines
3.3 KiB
Objective-C
#import "LoaderConfig.h"
|
|
#import "Utils.h"
|
|
#import "Logger.h"
|
|
|
|
@implementation LoaderConfig
|
|
|
|
- (instancetype)init {
|
|
self = [super init];
|
|
if (self) {
|
|
self.customLoadUrlEnabled = NO;
|
|
self.customLoadUrl = [NSURL URLWithString:@"http://localhost:4040/revenge.js"];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (BOOL)loadConfig {
|
|
NSURL *loaderConfigUrl = [getPyoncordDirectory() URLByAppendingPathComponent:@"loader.json"];
|
|
RevengeLog(@"Attempting to load config from: %@", loaderConfigUrl.path);
|
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:loaderConfigUrl.path]) {
|
|
NSError *error = nil;
|
|
NSData *data = [NSData dataWithContentsOfURL:loaderConfigUrl];
|
|
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
|
|
if (error) {
|
|
RevengeLog(@"Error parsing loader config: %@", error);
|
|
return NO;
|
|
}
|
|
|
|
if (json) {
|
|
NSDictionary *customLoadUrl = json[@"customLoadUrl"];
|
|
if (customLoadUrl) {
|
|
self.customLoadUrlEnabled = [customLoadUrl[@"enabled"] boolValue];
|
|
NSString *urlString = customLoadUrl[@"url"];
|
|
if (urlString) {
|
|
self.customLoadUrl = [NSURL URLWithString:urlString];
|
|
}
|
|
}
|
|
|
|
RevengeLog(@"Loader config loaded - Custom URL %@: %@",
|
|
self.customLoadUrlEnabled ? @"enabled" : @"disabled",
|
|
self.customLoadUrl.absoluteString);
|
|
return YES;
|
|
}
|
|
}
|
|
|
|
RevengeLog(@"Using default loader config: %@", self.customLoadUrl.absoluteString);
|
|
return NO;
|
|
}
|
|
|
|
+ (instancetype)defaultConfig {
|
|
LoaderConfig *config = [[LoaderConfig alloc] init];
|
|
config.customLoadUrlEnabled = NO;
|
|
config.customLoadUrl = [NSURL URLWithString:@"http://localhost:4040/revenge.js"];
|
|
return config;
|
|
}
|
|
|
|
+ (instancetype)getLoaderConfig {
|
|
RevengeLog(@"Getting loader config");
|
|
|
|
NSURL *loaderConfigUrl = [getPyoncordDirectory() URLByAppendingPathComponent:@"loader.json"];
|
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:loaderConfigUrl.path]) {
|
|
NSError *error = nil;
|
|
NSData *data = [NSData dataWithContentsOfURL:loaderConfigUrl];
|
|
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
|
|
if (json && !error) {
|
|
LoaderConfig *config = [[LoaderConfig alloc] init];
|
|
NSDictionary *customLoadUrl = json[@"customLoadUrl"];
|
|
if (customLoadUrl) {
|
|
config.customLoadUrlEnabled = [customLoadUrl[@"enabled"] boolValue];
|
|
NSString *urlString = customLoadUrl[@"url"];
|
|
if (urlString) {
|
|
config.customLoadUrl = [NSURL URLWithString:urlString];
|
|
}
|
|
}
|
|
return config;
|
|
}
|
|
}
|
|
|
|
RevengeLog(@"Couldn't get loader config");
|
|
return [LoaderConfig defaultConfig];
|
|
}
|
|
|
|
- (BOOL)saveConfig {
|
|
NSURL *loaderConfigUrl = [getPyoncordDirectory() URLByAppendingPathComponent:@"loader.json"];
|
|
NSDictionary *json = @{
|
|
@"customLoadUrl": @{
|
|
@"enabled": @(self.customLoadUrlEnabled),
|
|
@"url": self.customLoadUrl.absoluteString
|
|
}
|
|
};
|
|
|
|
NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
|
|
return [data writeToURL:loaderConfigUrl atomically:YES];
|
|
}
|
|
|
|
@end
|