Use language-independent method

This commit is contained in:
Bryce Hackel 2024-04-03 11:24:25 -07:00
parent 13f1aa783a
commit 572ebf3e3b
No known key found for this signature in database
GPG key ID: F031960F08455E88
2 changed files with 26 additions and 9 deletions

View file

@ -66,12 +66,13 @@
@end
// Hide Premium Promo in You tab - @bhackel
@interface YTFormattedStringLabel : UILabel
@interface YTIconBadgeView : UIView
@end
@interface YTLinkCell : YTCollectionViewCell
@property(readonly, nonatomic) YTFormattedStringLabel *titleLabel;
@property(readonly, nonatomic) YTIconBadgeView *_iconBadgeView;
@end
// uYouPlus
@interface YTHeaderLogoController : UIView
@property(readonly, nonatomic) long long pageStyle;

View file

@ -280,13 +280,29 @@ BOOL isAd(YTIElementRenderer *self) {
%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;
// Get the badge of this cell, as it is language-independent and unique
YTIconBadgeView *badgeView = self._iconBadgeView;
// First null check for badgeView
if (!badgeView) {
return; // Early return if badgeView is nil
}
// Walk down the subviews to get to a specific view
UIView *subview = badgeView.subviews.firstObject;
// Second null check for the first subview
if (!subview) {
return;
}
UIImageView *imageView = subview.subviews.firstObject;
// Third null check for the imageView
if (!imageView) {
return;
}
// Get the description of this view
NSString *description = imageView.description;
// Check if "yt_outline_youtube_logo_icon" is in the description
if ([description containsString:@"yt_outline_youtube_logo_icon"]) {
self.hidden = YES; // Hide the cell
self.frame = CGRectZero; // Eliminate free space
}
}
%end