From 810aca2f162b13f764c20e58e8b122dacf474ebd Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 11:06:07 -0700 Subject: [PATCH 01/10] Disable warning popup --- YTLitePlus.h | 4 ++++ YTLitePlus.xm | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/YTLitePlus.h b/YTLitePlus.h index 247af9e..1c3ead2 100644 --- a/YTLitePlus.h +++ b/YTLitePlus.h @@ -130,6 +130,10 @@ typedef NS_ENUM(NSUInteger, GestureSection) { @property (nonatomic, assign, readwrite) BOOL enableSnapToChapter; @end +// Hide YouTube Plus incompatibility warning popup - @bhackel +@interface HelperVC : UIViewController +@end + // Hide Autoplay Mini Preview - @bhackel @interface YTAutonavPreviewView : UIView @end diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 093b70d..aa8b0bc 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -110,12 +110,8 @@ BOOL isSelf() { } %end -# pragma mark - Hide SponsorBlock Button +// Hide SponsorBlock Button in navigation bar %hook YTRightNavigationButtons -- (void)didMoveToWindow { - %orig; -} - - (void)layoutSubviews { %orig; if (IsEnabled(@"hideSponsorBlockButton_enabled")) { @@ -174,6 +170,18 @@ BOOL isSelf() { %end %end +// Disable YouTube Plus incompatibility warning popup - @bhackel +%hook HelperVC +- (void)viewDidLoad { + %orig; + // Check if it responds to the selector riskButtonTapped + if ([self respondsToSelector:@selector(riskButtonTapped)]) { + // Call the selector riskButtonTapped + [self performSelector:@selector(riskButtonTapped)]; + } +} +%end + // A/B flags %hook YTColdConfig From a3ac8e973584860a0ed643a52e710ae1973726b1 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 11:19:09 -0700 Subject: [PATCH 02/10] Default disable iSponsorBlock --- YTLitePlus.xm | 54 ++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index aa8b0bc..4dd9a90 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -1319,36 +1319,28 @@ NSInteger pageStyle = 0; // Change the default value of some options NSArray *allKeys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys]; - if (![allKeys containsObject:@"RYD-ENABLED"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RYD-ENABLED"]; - } - if (![allKeys containsObject:@"YouPiPEnabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"YouPiPEnabled"]; - } - if (![allKeys containsObject:@"newSettingsUI_enabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"newSettingsUI_enabled"]; - } - if (![allKeys containsObject:@"fixCasting_enabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"fixCasting_enabled"]; - } - // Default gestures as volume, brightness, seek - if (![allKeys containsObject:@"playerGestureTopSelection"]) { - [[NSUserDefaults standardUserDefaults] setInteger:GestureModeVolume forKey:@"playerGestureTopSelection"]; - } - if (![allKeys containsObject:@"playerGestureMiddleSelection"]) { - [[NSUserDefaults standardUserDefaults] setInteger:GestureModeBrightness forKey:@"playerGestureMiddleSelection"]; - } - if (![allKeys containsObject:@"playerGestureBottomSelection"]) { - [[NSUserDefaults standardUserDefaults] setInteger:GestureModeSeek forKey:@"playerGestureBottomSelection"]; - } - // Default configuration options for gestures - if (![allKeys containsObject:@"playerGesturesDeadzone"]) { - [[NSUserDefaults standardUserDefaults] setFloat:20.0 forKey:@"playerGesturesDeadzone"]; - } - if (![allKeys containsObject:@"playerGesturesSensitivity"]) { - [[NSUserDefaults standardUserDefaults] setFloat:1.0 forKey:@"playerGesturesSensitivity"]; - } - if (![allKeys containsObject:@"playerGesturesHapticFeedback_enabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"playerGesturesHapticFeedback_enabled"]; + if (![allKeys containsObject:@"YTLPDidPerformFirstRunSetup"]) { + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"YTLPDidPerformFirstRunSetup"]; + // Set iSponsorBlock to default disabled + NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; + NSString *settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; + NSMutableDictionary *settings = [NSMutableDictionary dictionary]; + NSDictionary *existingSettings = [NSDictionary dictionaryWithContentsOfFile:settingsPath]; + [settings addEntriesFromDictionary:existingSettings]; + [settings setObject:@(NO) forKey:@"enabled"]; + [settings writeToFile:settingsPath atomically:YES]; + // Set miscellaneous YTLitePlus features to enabled + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RYD-ENABLED"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"YouPiPEnabled"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"newSettingsUI_enabled"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"fixCasting_enabled"]; + // Default gestures as volume, brightness, seek + [[NSUserDefaults standardUserDefaults] setInteger:GestureModeVolume forKey:@"playerGestureTopSelection"]; + [[NSUserDefaults standardUserDefaults] setInteger:GestureModeBrightness forKey:@"playerGestureMiddleSelection"]; + [[NSUserDefaults standardUserDefaults] setInteger:GestureModeSeek forKey:@"playerGestureBottomSelection"]; + // Default gestures options + [[NSUserDefaults standardUserDefaults] setFloat:20.0 forKey:@"playerGesturesDeadzone"]; + [[NSUserDefaults standardUserDefaults] setFloat:1.0 forKey:@"playerGesturesSensitivity"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"playerGesturesHapticFeedback_enabled"]; } } From 861a9fd30b2a32e34af08122af72f8a0c3ed28e0 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:27:07 -0700 Subject: [PATCH 03/10] Remove OLED live chat fix --- YTLitePlus.xm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 4dd9a90..aa57691 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -586,16 +586,6 @@ BOOL isTabSelected = NO; [self setNeedsLayout]; [self removeFromSuperview]; } - - // Live chat OLED dark mode - @bhackel - CGFloat alpha; - if ([[%c(YTLUserDefaults) standardUserDefaults] boolForKey:@"oledTheme"] // YTLite OLED Theme - && [self.accessibilityIdentifier isEqualToString:@"eml.live_chat_text_message"] // Live chat text message - && [self.backgroundColor getWhite:nil alpha:&alpha] // Check if color is grayscale and get alpha - && alpha != 0.0) // Ignore shorts live chat - { - self.backgroundColor = [UIColor blackColor]; - } } %end From d4f8a41ff2920e146d00e2fa731506c4875738b3 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:10:51 -0700 Subject: [PATCH 04/10] Fix smoothing for player gestures --- YTLitePlus.xm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index aa57691..bfc82c8 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -689,7 +689,7 @@ BOOL isTabSelected = NO; // Variable used to smooth out the X translation static CGFloat smoothedTranslationX = 0; // Constant for the filter constant to change responsiveness - static const CGFloat filterConstant = 0.1; + // static const CGFloat filterConstant = 0.1; // Constant for the deadzone radius that can be changed in the settings static CGFloat deadzoneRadius = (CGFloat)GetFloat(@"playerGesturesDeadzone"); // Constant for the sensitivity factor that can be changed in the settings @@ -756,10 +756,10 @@ BOOL isTabSelected = NO; }; // Helper function to smooth out the X translation - CGFloat (^applyLowPassFilter)(CGFloat) = ^(CGFloat newTranslation) { - smoothedTranslationX = filterConstant * newTranslation + (1 - filterConstant) * smoothedTranslationX; - return smoothedTranslationX; - }; + // CGFloat (^applyLowPassFilter)(CGFloat) = ^(CGFloat newTranslation) { + // smoothedTranslationX = filterConstant * newTranslation + (1 - filterConstant) * smoothedTranslationX; + // return smoothedTranslationX; + // }; /***** Helper functions for running the selected gesture *****/ // Helper function to run any setup for the selected gesture mode @@ -923,7 +923,7 @@ BOOL isTabSelected = NO; // Adjust the X translation based on the value hit after exiting the deadzone adjustedTranslationX = translation.x - deadzoneStartingXTranslation; // Smooth the translation value - adjustedTranslationX = applyLowPassFilter(adjustedTranslationX); + // adjustedTranslationX = applyLowPassFilter(adjustedTranslationX); // Pass the adjusted translation to the selected gesture switch (gestureSection) { case GestureSectionTop: From c73cd63db47b0f9d0d1d3133cf35788853ccce7d Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:50:04 -0700 Subject: [PATCH 05/10] Cancel gesture after 1 second of inactivity --- YTLitePlus.xm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index bfc82c8..ae9a152 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -870,6 +870,13 @@ BOOL isTabSelected = NO; } // Deactive the activity flag isValidHorizontalPan = NO; + // Cancel this gesture if it has not activated after 1 second + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if (!isValidHorizontalPan && panGestureRecognizer.state != UIGestureRecognizerStateEnded) { + // Cancel the gesture by setting its state to UIGestureRecognizerStateCancelled + panGestureRecognizer.state = UIGestureRecognizerStateCancelled; + } + }); } // Handle changed gesture state by activating the gesture once it has exited the deadzone, From 9d62ce75ce58b5ee4bf01022b7342bb679bf2b73 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 14:45:20 -0700 Subject: [PATCH 06/10] Fix bugs --- Source/Settings.xm | 2 +- YTLitePlus.xm | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/Settings.xm b/Source/Settings.xm index 418d6f4..864275b 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -396,7 +396,7 @@ static const NSInteger YTLiteSection = 789; // Toggle for haptic feedback BASIC_SWITCH(LOC(@"PLAYER_GESTURES_HAPTIC_FEEDBACK"), nil, @"playerGesturesHapticFeedback_enabled"), ]; - YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"Player Gestures (Beta)") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; + YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"PLAYER_GESTURES_TITLE") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; [settingsViewController pushViewController:picker]; return YES; }]; diff --git a/YTLitePlus.xm b/YTLitePlus.xm index ae9a152..766395a 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -172,14 +172,17 @@ BOOL isSelf() { // Disable YouTube Plus incompatibility warning popup - @bhackel %hook HelperVC -- (void)viewDidLoad { - %orig; - // Check if it responds to the selector riskButtonTapped - if ([self respondsToSelector:@selector(riskButtonTapped)]) { - // Call the selector riskButtonTapped - [self performSelector:@selector(riskButtonTapped)]; - } + +- (void)viewWillAppear:(BOOL)animated { + %orig; // Call the original implementation + + // // Hide the view before it appears + // self.view.hidden = YES; + + // // Optionally, you can remove the view from the superview to ensure it's gone + // [self.view removeFromSuperview]; } + %end @@ -1240,6 +1243,8 @@ NSInteger pageStyle = 0; %init; // Access YouGroupSettings methods dlopen([[NSString stringWithFormat:@"%@/Frameworks/YouGroupSettings.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY); + // Access YouTube Plus methods + dlopen([[NSString stringWithFormat:@"%@/Frameworks/YTLite.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY); if (IsEnabled(@"hideCastButton_enabled")) { %init(gHideCastButton); @@ -1322,8 +1327,6 @@ NSInteger pageStyle = 0; NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; NSString *settingsPath = [documentsDirectory stringByAppendingPathComponent:@"iSponsorBlock.plist"]; NSMutableDictionary *settings = [NSMutableDictionary dictionary]; - NSDictionary *existingSettings = [NSDictionary dictionaryWithContentsOfFile:settingsPath]; - [settings addEntriesFromDictionary:existingSettings]; [settings setObject:@(NO) forKey:@"enabled"]; [settings writeToFile:settingsPath atomically:YES]; // Set miscellaneous YTLitePlus features to enabled From df0be8c66eb36872d2306d12ce51e7d355b5409a Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:31:28 -0700 Subject: [PATCH 07/10] Change hiding method --- YTLitePlus.xm | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 766395a..517fdd4 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -171,21 +171,53 @@ BOOL isSelf() { %end // Disable YouTube Plus incompatibility warning popup - @bhackel -%hook HelperVC +%hook UIView -- (void)viewWillAppear:(BOOL)animated { - %orig; // Call the original implementation +- (void)willMoveToWindow:(UIWindow *)newWindow { + UIResponder *responder = self; + while (responder) { + responder = [responder nextResponder]; + if ([responder isKindOfClass:NSClassFromString(@"HelperVC")]) { + // View belongs to HelperVC, now proceed with getting the UIButton - // // Hide the view before it appears - // self.view.hidden = YES; + if ([self.subviews count] > 4 && [[self.subviews objectAtIndex:4] isKindOfClass:[UIButton class]]) { + UIButton *button = [self.subviews objectAtIndex:4]; - // // Optionally, you can remove the view from the superview to ensure it's gone - // [self.view removeFromSuperview]; + // 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 + } + } + + %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 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 08/10] 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 From 7674805f756adca06a2861e6b1462ae33829fe98 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:40:12 -0700 Subject: [PATCH 09/10] ee --- YTLitePlus.xm | 154 ++++++++++++++++++-------------------------------- 1 file changed, 55 insertions(+), 99 deletions(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 07e99b2..39c0a7d 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -171,123 +171,79 @@ BOOL isSelf() { %end // 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 - (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; + // show a toast + [[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Bypassing Popup"] animated:YES]; + // 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; + } } - // Call the original method for other view controllers %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); -// - (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; -// } -// } -// } + 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]; -// %orig; // Call the original method -// } + // Access the _targetActions ivar using KVC (Key-Value Coding) + NSArray *targetActions = [button valueForKey:@"_targetActions"]; -- (void)didMoveToSuperview { - %orig; + if ([targetActions count] > 0) { + NSLog(@"bhackel Found targetActions (3/5): %@", targetActions); + id controlTargetAction = [targetActions objectAtIndex:0]; - // 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); + // 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 From 55494e2e91cd12017939a7426ee8045be0a46b92 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:27:38 -0700 Subject: [PATCH 10/10] coding on my phone --- YTLitePlus.xm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index 39c0a7d..9670a34 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -176,7 +176,7 @@ BOOL isSelf() { - (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion { if ([NSStringFromClass([viewControllerToPresent class]) isEqualToString:@"HelperVC"]) { // show a toast - [[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Bypassing Popup"] animated:YES]; + [[%c(GOOHUDManagerInternal) sharedInstance] showMessageMainThread:[%c(YTHUDMessage) messageWithText:@"Bypassing Popup"]]; // look for UIWindows of the sus type and hide them NSArray *windows = [UIApplication sharedApplication].windows; for (UIWindow *window in windows) {