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 %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 // Enable Alternate Icons - @arichornlover
%hook UIApplication %hook UIApplication
- (BOOL)supportsAlternateIcons { - (BOOL)supportsAlternateIcons {
@ -130,6 +147,8 @@ NSBundle *tweakBundle = uYouPlusBundle();
} }
%end %end
NSString *getAdString(NSString *description) { NSString *getAdString(NSString *description) {
if ([description containsString:@"ad_layout"])
return @"ad_layout";
if ([description containsString:@"brand_promo"]) if ([description containsString:@"brand_promo"])
return @"brand_promo"; return @"brand_promo";
if ([description containsString:@"carousel_footered_layout"]) if ([description containsString:@"carousel_footered_layout"])
@ -176,12 +195,12 @@ static __strong NSData *cellDividerData;
} }
if (!cellDividerData) return %orig; if (!cellDividerData) return %orig;
if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) { if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 1 %@", cellDividerData); HBLogDebug(@"YTX adLogging 1 %@", cellDividerData);
return cellDividerData; return cellDividerData;
} }
NSString *adString = getAdString(description); NSString *adString = getAdString(description);
if (adString) { if (adString) {
// HBLogInfo(@"YTX getAdString 1 %@ %@", adString, cellDividerData); HBLogDebug(@"YTX getAdString 1 %@ %@", adString, cellDividerData);
return cellDividerData; return cellDividerData;
} }
return %orig; return %orig;
@ -198,13 +217,13 @@ static __strong NSData *cellDividerData;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject]; YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer; YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) { if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 2 %@", elementRenderer); HBLogDebug(@"YTX adLogging 2 %@", elementRenderer);
return YES; return YES;
} }
NSString *description = [elementRenderer description]; NSString *description = [elementRenderer description];
NSString *adString = getAdString(description); NSString *adString = getAdString(description);
if (adString) { if (adString) {
// HBLogInfo(@"YTX getAdString 2 %@ %@", adString, elementRenderer); HBLogDebug(@"YTX getAdString 2 %@ %@", adString, elementRenderer);
return YES; return YES;
} }
return NO; return NO;
@ -234,36 +253,26 @@ static __strong NSData *cellDividerData;
%end %end
// Center YouTube Logo - @arichornlover // Center YouTube Logo - @arichornlover
%group gCenterYouTubeLogo // BROKEN %group gCenterYouTubeLogo
%hook YTNavigationBarTitleView %hook YTNavigationBarTitleView
- (void)setShouldCenterNavBarTitleView:(BOOL)center { // Doesn't do anything? - (void)setShouldCenterNavBarTitleView:(BOOL)center {
%orig(YES); %orig(center);
if (center) {
[self alignCustomViewToCenterOfWindow];
}
} }
- (BOOL)shouldCenterNavBarTitleView { - (BOOL)shouldCenterNavBarTitleView {
return YES; return YES;
} }
%new;
- (void)alignCustomViewToCenterOfWindow { - (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
%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/ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
%hook YTWatchMiniBarViewController %hook YTWatchMiniBarViewController
- (void)updateMiniBarPlayerStateFromRenderer { - (void)updateMiniBarPlayerStateFromRenderer {
@ -852,28 +861,13 @@ static int contrastMode() {
%end %end
%end %end
// Fullscreen to the Right (iPhone-exclusive) - @arichornlover // Fullscreen to the Right (iPhone-exclusive) - @arichornlover & @bhackel
// NOTE: Please turn off the “Portrait Fullscreen” Option while the code below is active // WARNING: Please turn off the “Portrait Fullscreen” and "iPad Layout" Options while the option "Fullscreen to the Right" is enabled below.
%group gFullscreenToTheRight %group gFullscreenToTheRight
%hook YTWatchViewController %hook YTWatchViewController
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { - (UIInterfaceOrientationMask)allowedFullScreenOrientations {
if ([self isFullscreen] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { UIInterfaceOrientationMask orientations = UIInterfaceOrientationMaskLandscapeRight;
return UIInterfaceOrientationLandscapeRight; return orientations;
}
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"];
}
} }
%end %end
%end %end
@ -1094,7 +1088,16 @@ static int contrastMode() {
- (BOOL)fullscreenButtonDisabled { return YES; } - (BOOL)fullscreenButtonDisabled { return YES; }
- (BOOL)canShowFullscreenButton { return NO; } - (BOOL)canShowFullscreenButton { return NO; }
- (BOOL)canShowFullscreenButtonExperimental { 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
%end %end
@ -1111,7 +1114,6 @@ static int contrastMode() {
return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig; return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig;
} }
%end %end
// Hide Channel Watermark (for Backwards Compatibility)
%hook YTAnnotationsViewController %hook YTAnnotationsViewController
- (void)loadFeaturedChannelWatermark { - (void)loadFeaturedChannelWatermark {
if (IS_ENABLED(@"hideChannelWatermark_enabled")) {} if (IS_ENABLED(@"hideChannelWatermark_enabled")) {}
@ -1163,7 +1165,7 @@ static int contrastMode() {
%end %end
%end %end
// Hide Video Title (in Fullscreen) - @arichornlover // Hide Video Title when in Fullscreen - @arichornlover
%hook YTMainAppControlsOverlayView %hook YTMainAppControlsOverlayView
- (BOOL)titleViewHidden { - (BOOL)titleViewHidden {
return IS_ENABLED(@"hideVideoTitle_enabled") ? YES : %orig; 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 // Remove “Play next in queue” from the menu (@PoomSmart) - qnblackcat/uYouPlus#1138
%hook YTMenuItemVisibilityHandler %hook YTMenuItemVisibilityHandler
- (BOOL)shouldShowServiceItemRenderer:(YTIMenuConditionalServiceItemRenderer *)renderer { - (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 %end
@ -1597,7 +1599,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end %end
%end %end
// Hide Videos in Fullscreen - @arichornlover // Hide Videos when in Fullscreen - @arichornlover
%group gNoVideosInFullscreen %group gNoVideosInFullscreen
%hook YTFullScreenEngagementOverlayView %hook YTFullScreenEngagementOverlayView
- (void)setRelatedVideosView:(id)view { - (void)setRelatedVideosView:(id)view {
@ -1621,9 +1623,9 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
// iPhone Layout - @LillieH1000 & @arichornlover // iPhone Layout - @LillieH1000 & @arichornlover
%group giPhoneLayout %group giPhoneLayout
%hook UIDevice %hook UIDevice
- (long long)userInterfaceIdiom { - (UIUserInterfaceIdiom)userInterfaceIdiom {
return NO; return UIUserInterfaceIdiomPhone;
} }
%end %end
%hook UIStatusBarStyleAttributes %hook UIStatusBarStyleAttributes
- (long long)idiom { - (long long)idiom {
@ -1632,12 +1634,20 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end %end
%hook UIKBTree %hook UIKBTree
- (long long)nativeIdiom { - (long long)nativeIdiom {
return YES; if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
} }
%end %end
%hook UIKBRenderer %hook UIKBRenderer
- (long long)assetIdiom { - (long long)assetIdiom {
return NO; if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
} }
%end %end
%end %end