Skip to content

Commit

Permalink
style: use for loop instead of multiple ifs on YouTube-X
Browse files Browse the repository at this point in the history
These changes were by: 
asdfzxcvbn
  • Loading branch information
aricloverALT authored Nov 17, 2024
1 parent 4b569e3 commit f17518a
Showing 1 changed file with 24 additions and 40 deletions.
64 changes: 24 additions & 40 deletions Sources/uYouPlus.xm
Original file line number Diff line number Diff line change
Expand Up @@ -323,46 +323,30 @@ YTMainAppControlsOverlayView *controlsOverlayView;
}
%end
NSString *getAdString(NSString *description) {
if ([description containsString:@"brand_promo"])
return @"brand_promo";
if ([description containsString:@"carousel_footered_layout"])
return @"carousel_footered_layout";
if ([description containsString:@"carousel_headered_layout"])
return @"carousel_headered_layout";
if ([description containsString:@"eml.expandable_metadata"])
return @"eml.expandable_metadata";
if ([description containsString:@"feed_ad_metadata"])
return @"feed_ad_metadata";
if ([description containsString:@"full_width_portrait_image_layout"])
return @"full_width_portrait_image_layout";
if ([description containsString:@"full_width_square_image_layout"])
return @"full_width_square_image_layout";
if ([description containsString:@"landscape_image_wide_button_layout"])
return @"landscape_image_wide_button_layout";
if ([description containsString:@"post_shelf"])
return @"post_shelf";
if ([description containsString:@"product_carousel"])
return @"product_carousel";
if ([description containsString:@"product_engagement_panel"])
return @"product_engagement_panel";
if ([description containsString:@"product_item"])
return @"product_item";
if ([description containsString:@"shopping_carousel"])
return @"shopping_carousel";
if ([description containsString:@"shopping_item_card_list"])
return @"shopping_item_card_list";
if ([description containsString:@"statement_banner"])
return @"statement_banner";
if ([description containsString:@"square_image_layout"])
return @"square_image_layout";
if ([description containsString:@"text_image_button_layout"])
return @"text_image_button_layout";
if ([description containsString:@"text_search_ad"])
return @"text_search_ad";
if ([description containsString:@"video_display_full_layout"])
return @"video_display_full_layout";
if ([description containsString:@"video_display_full_buttoned_layout"])
return @"video_display_full_buttoned_layout";
for (NSString *str in @[
@"brand_promo",
@"carousel_footered_layout",
@"carousel_headered_layout",
@"eml.expandable_metadata",
@"feed_ad_metadata",
@"full_width_portrait_image_layout",
@"full_width_square_image_layout",
@"landscape_image_wide_button_layout",
@"post_shelf",
@"product_carousel",
@"product_engagement_panel",
@"product_item",
@"shopping_carousel",
@"shopping_item_card_list",
@"statement_banner",
@"square_image_layout",
@"text_image_button_layout",
@"text_search_ad",
@"video_display_full_layout",
@"video_display_full_buttoned_layout"
])
if ([description containsString:str]) return str;

return nil;
}
static BOOL isAdRenderer(YTIElementRenderer *elementRenderer, int kind) {
Expand Down

0 comments on commit f17518a

Please sign in to comment.