From d6c995b1be172143f82985a78284a931e9bc2eae Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:43:42 -0700 Subject: [PATCH] Improve hiding warning --- Makefile | 2 +- YTLitePlus.xm | 142 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 108 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index 3046c62..ebb5990 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ SUBPROJECTS += Tweaks/Alderis Tweaks/iSponsorBlock Tweaks/YTUHD Tweaks/YouPiP Tw include $(THEOS_MAKE_PATH)/aggregate.mk YTLITE_PATH = Tweaks/YTLite -YTLITE_VERSION := $(shell wget -qO- "https://github.com/dayanch96/YTLite/releases/latest" | grep -o -E '/tag/v[^"]+' | head -n 1 | sed 's/\/tag\/v//') +YTLITE_VERSION := 5.0.1 YTLITE_DEB = $(YTLITE_PATH)/com.dvntm.ytlite_$(YTLITE_VERSION)_iphoneos-arm64.deb YTLITE_DYLIB = $(YTLITE_PATH)/var/jb/Library/MobileSubstrate/DynamicLibraries/YTLite.dylib YTLITE_BUNDLE = $(YTLITE_PATH)/var/jb/Library/Application\ Support/YTLite.bundle diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 517fdd4..07e99b2 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -171,52 +171,124 @@ BOOL isSelf() { %end // Disable YouTube Plus incompatibility warning popup - @bhackel -%hook UIView +%hook HelperVC +- (void)viewDidAppear:(BOOL)animated { + %orig; + // Start from the current view and traverse up to find the UITransitionView + UIView *currentView = self.view; + while (currentView != nil && ![NSStringFromClass([currentView class]) isEqualToString:@"UITransitionView"]) { + currentView = currentView.superview; + } + // If UITransitionView is found, hide it + if (currentView) { + NSLog(@"bhackel Found and hiding UITransitionView: %@", currentView); + currentView.hidden = YES; + currentView.userInteractionEnabled = NO; + // Print the subview structure for debugging + NSLog(@"bhackel Subviews of UITransitionView: %@", currentView.subviews); + NSLog(@"bhackel Superview of UITransitionView: %@", currentView.superview); + [currentView removeFromSuperview]; + } +} +%end -- (void)willMoveToWindow:(UIWindow *)newWindow { - UIResponder *responder = self; +%hook UIWindow + +- (void)addSubview:(UIView *)view { + // Check if the view's view controller is HelperVC using the responder chain + UIResponder *responder = view.nextResponder; while (responder) { - responder = [responder nextResponder]; - if ([responder isKindOfClass:NSClassFromString(@"HelperVC")]) { - // View belongs to HelperVC, now proceed with getting the UIButton - - if ([self.subviews count] > 4 && [[self.subviews objectAtIndex:4] isKindOfClass:[UIButton class]]) { - UIButton *button = [self.subviews objectAtIndex:4]; - - // Access the _targetActions ivar using KVC (Key-Value Coding) - NSArray *targetActions = [button valueForKey:@"_targetActions"]; - - if ([targetActions count] > 0) { - 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]]) { - // Access the handler property of UIAction - void (^handlerBlock)(void) = [actionHandler valueForKey:@"handler"]; - - // Invoke the handler block - if (handlerBlock) { - handlerBlock(); // Call the block - } - } - } - } - - // Prevent the view from being added to the window - [self removeFromSuperview]; - return; // Exit early to prevent further processing + if ([responder isKindOfClass:[UIViewController class]] && + [NSStringFromClass([responder class]) isEqualToString:@"HelperVC"]) { + // Block the view from being added to the window + NSLog(@"bhackel Blocked HelperVC's view from being added to UIWindow"); + return; } + responder = [responder nextResponder]; } - %orig(newWindow); // Call the original method if the view doesn't belong to HelperVC + // Call the original method for other views + %orig(view); +} + +- (void)setRootViewController:(UIViewController *)rootViewController { + // Check if the rootViewController is HelperVC + if ([NSStringFromClass([rootViewController class]) isEqualToString:@"HelperVC"]) { + // Block setting HelperVC as the root view controller + NSLog(@"bhackel Blocked HelperVC from being set as UIWindow's root view controller"); + return; + } + + // Call the original method for other view controllers + %orig(rootViewController); +} + +%end + + +%hook UIViewController + +- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion { + // Check if the view controller being presented is HelperVC using string comparison + if ([NSStringFromClass([viewControllerToPresent class]) isEqualToString:@"HelperVC"]) { + // Block the presentation by not calling the original method + NSLog(@"bhackel Blocked presentation of HelperVC"); + return; + } + + // Call the original method for other view controllers + %orig(viewControllerToPresent, flag, completion); } %end +%hook UIView + +// - (void)layoutSubviews { +// // Check if the view's view controller is HelperVC +// UIResponder *responder = self; +// while (responder) { +// responder = [responder nextResponder]; +// if ([responder isKindOfClass:[UIViewController class]]) { +// if ([NSStringFromClass([responder class]) isEqualToString:@"HelperVC"] +// && self.hidden == NO) { +// // If it's HelperVC, neutralize the view +// NSLog(@"bhackel Neutralizing HelperVC"); +// self.bounds = CGRectZero; +// self.hidden = YES; +// self.userInteractionEnabled = NO; +// // [self removeFromSuperview]; +// // Go ahead and set its superview to also be hidden +// UIView *superview = self.superview; +// if (superview) { +// superview.hidden = YES; +// superview.userInteractionEnabled = NO; +// } +// break; +// } +// } +// } + +// %orig; // Call the original method +// } + +- (void)didMoveToSuperview { + %orig; + + // Consolidate the log statements into one + NSLog(@"bhackel UIView added to hierarchy: %@ | View class: %@ | Frame: %@ | Background Color: %@ | Alpha: %f", + self, + NSStringFromClass([self class]), + NSStringFromCGRect(self.frame), + self.backgroundColor, + self.alpha); +} + + + +%end // A/B flags %hook YTColdConfig