From 3738ed19bb3d93021bdc87cc7a30fa241012b257 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:28:00 -0700 Subject: [PATCH] Hide Get Youtube Premium --- Sources/uYouPlus.h | 8 ++++++++ Sources/uYouPlus.xm | 22 ++++++++++++++++++++++ Sources/uYouPlusSettings.xm | 1 + 3 files changed, 31 insertions(+) diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index 9e27478..acb336f 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -27,6 +27,7 @@ #import "Tweaks/YouTubeHeader/YTInlinePlayerBarContainerView.h" #import "Tweaks/YouTubeHeader/YTInnerTubeCollectionViewController.h" #import "Tweaks/YouTubeHeader/YTPivotBarItemView.h" +#import "Tweaks/YouTubeHeader/YTCollectionViewCell.h" // Hide buttons under the video player by @PoomSmart #import "Tweaks/YouTubeHeader/ASCollectionElement.h" @@ -64,6 +65,13 @@ @property(readonly, nonatomic) YTIIcon *iconImage; @end +// Hide Premium Promo in You tab - @bhackel +@interface YTFormattedStringLabel : UILabel +@end +@interface YTLinkCell : YTCollectionViewCell +@property(readonly, nonatomic) YTFormattedStringLabel *titleLabel; +@end + // uYouPlus @interface YTHeaderLogoController : UIView @property(readonly, nonatomic) long long pageStyle; diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index d81c284..a6c9a88 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -274,6 +274,25 @@ BOOL isAd(YTIElementRenderer *self) { - (BOOL)savedSettingShouldExpire { return NO; } %end +// Hide Premium promos in "You" and "Library" tab - @bhackel +%group gHidePremiumPromos + // Hide "Get Youtube Premium" in the "You" tab + %hook YTLinkCell + - (void)layoutSubviews { + %orig; + // Get the text label object for this cell + YTFormattedStringLabel *label = self.titleLabel; + // Check if the cell is a premium promo + if ([label.accessibilityLabel isEqualToString:@"Get YouTube Premium"]) { + // Hide the cell + self.hidden = YES; + self.frame = CGRectZero; + } + } + %end +%end + + // YTShortsProgress - https://github.com/PoomSmart/YTShortsProgress/ %hook YTShortsPlayerViewController - (BOOL)shouldAlwaysEnablePlayerBar { return YES; } @@ -1322,6 +1341,9 @@ static BOOL findCell(ASNodeController *nodeController, NSArray *ide if (IS_ENABLED(@"YTTapToSeek_enabled")) { %init(YTTTS_Tweak); } + if (IS_ENABLED(@"hidePremiumPromos_enabled")) { + %init(gHidePremiumPromos); + } // YTNoModernUI - @arichorn BOOL ytNoModernUIEnabled = IS_ENABLED(@"ytNoModernUI_enabled"); diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index 16b4e0a..eb65e79 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -275,6 +275,7 @@ extern NSBundle *uYouPlusBundle(); SWITCH_ITEM2(LOC(@"Hide `Your data in YouTube` Section"), LOC(@"App restart is required."), @"disableYourDataInYouTubeSection_enabled"); SWITCH_ITEM2(LOC(@"Hide `Privacy` Section"), LOC(@"App restart is required."), @"disablePrivacySection_enabled"); SWITCH_ITEM2(LOC(@"Hide `Live Chat` Section"), LOC(@"App restart is required."), @"disableLiveChatSection_enabled"); + SWITCH_ITEM2(LOC(@"Hide Premium Promos"), LOC(@"App restart is required."), @"hidePremiumPromos_enabled"); # pragma mark - UI interface options SECTION_HEADER(LOC(@"UI Interface Options"));