mirror of
https://github.com/SoPat712/YTLitePlus.git
synced 2025-08-21 18:48:45 -04:00
Improve hiding warning
This commit is contained in:
2
Makefile
2
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
|
||||
|
138
YTLitePlus.xm
138
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) {
|
||||
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];
|
||||
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
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
%orig(newWindow); // Call the original method if the view doesn't belong to HelperVC
|
||||
// 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
|
||||
|
Reference in New Issue
Block a user