fix: fix loader config
This commit is contained in:
parent
e5fdfbf00c
commit
3d86fe0f75
4 changed files with 50 additions and 2 deletions
1
Extensions/SafariExtension
Submodule
1
Extensions/SafariExtension
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a7b21ac17fb52c2b795e445da762008f88a44d35
|
||||
|
|
@ -5,4 +5,6 @@
|
|||
@property (nonatomic, strong) NSURL *customLoadUrl;
|
||||
+ (instancetype)defaultConfig;
|
||||
+ (instancetype)getLoaderConfig;
|
||||
- (instancetype)init;
|
||||
- (BOOL)loadConfig;
|
||||
@end
|
||||
|
|
@ -4,6 +4,50 @@
|
|||
|
||||
@implementation LoaderConfig
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.customLoadUrlEnabled = NO;
|
||||
self.customLoadUrl = [NSURL URLWithString:@"http://localhost:4040/bunny.js"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)loadConfig {
|
||||
NSURL *loaderConfigUrl = [getPyoncordDirectory() URLByAppendingPathComponent:@"loader.json"];
|
||||
BunnyLog(@"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) {
|
||||
BunnyLog(@"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];
|
||||
}
|
||||
}
|
||||
|
||||
BunnyLog(@"Loader config loaded - Custom URL %@: %@",
|
||||
self.customLoadUrlEnabled ? @"enabled" : @"disabled",
|
||||
self.customLoadUrl.absoluteString);
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
BunnyLog(@"Using default loader config: %@", self.customLoadUrl.absoluteString);
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (instancetype)defaultConfig {
|
||||
LoaderConfig *config = [[LoaderConfig alloc] init];
|
||||
config.customLoadUrlEnabled = NO;
|
||||
|
|
|
|||
|
|
@ -162,9 +162,10 @@ static LoaderConfig *loaderConfig;
|
|||
RevengeLog(@"Bundle contents: %@", bundleContents);
|
||||
}
|
||||
|
||||
pyoncordDirectory = getPyoncordDirectory();
|
||||
pyoncordDirectory = getPyoncordDirectory();
|
||||
loaderConfig = [[LoaderConfig alloc] init];
|
||||
|
||||
[loaderConfig loadConfig];
|
||||
|
||||
%init;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue