From 4de07c2d7a4f63f6864c1b69fe3cf6144495b6ea Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Fri, 5 Jul 2024 01:59:32 -0700 Subject: [PATCH] Fix YouGroupSettings addition --- Source/Settings.xm | 21 ++++++++++----------- YTLitePlus.xm | 6 ++++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/Settings.xm b/Source/Settings.xm index 57f2653..79ff3a4 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -31,7 +31,6 @@ static int contrastMode() { static int appVersionSpoofer() { return [[NSUserDefaults standardUserDefaults] integerForKey:@"versionSpoofer"]; } -static const NSInteger YTLitePlusSection = 788; @interface YTSettingsSectionItemManager (YTLitePlus) - (void)updateYTLitePlusSectionWithEntry:(id)entry; @@ -40,20 +39,20 @@ static const NSInteger YTLitePlusSection = 788; extern NSBundle *YTLitePlusBundle(); // Add both YTLite and YTLitePlus to YouGroupSettings -static const NSInteger YTLiteSection = 789; // Grabbed from YTLite +static const NSInteger YTLitePlusSection = 788; +static const NSInteger YTLiteSection = 789; %hook YTSettingsGroupData + (NSMutableArray *)tweaks { - NSMutableArray *originalTweaks = %orig; + NSLog(@"bhackel: called hooked 'tweaks' method."); + NSMutableArray *originalTweaks = %orig; - // Use a static variable to ensure the array is modified only once. - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [originalTweaks addObject:@(YTLitePlusSection)]; - [originalTweaks addObject:@(YTLiteSection)]; - }); + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + [originalTweaks addObject:@(YTLitePlusSection)]; + [originalTweaks addObject:@(YTLiteSection)]; + }); - // Return the modified array. - return originalTweaks; + return originalTweaks; } %end diff --git a/YTLitePlus.xm b/YTLitePlus.xm index de60347..9063ed8 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -667,6 +667,9 @@ static NSData *cellDividerData = nil; # pragma mark - ctor %ctor { %init; + // Access YouGroupSettings methods + dlopen([[NSString stringWithFormat:@"%@/Frameworks/YouGroupSettings.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY); + if (IsEnabled(@"hideCastButton_enabled")) { %init(gHideCastButton); } @@ -729,8 +732,7 @@ static NSData *cellDividerData = nil; } if (IsEnabled(@"fixCasting_enabled")) { %init(gFixCasting); - } - + } // Change the default value of some options NSArray *allKeys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys];