From f782a19cd6d51fbf7fe609a8ee1762c2a5ca4d91 Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:29:51 +0100 Subject: [PATCH 1/2] fix: fix loader config --- Extensions/SafariExtension | 1 + Headers/LoaderConfig.h | 2 ++ Sources/LoaderConfig.m | 44 ++++++++++++++++++++++++++++++++++++++ Sources/Tweak.x | 3 ++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 160000 Extensions/SafariExtension diff --git a/Extensions/SafariExtension b/Extensions/SafariExtension new file mode 160000 index 0000000..a7b21ac --- /dev/null +++ b/Extensions/SafariExtension @@ -0,0 +1 @@ +Subproject commit a7b21ac17fb52c2b795e445da762008f88a44d35 diff --git a/Headers/LoaderConfig.h b/Headers/LoaderConfig.h index 6c63fa8..d15774d 100644 --- a/Headers/LoaderConfig.h +++ b/Headers/LoaderConfig.h @@ -5,4 +5,6 @@ @property (nonatomic, strong) NSURL *customLoadUrl; + (instancetype)defaultConfig; + (instancetype)getLoaderConfig; +- (instancetype)init; +- (BOOL)loadConfig; @end \ No newline at end of file diff --git a/Sources/LoaderConfig.m b/Sources/LoaderConfig.m index bfc31f4..bfd6794 100644 --- a/Sources/LoaderConfig.m +++ b/Sources/LoaderConfig.m @@ -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; diff --git a/Sources/Tweak.x b/Sources/Tweak.x index 79f31f1..2fa7468 100644 --- a/Sources/Tweak.x +++ b/Sources/Tweak.x @@ -162,8 +162,9 @@ static LoaderConfig *loaderConfig; BunnyLog(@"Bundle contents: %@", bundleContents); } - pyoncordDirectory = getPyoncordDirectory(); +pyoncordDirectory = getPyoncordDirectory(); loaderConfig = [[LoaderConfig alloc] init]; + [loaderConfig loadConfig]; %init; } From 2fd7b277f423463f68d0d742e518fe357d0ada39 Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:51:57 +0100 Subject: [PATCH 2/2] fix: git moment --- Extensions/SafariExtension | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Extensions/SafariExtension diff --git a/Extensions/SafariExtension b/Extensions/SafariExtension deleted file mode 160000 index a7b21ac..0000000 --- a/Extensions/SafariExtension +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a7b21ac17fb52c2b795e445da762008f88a44d35