Fix YouGroupSettings addition

This commit is contained in:
Bryce Hackel
2024-07-05 01:59:32 -07:00
parent 4074281265
commit 4de07c2d7a
2 changed files with 14 additions and 13 deletions

View File

@@ -31,7 +31,6 @@ static int contrastMode() {
static int appVersionSpoofer() { static int appVersionSpoofer() {
return [[NSUserDefaults standardUserDefaults] integerForKey:@"versionSpoofer"]; return [[NSUserDefaults standardUserDefaults] integerForKey:@"versionSpoofer"];
} }
static const NSInteger YTLitePlusSection = 788;
@interface YTSettingsSectionItemManager (YTLitePlus) @interface YTSettingsSectionItemManager (YTLitePlus)
- (void)updateYTLitePlusSectionWithEntry:(id)entry; - (void)updateYTLitePlusSectionWithEntry:(id)entry;
@@ -40,20 +39,20 @@ static const NSInteger YTLitePlusSection = 788;
extern NSBundle *YTLitePlusBundle(); extern NSBundle *YTLitePlusBundle();
// Add both YTLite and YTLitePlus to YouGroupSettings // 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 %hook YTSettingsGroupData
+ (NSMutableArray <NSNumber *> *)tweaks { + (NSMutableArray <NSNumber *> *)tweaks {
NSMutableArray <NSNumber *> *originalTweaks = %orig; NSLog(@"bhackel: called hooked 'tweaks' method.");
NSMutableArray <NSNumber *> *originalTweaks = %orig;
// Use a static variable to ensure the array is modified only once. static dispatch_once_t onceToken;
static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{
dispatch_once(&onceToken, ^{ [originalTweaks addObject:@(YTLitePlusSection)];
[originalTweaks addObject:@(YTLitePlusSection)]; [originalTweaks addObject:@(YTLiteSection)];
[originalTweaks addObject:@(YTLiteSection)]; });
});
// Return the modified array. return originalTweaks;
return originalTweaks;
} }
%end %end

View File

@@ -667,6 +667,9 @@ static NSData *cellDividerData = nil;
# pragma mark - ctor # pragma mark - ctor
%ctor { %ctor {
%init; %init;
// Access YouGroupSettings methods
dlopen([[NSString stringWithFormat:@"%@/Frameworks/YouGroupSettings.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY);
if (IsEnabled(@"hideCastButton_enabled")) { if (IsEnabled(@"hideCastButton_enabled")) {
%init(gHideCastButton); %init(gHideCastButton);
} }
@@ -729,8 +732,7 @@ static NSData *cellDividerData = nil;
} }
if (IsEnabled(@"fixCasting_enabled")) { if (IsEnabled(@"fixCasting_enabled")) {
%init(gFixCasting); %init(gFixCasting);
} }
// Change the default value of some options // Change the default value of some options
NSArray *allKeys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys]; NSArray *allKeys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys];