From 08c51e5e5f11953681da20835f67558cf6bd7abe Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:34:47 -0500 Subject: [PATCH 1/9] Revamp uYouPlus.xm --- Sources/uYouPlus.xm | 118 ++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 54 deletions(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index f8298fd..1022692 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -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 *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 *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 *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 *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 From 602b7b76a8efd8de5df77cd33753ee1eb4c11e8b Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:35:54 -0500 Subject: [PATCH 2/9] Update uYouPlus.xm --- Sources/uYouPlus.xm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index 1022692..bd9f160 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -1580,7 +1580,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray *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 ? NO : %orig; + return IS_ENABLED(@"hidePlayNextInQueue_enabled") && renderer.icon.iconType == 251 && renderer.secondaryIcon.iconType == 741 ? NO : %orig; } %end From b681d2140cadf06b947709ebd2b94290ca5708f2 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:37:05 -0500 Subject: [PATCH 3/9] Update uYouPlus.h --- Sources/uYouPlus.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index 66d3514..c444b6c 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -37,6 +37,7 @@ #import #import #import +#import #import #import #import @@ -116,7 +117,12 @@ @interface YTWatchViewController (uYouEnhanced) - (UIInterfaceOrientationMask) supportedInterfaceOrientations; - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation; -- (void)forceRightFullscreenOrientation; +@end + +// Center YouTube Logo (Custom Version) - @arichornlover +@interface YTNavigationBarTitleView (uYouEnhanced) +@property (nonatomic, strong) UIView *customView; +- (void)alignCustomViewToCenterOfWindow; @end // uYouPlus @@ -124,9 +130,6 @@ @property(readonly, nonatomic) long long pageStyle; @end -@interface YTNavigationBarTitleView : UIView -@end - @interface YTChipCloudCell : UIView @end From 6300fd4cac5f8f038c2d79620d02a68dd3e6f6b3 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:59:21 -0500 Subject: [PATCH 4/9] Update .gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index be5e66c..bcfec37 100644 --- a/.gitmodules +++ b/.gitmodules @@ -45,7 +45,7 @@ url = https://github.com/Muirey03/RemoteLog [submodule "Tweaks/DontEatMyContent"] path = Tweaks/DontEatMyContent - url = https://github.com/therealFoxster/DontEatMyContent + url = https://github.com/arichornloverALT/DontEatMyContent [submodule "Tweaks/iSponsorBlock"] path = Tweaks/iSponsorBlock url = https://github.com/Galactic-Dev/iSponsorBlock.git From d16a0ec73d08e625e90e9c55827b9ac98a66a82c Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:33:02 -0500 Subject: [PATCH 5/9] Update YouTube-native-share to 0.2.3 & re-added Google Sign In Fix --- Sources/uYouPlusPatches.xm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 7540250..cbab506 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -2,8 +2,8 @@ # pragma mark - YouTube patches -/* // Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684) +%group gGoogleSignInPatch %hook NSBundle - (NSDictionary *)infoDictionary { NSMutableDictionary *info = %orig.mutableCopy; @@ -12,7 +12,7 @@ return info; } %end -*/ +%end // Workaround for MiRO92/uYou-for-YouTube#12, qnblackcat/uYouPlus#263 %hook YTDataUtils @@ -98,6 +98,7 @@ typedef NS_ENUM(NSInteger, ShareEntityType) { ShareEntityFieldVideo = 1, ShareEntityFieldPlaylist = 2, ShareEntityFieldChannel = 3, + ShareEntityFieldPost = 6, ShareEntityFieldClip = 8 }; @@ -110,6 +111,7 @@ static inline NSString* extractIdWithFormat(GPBUnknownFieldSet *fields, NSIntege NSString *id = [[NSString alloc] initWithData:[idField.lengthDelimitedList firstObject] encoding:NSUTF8StringEncoding]; return [NSString stringWithFormat:format, id]; } + static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *sourceView) { GPBMessage *shareEntity = [%c(GPBMessage) deserializeFromString:serializedShareEntity]; GPBUnknownFieldSet *fields = shareEntity.unknownFields; @@ -138,6 +140,9 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source if (!shareUrl) shareUrl = extractIdWithFormat(fields, ShareEntityFieldVideo, @"https://youtube.com/watch?v=%@"); + if (!shareUrl) + shareUrl = extractIdWithFormat(fields, ShareEntityFieldPost, @"https://youtube.com/post/%@"); + if (!shareUrl) return NO; @@ -166,7 +171,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source YTIShareEntityEndpoint *shareEntityEndpoint = [self.command getExtension:shareEntityEndpointDescriptor]; if (!shareEntityEndpoint.hasSerializedShareEntity) return %orig; - if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity, self.fromView)) + if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity)) return %orig; } %end @@ -174,7 +179,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source /* ------------------- iPhone Layout ------------------- */ %hook ELMPBShowActionSheetCommand -- (void)executeWithCommandContext:(ELMCommandContext*)context handler:(id)_handler { +- (void)executeWithCommandContext:(id)_context handler:(id)_handler { if (!self.hasOnAppear) return %orig; GPBExtensionDescriptor *innertubeCommandDescriptor = [%c(YTIInnertubeCommandExtensionRoot) innertubeCommand]; @@ -187,7 +192,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source YTIUpdateShareSheetCommand *updateShareSheetCommand = [innertubeCommand getExtension:updateShareSheetCommandDescriptor]; if (!updateShareSheetCommand.hasSerializedShareEntity) return %orig; - if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity, context.context.fromView)) + if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity)) return %orig; } %end @@ -331,6 +336,9 @@ static void refreshUYouAppearance() { %ctor { %init; + if (IS_ENABLED(@"googleSignInPatch_enabled")) { + %init(gGoogleSignInPatch); + } // if (@available(iOS 16, *)) { // %init(iOS16); // } From e91b64b2488dd0a6ac6fbffe2ca50c4424f3e52e Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:35:59 -0500 Subject: [PATCH 6/9] Re-add missing youtube-native-share 0.2.3 I accidentally reverted this. It should still work as intended. --- Sources/uYouPlusPatches.xm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index cbab506..95e9acc 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -171,15 +171,16 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source YTIShareEntityEndpoint *shareEntityEndpoint = [self.command getExtension:shareEntityEndpointDescriptor]; if (!shareEntityEndpoint.hasSerializedShareEntity) return %orig; - if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity)) + if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity, self.fromView)) return %orig; } %end + /* ------------------- iPhone Layout ------------------- */ %hook ELMPBShowActionSheetCommand -- (void)executeWithCommandContext:(id)_context handler:(id)_handler { +- (void)executeWithCommandContext:(ELMCommandContext*)context handler:(id)_handler { if (!self.hasOnAppear) return %orig; GPBExtensionDescriptor *innertubeCommandDescriptor = [%c(YTIInnertubeCommandExtensionRoot) innertubeCommand]; @@ -192,7 +193,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source YTIUpdateShareSheetCommand *updateShareSheetCommand = [innertubeCommand getExtension:updateShareSheetCommandDescriptor]; if (!updateShareSheetCommand.hasSerializedShareEntity) return %orig; - if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity)) + if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity, context.context.fromView)) return %orig; } %end From c08e2fcfd5aacc746b38c725e128e31980d2dd3f Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:27:56 -0500 Subject: [PATCH 7/9] Update YouTube-X (uYouPlus.xm) --- Sources/uYouPlus.xm | 89 ++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index bd9f160..5bd4753 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -105,6 +105,14 @@ NSBundle *tweakBundle = uYouPlusBundle(); - (void)decorateContext:(id)context { %orig(nil); } %end +%hook YTLocalPlaybackController +- (id)createAdsPlaybackCoordinator { return nil; } +%end + +%hook MDXSession +- (void)adPlaying:(id)ad {} +%end + %hook YTReelInfinitePlaybackDataSource - (void)setReels:(NSMutableOrderedSet *)reels { [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { @@ -138,6 +146,12 @@ NSBundle *tweakBundle = uYouPlusBundle(); %hook YTAccountScopedAdsInnerTubeContextDecorator - (void)decorateContext:(id)context { %orig(nil); } %end +%hook YTLocalPlaybackController +- (id)createAdsPlaybackCoordinator { return nil; } +%end +%hook MDXSession +- (void)adPlaying:(id)ad {} +%end %hook YTReelInfinitePlaybackDataSource - (void)setReels:(NSMutableOrderedSet *)reels { [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { @@ -147,8 +161,6 @@ 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"]) @@ -185,53 +197,48 @@ NSString *getAdString(NSString *description) { return @"video_display_full_buttoned_layout"; return nil; } -static __strong NSData *cellDividerData; -%hook YTIElementRenderer -- (NSData *)elementData { - NSString *description = [self description]; - if ([description containsString:@"cell_divider"]) { - if (!cellDividerData) cellDividerData = %orig; - return cellDividerData; - } - if (!cellDividerData) return %orig; - if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) { - HBLogDebug(@"YTX adLogging 1 %@", cellDividerData); - return cellDividerData; +static BOOL isAdRenderer(YTIElementRenderer *elementRenderer, int kind) { + if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) { + HBLogDebug(@"YTX adLogging %d %@", kind, elementRenderer); + return YES; } + NSString *description = [elementRenderer description]; NSString *adString = getAdString(description); if (adString) { - HBLogDebug(@"YTX getAdString 1 %@ %@", adString, cellDividerData); - return cellDividerData; + HBLogDebug(@"YTX getAdString %d %@ %@", kind, adString, elementRenderer); + return YES; } - return %orig; + return NO; } -%end -%hook YTInnerTubeCollectionViewController -- (void)loadWithModel:(YTISectionListRenderer *)model { - if ([model isKindOfClass:%c(YTISectionListRenderer)]) { - NSMutableArray *contentsArray = model.contentsArray; - NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) { - if (![renderers isKindOfClass:%c(YTISectionListSupportedRenderers)]) - return NO; - YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer; - YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject]; - YTIElementRenderer *elementRenderer = firstObject.elementRenderer; - if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) { - HBLogDebug(@"YTX adLogging 2 %@", elementRenderer); - return YES; - } - NSString *description = [elementRenderer description]; - NSString *adString = getAdString(description); - if (adString) { - HBLogDebug(@"YTX getAdString 2 %@ %@", adString, elementRenderer); - return YES; - } +static NSMutableArray *filteredArray(NSArray *array) { + NSMutableArray *newArray = [array mutableCopy]; + NSIndexSet *removeIndexes = [newArray indexesOfObjectsPassingTest:^BOOL(YTIItemSectionRenderer *sectionRenderer, NSUInteger idx, BOOL *stop) { + if (![sectionRenderer isKindOfClass:%c(YTIItemSectionRenderer)]) return NO; - }]; - [contentsArray removeObjectsAtIndexes:removeIndexes]; - } + NSMutableArray *contentsArray = sectionRenderer.contentsArray; + if (contentsArray.count > 1) { + NSIndexSet *removeContentsArrayIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTIItemSectionSupportedRenderers *sectionSupportedRenderers, NSUInteger idx2, BOOL *stop2) { + YTIElementRenderer *elementRenderer = sectionSupportedRenderers.elementRenderer; + return isAdRenderer(elementRenderer, 3); + }]; + [contentsArray removeObjectsAtIndexes:removeContentsArrayIndexes]; + } + YTIItemSectionSupportedRenderers *firstObject = [contentsArray firstObject]; + YTIElementRenderer *elementRenderer = firstObject.elementRenderer; + return isAdRenderer(elementRenderer, 2); + }]; + [newArray removeObjectsAtIndexes:removeIndexes]; + return newArray; +} +%hook YTInnerTubeCollectionViewController +- (void)displaySectionsWithReloadingSectionControllerByRenderer:(id)renderer { + NSMutableArray *sectionRenderers = [self valueForKey:@"_sectionRenderers"]; + [self setValue:filteredArray(sectionRenderers) forKey:@"_sectionRenderers"]; %orig; } +- (void)addSectionsFromArray:(NSArray *)array { + %orig(filteredArray(array)); +} %end %end From 064774b9110de80c10948a9e939625629f2f7beb Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:54:03 -0500 Subject: [PATCH 8/9] =?UTF-8?q?Added=20new=20option=20=E2=80=9CYouTube=20S?= =?UTF-8?q?ign-In=20Patch=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/uYouPlusSettings.xm | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index 76dd5c5..d08491d 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -1340,6 +1340,7 @@ extern NSBundle *uYouPlusBundle(); # pragma mark - Miscellaneous SECTION_HEADER(LOC(@"MISCELLANEOUS")); + SWITCH_ITEM2(LOC(@"YouTube Sign-In Patch"), LOC(@"When enabled, it will allow you to sign in on the YouTube App when sideloaded.\nUnwanted Side Effects: Most Icons in the app will be Invisible & Notifications might not work."), @"googleSignInPatch_enabled"); SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND_LITE"), LOC(@"ADBLOCK_WORKAROUND_LITE_DESC"), @"uYouAdBlockingWorkaroundLite_enabled"); SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND"), LOC(@"ADBLOCK_WORKAROUND_DESC"), @"uYouAdBlockingWorkaround_enabled"); SWITCH_ITEM3( From df32a653f7c3d0b3fe8b5cbb39d71cf3208fff45 Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Fri, 16 Aug 2024 20:05:33 -0500 Subject: [PATCH 9/9] Update YouTube-X again (uYouPlus.xm) --- Sources/uYouPlus.xm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index 5bd4753..ab46f68 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -183,6 +183,8 @@ NSString *getAdString(NSString *description) { return @"product_engagement_panel"; if ([description containsString:@"product_item"]) return @"product_item"; + if ([description containsString:@"shopping_carousel"]) + return @"shopping_carousel"; if ([description containsString:@"statement_banner"]) return @"statement_banner"; if ([description containsString:@"square_image_layout"])