mirror of
https://github.com/SoPat712/YTLitePlus.git
synced 2025-08-21 18:48:45 -04:00
ee
This commit is contained in:
154
YTLitePlus.xm
154
YTLitePlus.xm
@@ -171,123 +171,79 @@ BOOL isSelf() {
|
|||||||
%end
|
%end
|
||||||
|
|
||||||
// Disable YouTube Plus incompatibility warning popup - @bhackel
|
// Disable YouTube Plus incompatibility warning popup - @bhackel
|
||||||
%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
|
|
||||||
|
|
||||||
%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) {
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
%hook UIViewController
|
||||||
|
|
||||||
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
|
- (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"]) {
|
if ([NSStringFromClass([viewControllerToPresent class]) isEqualToString:@"HelperVC"]) {
|
||||||
// Block the presentation by not calling the original method
|
// show a toast
|
||||||
NSLog(@"bhackel Blocked presentation of HelperVC");
|
[[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Bypassing Popup"] animated:YES];
|
||||||
return;
|
// look for UIWindows of the sus type and hide them
|
||||||
|
NSArray<UIWindow *> *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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the original method for other view controllers
|
|
||||||
%orig(viewControllerToPresent, flag, completion);
|
%orig(viewControllerToPresent, flag, completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%hook UIView
|
%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);
|
||||||
|
|
||||||
// - (void)layoutSubviews {
|
if ([self.subviews count] > 4 && [[self.subviews objectAtIndex:4] isKindOfClass:[UIButton class]]) {
|
||||||
// // Check if the view's view controller is HelperVC
|
NSLog(@"bhackel Found UIButton (2/5): %@", [self.subviews objectAtIndex:4]);
|
||||||
// UIResponder *responder = self;
|
UIButton *button = [self.subviews objectAtIndex:4];
|
||||||
// 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
|
// Access the _targetActions ivar using KVC (Key-Value Coding)
|
||||||
// }
|
NSArray *targetActions = [button valueForKey:@"_targetActions"];
|
||||||
|
|
||||||
- (void)didMoveToSuperview {
|
if ([targetActions count] > 0) {
|
||||||
%orig;
|
NSLog(@"bhackel Found targetActions (3/5): %@", targetActions);
|
||||||
|
id controlTargetAction = [targetActions objectAtIndex:0];
|
||||||
|
|
||||||
// Consolidate the log statements into one
|
// Use KVC to get the _actionHandler (which is of type UIAction)
|
||||||
NSLog(@"bhackel UIView added to hierarchy: %@ | View class: %@ | Frame: %@ | Background Color: %@ | Alpha: %f",
|
UIAction *actionHandler = [controlTargetAction valueForKey:@"_actionHandler"];
|
||||||
self,
|
|
||||||
NSStringFromClass([self class]),
|
if (actionHandler && [actionHandler isKindOfClass:[UIAction class]]) {
|
||||||
NSStringFromCGRect(self.frame),
|
NSLog(@"bhackel Found actionHandler (4/5): %@", actionHandler);
|
||||||
self.backgroundColor,
|
// Access the handler property of UIAction
|
||||||
self.alpha);
|
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
|
%end
|
||||||
|
|
||||||
// A/B flags
|
// A/B flags
|
||||||
|
Reference in New Issue
Block a user