Revamp uYouPlus.xm

This commit is contained in:
arichornlover 2024-07-19 14:34:47 -05:00 committed by GitHub
parent f37c53b3fb
commit 08c51e5e5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,6 +53,23 @@ NSBundle *tweakBundle = uYouPlusBundle();
}
%end
// Fix App Group Directory by move it to document directory
%hook NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier {
if (groupIdentifier != nil) {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [paths lastObject];
return [documentsURL URLByAppendingPathComponent:@"AppGroup"];
}
return %orig(groupIdentifier);
}
%end
// Remove App Rating Prompt in YouTube (for Sideloaded - iOS 14+) - @arichornlover
%hook SKStoreReviewController
+ (void)requestReview { }
%end
// Enable Alternate Icons - @arichornlover
%hook UIApplication
- (BOOL)supportsAlternateIcons {
@ -130,6 +147,8 @@ NSBundle *tweakBundle = uYouPlusBundle();
}
%end
NSString *getAdString(NSString *description) {
if ([description containsString:@"ad_layout"])
return @"ad_layout";
if ([description containsString:@"brand_promo"])
return @"brand_promo";
if ([description containsString:@"carousel_footered_layout"])
@ -176,12 +195,12 @@ static __strong NSData *cellDividerData;
}
if (!cellDividerData) return %orig;
if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 1 %@", cellDividerData);
HBLogDebug(@"YTX adLogging 1 %@", cellDividerData);
return cellDividerData;
}
NSString *adString = getAdString(description);
if (adString) {
// HBLogInfo(@"YTX getAdString 1 %@ %@", adString, cellDividerData);
HBLogDebug(@"YTX getAdString 1 %@ %@", adString, cellDividerData);
return cellDividerData;
}
return %orig;
@ -198,13 +217,13 @@ static __strong NSData *cellDividerData;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 2 %@", elementRenderer);
HBLogDebug(@"YTX adLogging 2 %@", elementRenderer);
return YES;
}
NSString *description = [elementRenderer description];
NSString *adString = getAdString(description);
if (adString) {
// HBLogInfo(@"YTX getAdString 2 %@ %@", adString, elementRenderer);
HBLogDebug(@"YTX getAdString 2 %@ %@", adString, elementRenderer);
return YES;
}
return NO;
@ -234,36 +253,26 @@ static __strong NSData *cellDividerData;
%end
// Center YouTube Logo - @arichornlover
%group gCenterYouTubeLogo // BROKEN
%group gCenterYouTubeLogo
%hook YTNavigationBarTitleView
- (void)setShouldCenterNavBarTitleView:(BOOL)center { // Doesn't do anything?
%orig(YES);
- (void)setShouldCenterNavBarTitleView:(BOOL)center {
%orig(center);
if (center) {
[self alignCustomViewToCenterOfWindow];
}
}
- (BOOL)shouldCenterNavBarTitleView {
return YES;
}
%new;
- (void)alignCustomViewToCenterOfWindow {
CGRect frame = self.customView.frame;
frame.origin.x = (self.window.frame.size.width - frame.size.width) / 2;
self.customView.frame = frame;
}
%end
%end
// Fix App Group Directory by move it to document directory
%hook NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier {
if (groupIdentifier != nil) {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [paths lastObject];
return [documentsURL URLByAppendingPathComponent:@"AppGroup"];
}
return %orig(groupIdentifier);
}
%end
// Remove App Rating Prompt in YouTube (for Sideloaded - iOS 14+) - @arichornlover
%hook SKStoreReviewController
+ (void)requestReview { }
%end
// YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
%hook YTWatchMiniBarViewController
- (void)updateMiniBarPlayerStateFromRenderer {
@ -852,28 +861,13 @@ static int contrastMode() {
%end
%end
// Fullscreen to the Right (iPhone-exclusive) - @arichornlover
// NOTE: Please turn off the “Portrait Fullscreen” Option while the code below is active
// Fullscreen to the Right (iPhone-exclusive) - @arichornlover & @bhackel
// WARNING: Please turn off the “Portrait Fullscreen” and "iPad Layout" Options while the option "Fullscreen to the Right" is enabled below.
%group gFullscreenToTheRight
%hook YTWatchViewController
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
if ([self isFullscreen] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationLandscapeRight;
}
return %orig;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
if ([self isFullscreen] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskLandscape;
}
return %orig;
}
%new
- (void)forceRightFullscreenOrientation { // custom void
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
- (UIInterfaceOrientationMask)allowedFullScreenOrientations {
UIInterfaceOrientationMask orientations = UIInterfaceOrientationMaskLandscapeRight;
return orientations;
}
%end
%end
@ -1094,7 +1088,16 @@ static int contrastMode() {
- (BOOL)fullscreenButtonDisabled { return YES; }
- (BOOL)canShowFullscreenButton { return NO; }
- (BOOL)canShowFullscreenButtonExperimental { return NO; }
// - (void)setFullscreenButtonDisabled:(BOOL) // Uncomment and might implement this if needed - @arichornlover
// - (void)setFullscreenButtonDisabled:(BOOL) // Might implement this if useful - @arichornlover
- (void)layoutSubviews {
%orig;
if (self.exitFullscreenButton && !self.exitFullscreenButton.hidden) {
self.exitFullscreenButton.hidden = YES;
}
if (self.enterFullscreenButton && !self.enterFullscreenButton.hidden) {
self.enterFullscreenButton.hidden = YES;
}
}
%end
%end
@ -1111,7 +1114,6 @@ static int contrastMode() {
return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig;
}
%end
// Hide Channel Watermark (for Backwards Compatibility)
%hook YTAnnotationsViewController
- (void)loadFeaturedChannelWatermark {
if (IS_ENABLED(@"hideChannelWatermark_enabled")) {}
@ -1163,7 +1165,7 @@ static int contrastMode() {
%end
%end
// Hide Video Title (in Fullscreen) - @arichornlover
// Hide Video Title when in Fullscreen - @arichornlover
%hook YTMainAppControlsOverlayView
- (BOOL)titleViewHidden {
return IS_ENABLED(@"hideVideoTitle_enabled") ? YES : %orig;
@ -1578,7 +1580,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
// Remove “Play next in queue” from the menu (@PoomSmart) - qnblackcat/uYouPlus#1138
%hook YTMenuItemVisibilityHandler
- (BOOL)shouldShowServiceItemRenderer:(YTIMenuConditionalServiceItemRenderer *)renderer {
return IS_ENABLED(@"hidePlayNextInQueue_enabled") && renderer.icon.iconType == 251 && renderer.secondaryIcon.iconType == 741 ? NO : %orig;
return IS_ENABLED(@"hidePlayNextInQueue_enabled") && renderer.icon.iconType == 251 ? NO : %orig;
}
%end
@ -1597,7 +1599,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end
%end
// Hide Videos in Fullscreen - @arichornlover
// Hide Videos when in Fullscreen - @arichornlover
%group gNoVideosInFullscreen
%hook YTFullScreenEngagementOverlayView
- (void)setRelatedVideosView:(id)view {
@ -1621,9 +1623,9 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
// iPhone Layout - @LillieH1000 & @arichornlover
%group giPhoneLayout
%hook UIDevice
- (long long)userInterfaceIdiom {
return NO;
}
- (UIUserInterfaceIdiom)userInterfaceIdiom {
return UIUserInterfaceIdiomPhone;
}
%end
%hook UIStatusBarStyleAttributes
- (long long)idiom {
@ -1632,12 +1634,20 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end
%hook UIKBTree
- (long long)nativeIdiom {
return YES;
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
}
%end
%hook UIKBRenderer
- (long long)assetIdiom {
return NO;
if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
}
%end
%end