From c8e76e0efeb24189add4cb2819f80057f1ecd37e Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Sat, 22 Jun 2024 18:01:54 -0500 Subject: [PATCH] Restore Settings Button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: this will likely cause duplicated settings button in the Settings Tab. It’s a recreation of the exact button. --- Sources/uYouPlus.xm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index bd06738..41ea737 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -60,6 +60,46 @@ NSBundle *tweakBundle = uYouPlusBundle(); } %end +// Restore Settings Button - v18.35.4+ - @arichornlover +%hook YTRightNavigationButtons +%property (retain, nonatomic) YTQTMButton *settingsButton; +- (NSMutableArray *)buttons { + NSString *appVersion = [YTVersionUtilsClass performSelector:@selector(appVersion)]; + NSComparisonResult versionCheck = [appVersion compare:@"18.35.4" options:NSNumericSearch]; + if (versionCheck == NSOrderedAscending) { + return %orig; + } + NSMutableArray *retVal = %orig.mutableCopy; + [self.settingsButton removeFromSuperview]; + [self addSubview:self.settingsButton]; + if (!self.settingsButton) { + self.settingsButton = [%c(YTQTMButton) iconButton]; + self.settingsButton.frame = CGRectMake(0, 0, 24, 24); + [self.settingsButton setImage:[UIImage imageNamed:@"yt_outline_gear_24pt"] forState:UIControlStateNormal]; + [self.settingsButton addTarget:self action:@selector(settingsAction) forControlEvents:UIControlEventTouchUpInside]; + + [retVal insertObject:self.settingsButton atIndex:0]; + } + return retVal; +} +- (NSMutableArray *)visibleButtons { + NSMutableArray *retVal = %orig.mutableCopy; + [self setLeadingPadding:+10]; + + if (self.settingsButton) { + [self.settingsButton removeFromSuperview]; + [self addSubview:self.settingsButton]; + [retVal insertObject:self.settingsButton atIndex:0]; + } + return retVal; +} +%new; +- (void)settingsAction { + UIViewController *settingsViewController = [[[YTSettingsViewController alloc] init] autorelease]; + [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:settingsViewController animated:YES completion:nil]; +} +%end + // uYou AdBlock Workaround LITE (This Version will only remove ads from Videos/Shorts!) - @PoomSmart %group uYouAdBlockingWorkaroundLite %hook YTHotConfig