From 24c69834c583f1c3eda5e2ea8786d7a2a1e73460 Mon Sep 17 00:00:00 2001 From: Extreme_Ninja2099 <59802365+ExtNinja2099@users.noreply.github.com> Date: Tue, 17 Sep 2024 07:50:35 +0100 Subject: [PATCH] Update YTLitePlus.xm Brought back code related to disabling YTLite Popup --- YTLitePlus.xm | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 4ae4090..cfdc42f 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -170,6 +170,80 @@ BOOL isSelf() { %end %end +// Disable YouTube Plus incompatibility warning popup - @bhackel +%hook UIViewController + +- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion { + if ([NSStringFromClass([viewControllerToPresent class]) isEqualToString:@"HelperVC"]) { + // look for UIWindows of the sus type and hide them + NSArray *windows = [UIApplication sharedApplication].windows; + for (UIWindow *window in windows) { + // Check the class name of the window + if ([NSStringFromClass([window class]) isEqualToString:@"YTMainWindow"]) { + NSLog(@"bhackel Skipping UIWindow with class YTMainWindow: %@", window); + window.userInteractionEnabled = YES; + continue; + } + NSLog(@"bhackel Yeeting UIWindow %@", window); + window.hidden = YES; + window.userInteractionEnabled = NO; + } + } + + %orig(viewControllerToPresent, flag, completion); +} + +%end + + +%hook UIView +- (void)willMoveToWindow:(UIWindow *)newWindow { + // yeet yeet + UIResponder *responder = self; + while (responder) { + responder = [responder nextResponder]; + if ([responder isKindOfClass:NSClassFromString(@"HelperVC")]) { + // View belongs to HelperVC, now proceed with getting the UIButton + NSLog(@"bhackel Found HelperVC (1/5): %@", responder); + + if ([self.subviews count] > 4 && [[self.subviews objectAtIndex:4] isKindOfClass:[UIButton class]]) { + NSLog(@"bhackel Found UIButton (2/5): %@", [self.subviews objectAtIndex:4]); + UIButton *button = [self.subviews objectAtIndex:4]; + + // Access the _targetActions ivar using KVC (Key-Value Coding) + NSArray *targetActions = [button valueForKey:@"_targetActions"]; + + if ([targetActions count] > 0) { + NSLog(@"bhackel Found targetActions (3/5): %@", targetActions); + id controlTargetAction = [targetActions objectAtIndex:0]; + + // Use KVC to get the _actionHandler (which is of type UIAction) + UIAction *actionHandler = [controlTargetAction valueForKey:@"_actionHandler"]; + + if (actionHandler && [actionHandler isKindOfClass:[UIAction class]]) { + NSLog(@"bhackel Found actionHandler (4/5): %@", actionHandler); + // Access the handler property of UIAction + void (^handlerBlock)(void) = [actionHandler valueForKey:@"handler"]; + + // Invoke the handler block + if (handlerBlock) { + NSLog(@"bhackel Found handlerBlock (5/5): %@", handlerBlock); + handlerBlock(); // Call the block + } + } + } + } + + // Prevent the view from being added to the window + [self removeFromSuperview]; + return; // Exit early to prevent further processing + } + } + + %orig(newWindow); // Call the original method if the view doesn't belong to HelperVC +} +%end + // A/B flags %hook YTColdConfig - (BOOL)respectDeviceCaptionSetting { return NO; } // YouRememberCaption: https://poomsmart.github.io/repo/depictions/youremembercaption.html