2828- (void )decorateContext:(id )context { if (!kNoAds ) %orig ; }
2929%end
3030
31- BOOL isAd (YTIElementRenderer *self) {
32- if (self == nil ) return NO ;
33- if (self.hasCompatibilityOptions && self.compatibilityOptions .hasAdLoggingData ) return YES ;
31+ %hook YTIElementRenderer
32+ - (NSData *)elementData {
33+ if (self.hasCompatibilityOptions && self.compatibilityOptions .hasAdLoggingData )
34+ return nil ;
3435 NSString *description = [self description ];
3536 if (([description containsString: @" brand_promo" ]
3637 || [description containsString: @" product_carousel" ]
3738 || [description containsString: @" product_engagement_panel" ]
3839 || [description containsString: @" product_item" ]) && kNoAds )
39- return YES ;
40- return NO ;
40+ return [ NSData data ] ;
41+ return %orig ;
4142}
43+ %end
4244
4345%hook YTSectionListViewController
4446- (void )loadWithModel:(YTISectionListRenderer *)model {
@@ -47,7 +49,7 @@ BOOL isAd(YTIElementRenderer *self) {
4749 NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest: ^BOOL (YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
4850 YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer ;
4951 YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject ];
50- return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer || isAd (firstObject. elementRenderer ) ;
52+ return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer ;
5153 }];
5254 [contentsArray removeObjectsAtIndexes: removeIndexes];
5355 } %orig ;
@@ -89,15 +91,6 @@ BOOL isAd(YTIElementRenderer *self) {
8991- (void )showSurveyWithRenderer:(id )arg1 surveyParentResponder:(id )arg2 {}
9092%end
9193
92- // Statement banner
93- %hook YTPremiumSeasonCardCellController
94- - (void )setCell:(id )arg1 { arg1 = NULL ; %orig ; }
95- %end
96-
97- %hook YTPremiumSeasonCardView
98- - (long long )accessibilityElementCount { return 0 ; }
99- %end
100-
10194// Navbar Stuff
10295// Disable Cast
10396%hook MDXPlaybackRouteButtonController
@@ -117,6 +110,7 @@ BOOL isAd(YTIElementRenderer *self) {
117110 if (kNoCast && self.subviews .count > 1 && [self .subviews[1 ].accessibilityIdentifier isEqualToString: @" id.mdx.playbackroute.button" ]) self.subviews [1 ].hidden = YES ; // Hide icon immediately
118111 if (kNoNotifsButton ) self.notificationButton .hidden = YES ;
119112 if (kNoSearchButton ) self.searchButton .hidden = YES ;
113+ if (kNoVoiceSearchButton && self.subviews .count >= 4 && [self .subviews[2 ].accessibilityIdentifier isEqualToString: @" id.settings.overflow.button" ]) self.subviews [3 ].hidden = YES ;
120114}
121115%end
122116
@@ -131,16 +125,21 @@ BOOL isAd(YTIElementRenderer *self) {
131125%end
132126
133127// Remove Subbar
134- %hook YTMySubsFilterHeaderView
128+ %hook YTMySubsFilterHeaderView
135129- (void )setChipFilterView:(id )arg1 { if (!kNoSubbar ) %orig ; }
136130%end
137131
138132%hook YTHeaderContentComboView
139133- (void )enableSubheaderBarWithView:(id )arg1 { if (!kNoSubbar ) %orig ; }
134+ - (void )setFeedHeaderScrollMode:(int )arg1 { kNoSubbar ? %orig (0 ) : %orig ; }
140135%end
141136
142- %hook YTHeaderContentComboView
143- - (void )setFeedHeaderScrollMode:(int )arg1 { kNoSubbar ? %orig (0 ) : %orig ; }
137+ %hook YTChipCloudCell
138+ - (void )layoutSubviews {
139+ if (self.superview && kNoSubbar ) {
140+ [self removeFromSuperview ];
141+ } %orig ;
142+ }
144143%end
145144
146145// Hide Autoplay Switch and Subs Button
@@ -271,27 +270,55 @@ BOOL isAd(YTIElementRenderer *self) {
271270- (void )enableDoubleTapToSeek:(BOOL )arg1 { kNoDoubleTapToSeek ? %orig (NO ) : %orig ; }
272271%end
273272
274- // Remove Shorts (https://github.com/MiRO92/YTNoShorts)
273+ // Fit 'Play All' Buttons Text For Localizations
274+ %hook YTQTMButton
275+ - (void )layoutSubviews {
276+ if ([self .accessibilityIdentifier isEqualToString: @" id.playlist.playall.button" ]) {
277+ self.titleLabel .adjustsFontSizeToFitWidth = YES ;
278+ } %orig ;
279+ }
280+ %end
281+
282+ // Fix Playlist Mini-bar Height For Small Screens
283+ %hook YTPlaylistMiniBarView
284+ - (void )setFrame:(CGRect)frame {
285+ if (frame.size .height < 54.0 ) frame.size .height = 54.0 ;
286+ %orig (frame);
287+ }
288+ %end
289+
290+ // Remove "Play next in queue" from the menu @PoomSmart (https://github.com/qnblackcat/uYouPlus/issues/1138#issuecomment-1606415080)
291+ %hook YTMenuItemVisibilityHandler
292+ - (BOOL )shouldShowServiceItemRenderer:(YTIMenuConditionalServiceItemRenderer *)renderer {
293+ if (kRemovePlayNext && renderer.icon .iconType == 251 ) {
294+ return NO ;
295+ } return %orig ;
296+ }
297+ %end
298+
299+ // Remove Premium Pop-up, Horizontal Video Carousel and Shorts (https://github.com/MiRO92/YTNoShorts)
275300%hook YTAsyncCollectionView
276301- (id )cellForItemAtIndexPath:(NSIndexPath *)indexPath {
277- if (kHideShorts ) {
278- UICollectionViewCell *cell = %orig ;
279- if ([cell isKindOfClass: NSClassFromString (@" _ASCollectionViewCell" )]) {
280- _ASCollectionViewCell *cell = %orig ;
281- if ([cell respondsToSelector: @selector (node )]) {
282- if ([[[cell node ] accessibilityIdentifier ] isEqualToString: @" eml.shorts-shelf" ]) {
283- [self removeShortsCellAtIndexPath: indexPath];
284- }
302+ UICollectionViewCell *cell = %orig ;
303+
304+ if ([cell isKindOfClass: objc_lookUpClass (" _ASCollectionViewCell" )]) {
305+ _ASCollectionViewCell *cell = %orig ;
306+ if ([cell respondsToSelector: @selector (node )]) {
307+ NSString *idToRemove = [[cell node ] accessibilityIdentifier ];
308+ if ([idToRemove isEqualToString: @" statement_banner.view" ] ||
309+ (([idToRemove isEqualToString: @" eml.shorts-grid" ] || [idToRemove isEqualToString: @" eml.shorts-shelf" ]) && kHideShorts )) {
310+ [self removeCellsAtIndexPath: indexPath];
285311 }
286- } else if ([cell isKindOfClass: NSClassFromString (@" YTReelShelfCell" )]) {
287- [self removeShortsCellAtIndexPath: indexPath];
288- } return %orig ;
312+ }
313+ } else if (([cell isKindOfClass: objc_lookUpClass (" YTReelShelfCell" )] && kHideShorts ) ||
314+ ([cell isKindOfClass: objc_lookUpClass (" YTHorizontalCardListCell" )] && kNoContinueWatching )) {
315+ [self removeCellsAtIndexPath: indexPath];
289316 } return %orig ;
290317}
291318
292319%new
293- - (void )removeShortsCellAtIndexPath :(NSIndexPath *)indexPath {
294- [self deleteItemsAtIndexPaths: [ NSArray arrayWithObject: indexPath]];
320+ - (void )removeCellsAtIndexPath :(NSIndexPath *)indexPath {
321+ [self deleteItemsAtIndexPaths: @[ indexPath]];
295322}
296323%end
297324
@@ -544,6 +571,7 @@ static void reloadPrefs() {
544571 kNoCast = [prefs[@" noCast" ] boolValue ] ?: NO ;
545572 kNoNotifsButton = [prefs[@" removeNotifsButton" ] boolValue ] ?: NO ;
546573 kNoSearchButton = [prefs[@" removeSearchButton" ] boolValue ] ?: NO ;
574+ kNoVoiceSearchButton = [prefs[@" removeVoiceSearchButton" ] boolValue ] ?: NO ;
547575 kStickyNavbar = [prefs[@" stickyNavbar" ] boolValue ] ?: NO ;
548576 kNoSubbar = [prefs[@" noSubbar" ] boolValue ] ?: NO ;
549577 kNoYTLogo = [prefs[@" noYTLogo" ] boolValue ] ?: NO ;
@@ -592,6 +620,8 @@ static void reloadPrefs() {
592620 kRemoveSubscriptions = [prefs[@" removeSubscriptions" ] boolValue ] ?: NO ;
593621 kRemoveUploads = (prefs[@" removeUploads" ] != nil ) ? [prefs[@" removeUploads" ] boolValue ] : YES ;
594622 kRemoveLibrary = [prefs[@" removeLibrary" ] boolValue ] ?: NO ;
623+ kRemovePlayNext = [prefs[@" removePlayNext" ] boolValue ] ?: NO ;
624+ kNoContinueWatching = [prefs[@" noContinueWatching" ] boolValue ] ?: NO ;
595625 kPivotIndex = (prefs[@" pivotIndex" ] != nil ) ? [prefs[@" pivotIndex" ] intValue ] : 0 ;
596626 kAdvancedMode = [prefs[@" advancedMode" ] boolValue ] ?: NO ;
597627
@@ -601,6 +631,7 @@ static void reloadPrefs() {
601631 @" noCast" : @(kNoCast ),
602632 @" removeNotifsButton" : @(kNoNotifsButton ),
603633 @" removeSearchButton" : @(kNoSearchButton ),
634+ @" removeVoiceSearchButton" : @(kNoVoiceSearchButton ),
604635 @" stickyNavbar" : @(kStickyNavbar ),
605636 @" noSubbar" : @(kNoSubbar ),
606637 @" noYTLogo" : @(kNoYTLogo ),
@@ -649,6 +680,8 @@ static void reloadPrefs() {
649680 @" removeSubscriptions" : @(kRemoveSubscriptions ),
650681 @" removeUploads" : @(kRemoveUploads ),
651682 @" removeLibrary" : @(kRemoveLibrary ),
683+ @" removePlayNext" : @(kRemovePlayNext ),
684+ @" noContinueWatching" : @(kNoContinueWatching ),
652685 @" pivotIndex" : @(kPivotIndex ),
653686 @" advancedMode" : @(kAdvancedMode )
654687 };
0 commit comments