Convert simple functions to macros

This commit is contained in:
Foxster
2023-12-25 00:27:46 -08:00
parent 11783bc606
commit 787870cab7
3 changed files with 91 additions and 104 deletions
+30 -36
View File
@@ -6,12 +6,6 @@
#import "../Tweaks/YouTubeHeader/YTSettingsPickerViewController.h" #import "../Tweaks/YouTubeHeader/YTSettingsPickerViewController.h"
#import "uYouPlus.h" #import "uYouPlus.h"
static BOOL IsEnabled(NSString *key) {
return [[NSUserDefaults standardUserDefaults] boolForKey:key];
}
static int GetSelection(NSString *key) {
return [[NSUserDefaults standardUserDefaults] integerForKey:key];
}
static const NSInteger uYouPlusSection = 500; static const NSInteger uYouPlusSection = 500;
@interface YTSettingsSectionItemManager (uYouPlus) @interface YTSettingsSectionItemManager (uYouPlus)
@@ -62,7 +56,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK")
titleDescription:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC") titleDescription:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"doubleTapToSeek_disabled") switchOn:IS_ENABLED(@"doubleTapToSeek_disabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"doubleTapToSeek_disabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"doubleTapToSeek_disabled"];
return YES; return YES;
@@ -72,7 +66,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"SNAP_TO_CHAPTER") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"SNAP_TO_CHAPTER")
titleDescription:LOC(@"SNAP_TO_CHAPTER_DESC") titleDescription:LOC(@"SNAP_TO_CHAPTER_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"snapToChapter_enabled") switchOn:IS_ENABLED(@"snapToChapter_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"snapToChapter_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"snapToChapter_enabled"];
return YES; return YES;
@@ -82,7 +76,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"PINCH_TO_ZOOM") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"PINCH_TO_ZOOM")
titleDescription:LOC(@"PINCH_TO_ZOOM_DESC") titleDescription:LOC(@"PINCH_TO_ZOOM_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"pinchToZoom_enabled") switchOn:IS_ENABLED(@"pinchToZoom_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"pinchToZoom_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"pinchToZoom_enabled"];
return YES; return YES;
@@ -92,7 +86,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_MINIPLAYER") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_MINIPLAYER")
titleDescription:LOC(@"YT_MINIPLAYER_DESC") titleDescription:LOC(@"YT_MINIPLAYER_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"ytMiniPlayer_enabled") switchOn:IS_ENABLED(@"ytMiniPlayer_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"];
return YES; return YES;
@@ -102,7 +96,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"STOCK_VOLUME_HUD") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"STOCK_VOLUME_HUD")
titleDescription:LOC(@"STOCK_VOLUME_HUD_DESC") titleDescription:LOC(@"STOCK_VOLUME_HUD_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"stockVolumeHUD_enabled") switchOn:IS_ENABLED(@"stockVolumeHUD_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"stockVolumeHUD_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"stockVolumeHUD_enabled"];
return YES; return YES;
@@ -122,7 +116,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_AUTOPLAY_SWITCH") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_AUTOPLAY_SWITCH")
titleDescription:LOC(@"HIDE_AUTOPLAY_SWITCH_DESC") titleDescription:LOC(@"HIDE_AUTOPLAY_SWITCH_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideAutoplaySwitch_enabled") switchOn:IS_ENABLED(@"hideAutoplaySwitch_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"];
return YES; return YES;
@@ -132,7 +126,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBTITLES_BUTTON") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBTITLES_BUTTON")
titleDescription:LOC(@"HIDE_SUBTITLES_BUTTON_DESC") titleDescription:LOC(@"HIDE_SUBTITLES_BUTTON_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideCC_enabled") switchOn:IS_ENABLED(@"hideCC_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"];
return YES; return YES;
@@ -142,7 +136,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HUD_MESSAGES") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HUD_MESSAGES")
titleDescription:LOC(@"HIDE_HUD_MESSAGES_DESC") titleDescription:LOC(@"HIDE_HUD_MESSAGES_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideHUD_enabled") switchOn:IS_ENABLED(@"hideHUD_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"];
return YES; return YES;
@@ -152,7 +146,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PAID_PROMOTION_CARDS") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PAID_PROMOTION_CARDS")
titleDescription:LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC") titleDescription:LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hidePaidPromotionCard_enabled") switchOn:IS_ENABLED(@"hidePaidPromotionCard_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePaidPromotionCard_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePaidPromotionCard_enabled"];
return YES; return YES;
@@ -162,7 +156,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHANNEL_WATERMARK") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHANNEL_WATERMARK")
titleDescription:LOC(@"HIDE_CHANNEL_WATERMARK_DESC") titleDescription:LOC(@"HIDE_CHANNEL_WATERMARK_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideChannelWatermark_enabled") switchOn:IS_ENABLED(@"hideChannelWatermark_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChannelWatermark_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChannelWatermark_enabled"];
return YES; return YES;
@@ -172,7 +166,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON")
titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC") titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hidePreviousAndNextButton_enabled") switchOn:IS_ENABLED(@"hidePreviousAndNextButton_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePreviousAndNextButton_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePreviousAndNextButton_enabled"];
return YES; return YES;
@@ -182,7 +176,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON")
titleDescription:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON_DESC") titleDescription:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"replacePreviousAndNextButton_enabled") switchOn:IS_ENABLED(@"replacePreviousAndNextButton_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"replacePreviousAndNextButton_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"replacePreviousAndNextButton_enabled"];
return YES; return YES;
@@ -192,7 +186,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RED_PROGRESS_BAR") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RED_PROGRESS_BAR")
titleDescription:LOC(@"RED_PROGRESS_BAR_DESC") titleDescription:LOC(@"RED_PROGRESS_BAR_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"redProgressBar_enabled") switchOn:IS_ENABLED(@"redProgressBar_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"redProgressBar_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"redProgressBar_enabled"];
return YES; return YES;
@@ -202,7 +196,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HOVER_CARD") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HOVER_CARD")
titleDescription:LOC(@"HIDE_HOVER_CARD_DESC") titleDescription:LOC(@"HIDE_HOVER_CARD_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideHoverCards_enabled") switchOn:IS_ENABLED(@"hideHoverCards_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHoverCards_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHoverCards_enabled"];
return YES; return YES;
@@ -212,7 +206,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_RIGHT_PANEL") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_RIGHT_PANEL")
titleDescription:LOC(@"HIDE_RIGHT_PANEL_DESC") titleDescription:LOC(@"HIDE_RIGHT_PANEL_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideRightPanel_enabled") switchOn:IS_ENABLED(@"hideRightPanel_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideRightPanel_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideRightPanel_enabled"];
return YES; return YES;
@@ -231,7 +225,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUPER_THANKS") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUPER_THANKS")
titleDescription:LOC(@"HIDE_SUPER_THANKS_DESC") titleDescription:LOC(@"HIDE_SUPER_THANKS_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideBuySuperThanks_enabled") switchOn:IS_ENABLED(@"hideBuySuperThanks_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideBuySuperThanks_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideBuySuperThanks_enabled"];
return YES; return YES;
@@ -241,7 +235,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBCRIPTIONS") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBCRIPTIONS")
titleDescription:LOC(@"HIDE_SUBCRIPTIONS_DESC") titleDescription:LOC(@"HIDE_SUBCRIPTIONS_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideSubcriptions_enabled") switchOn:IS_ENABLED(@"hideSubcriptions_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideSubcriptions_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideSubcriptions_enabled"];
return YES; return YES;
@@ -251,7 +245,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_RESUME_TO_SHORTS") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_RESUME_TO_SHORTS")
titleDescription:LOC(@"DISABLE_RESUME_TO_SHORTS_DESC") titleDescription:LOC(@"DISABLE_RESUME_TO_SHORTS_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"disableResumeToShorts") switchOn:IS_ENABLED(@"disableResumeToShorts")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableResumeToShorts"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableResumeToShorts"];
return YES; return YES;
@@ -268,7 +262,7 @@ extern NSBundle *uYouPlusBundle();
YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"THEME_OPTIONS") YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"THEME_OPTIONS")
accessibilityIdentifier:nil accessibilityIdentifier:nil
detailTextBlock:^NSString *() { detailTextBlock:^NSString *() {
switch (GetSelection(@"appTheme")) { switch (APP_THEME_IDX) {
case 1: case 1:
return LOC(@"OLED_DARK_THEME_2"); return LOC(@"OLED_DARK_THEME_2");
case 2: case 2:
@@ -299,14 +293,14 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"OLED_KEYBOARD") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"OLED_KEYBOARD")
titleDescription:LOC(@"OLED_KEYBOARD_DESC") titleDescription:LOC(@"OLED_KEYBOARD_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"oledKeyBoard_enabled") switchOn:IS_ENABLED(@"oledKeyBoard_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oledKeyBoard_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oledKeyBoard_enabled"];
return YES; return YES;
} }
settingItemId:0] settingItemId:0]
]; ];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:GetSelection(@"appTheme") parentResponder:[self parentResponder]]; YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:APP_THEME_IDX parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker]; [settingsViewController pushViewController:picker];
return YES; return YES;
}]; }];
@@ -318,7 +312,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"CAST_CONFIRM") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"CAST_CONFIRM")
titleDescription:LOC(@"CAST_CONFIRM_DESC") titleDescription:LOC(@"CAST_CONFIRM_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"castConfirm_enabled") switchOn:IS_ENABLED(@"castConfirm_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"];
return YES; return YES;
@@ -328,7 +322,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_HINTS") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_HINTS")
titleDescription:LOC(@"DISABLE_HINTS_DESC") titleDescription:LOC(@"DISABLE_HINTS_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"disableHints_enabled") switchOn:IS_ENABLED(@"disableHints_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableHints_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableHints_enabled"];
return YES; return YES;
@@ -338,7 +332,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_FLEX") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_FLEX")
titleDescription:LOC(@"ENABLE_FLEX_DESC") titleDescription:LOC(@"ENABLE_FLEX_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"flex_enabled") switchOn:IS_ENABLED(@"flex_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"flex_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"flex_enabled"];
return YES; return YES;
@@ -348,7 +342,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_YT_STARTUP_ANIMATION") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_YT_STARTUP_ANIMATION")
titleDescription:LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC") titleDescription:LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"ytStartupAnimation_enabled") switchOn:IS_ENABLED(@"ytStartupAnimation_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytStartupAnimation_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytStartupAnimation_enabled"];
return YES; return YES;
@@ -358,7 +352,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHIP_BAR") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHIP_BAR")
titleDescription:LOC(@"HIDE_CHIP_BAR_DESC") titleDescription:LOC(@"HIDE_CHIP_BAR_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hideChipBar_enabled") switchOn:IS_ENABLED(@"hideChipBar_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChipBar_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChipBar_enabled"];
return YES; return YES;
@@ -368,7 +362,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE")
titleDescription:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE_DESC") titleDescription:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"hidePlayNextInQueue_enabled") switchOn:IS_ENABLED(@"hidePlayNextInQueue_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePlayNextInQueue_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePlayNextInQueue_enabled"];
return YES; return YES;
@@ -378,7 +372,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"IPHONE_LAYOUT") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"IPHONE_LAYOUT")
titleDescription:LOC(@"IPHONE_LAYOUT_DESC") titleDescription:LOC(@"IPHONE_LAYOUT_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"iPhoneLayout_enabled") switchOn:IS_ENABLED(@"iPhoneLayout_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"iPhoneLayout_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"iPhoneLayout_enabled"];
return YES; return YES;
@@ -388,7 +382,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"NEW_MINIPLAYER_STYLE") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"NEW_MINIPLAYER_STYLE")
titleDescription:LOC(@"NEW_MINIPLAYER_STYLE_DESC") titleDescription:LOC(@"NEW_MINIPLAYER_STYLE_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"bigYTMiniPlayer_enabled") switchOn:IS_ENABLED(@"bigYTMiniPlayer_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"];
return YES; return YES;
@@ -398,7 +392,7 @@ extern NSBundle *uYouPlusBundle();
[YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_RE_EXPLORE") [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_RE_EXPLORE")
titleDescription:LOC(@"YT_RE_EXPLORE_DESC") titleDescription:LOC(@"YT_RE_EXPLORE_DESC")
accessibilityIdentifier:nil accessibilityIdentifier:nil
switchOn:IsEnabled(@"reExplore_enabled") switchOn:IS_ENABLED(@"reExplore_enabled")
switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"];
return YES; return YES;
+5 -2
View File
@@ -1,5 +1,3 @@
#import "../Tweaks/YouTubeHeader/YTAppDelegate.h"
#import "../Tweaks/YouTubeHeader/YTPlayerViewController.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <objc/runtime.h> #import <objc/runtime.h>
@@ -7,6 +5,9 @@
#import <sys/utsname.h> #import <sys/utsname.h>
#import <substrate.h> #import <substrate.h>
#import <rootless.h> #import <rootless.h>
#import "../Tweaks/YouTubeHeader/YTAppDelegate.h"
#import "../Tweaks/YouTubeHeader/YTPlayerViewController.h"
#import "../Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h" #import "../Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
#import "../Tweaks/YouTubeHeader/YTPlayerViewController.h" #import "../Tweaks/YouTubeHeader/YTPlayerViewController.h"
#import "../Tweaks/YouTubeHeader/YTWatchController.h" #import "../Tweaks/YouTubeHeader/YTWatchController.h"
@@ -29,6 +30,8 @@
#define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil] #define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil]
#define YT_BUNDLE_ID @"com.google.ios.youtube" #define YT_BUNDLE_ID @"com.google.ios.youtube"
#define YT_NAME @"YouTube" #define YT_NAME @"YouTube"
#define IS_ENABLED(k) [[NSUserDefaults standardUserDefaults] boolForKey:k]
#define APP_THEME_IDX [[NSUserDefaults standardUserDefaults] integerForKey:@"appTheme"]
#define DEFAULT_RATE 2.0f // YTSpeed #define DEFAULT_RATE 2.0f // YTSpeed
// IAmYouTube // IAmYouTube
+56 -66
View File
@@ -1,5 +1,9 @@
#import "uYouPlus.h" #import "uYouPlus.h"
#define IS_DARK_APPEARANCE_ENABLED ([[NSUserDefaults standardUserDefaults] integerForKey:@"page_style"] == 1)
#define IS_OLED_DARK_THEME_SELECTED (APP_THEME_IDX == 1)
#define IS_OLD_DARK_THEME_SELECTED (APP_THEME_IDX == 2)
// Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f // Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f
NSBundle *uYouPlusBundle() { NSBundle *uYouPlusBundle() {
static NSBundle *bundle = nil; static NSBundle *bundle = nil;
@@ -15,20 +19,6 @@ NSBundle *uYouPlusBundle() {
} }
NSBundle *tweakBundle = uYouPlusBundle(); NSBundle *tweakBundle = uYouPlusBundle();
//
static BOOL IsEnabled(NSString *key) {
return [[NSUserDefaults standardUserDefaults] boolForKey:key];
}
static BOOL isDarkMode() {
return ([[NSUserDefaults standardUserDefaults] integerForKey:@"page_style"] == 1);
}
static BOOL oledDarkTheme() {
return ([[NSUserDefaults standardUserDefaults] integerForKey:@"appTheme"] == 1);
}
static BOOL oldDarkTheme() {
return ([[NSUserDefaults standardUserDefaults] integerForKey:@"appTheme"] == 2);
}
# pragma mark - Tweaks # pragma mark - Tweaks
// FLEX // FLEX
@@ -37,7 +27,7 @@ static BOOL oldDarkTheme() {
didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions { didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
BOOL didFinishLaunching = %orig; BOOL didFinishLaunching = %orig;
if (IsEnabled(@"flex_enabled")) { if (IS_ENABLED(@"flex_enabled")) {
[[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)];
} }
@@ -45,7 +35,7 @@ static BOOL oldDarkTheme() {
} }
- (void)appWillResignActive:(id)arg1 { - (void)appWillResignActive:(id)arg1 {
%orig; %orig;
if (IsEnabled(@"flex_enabled")) { if (IS_ENABLED(@"flex_enabled")) {
[[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)];
} }
} }
@@ -137,7 +127,7 @@ static BOOL oldDarkTheme() {
// YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
%hook YTWatchMiniBarViewController %hook YTWatchMiniBarViewController
- (void)updateMiniBarPlayerStateFromRenderer { - (void)updateMiniBarPlayerStateFromRenderer {
if (IsEnabled(@"ytMiniPlayer_enabled")) {} if (IS_ENABLED(@"ytMiniPlayer_enabled")) {}
else { return %orig; } else { return %orig; }
} }
%end %end
@@ -145,7 +135,7 @@ static BOOL oldDarkTheme() {
// YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards // YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards
%hook YTCreatorEndscreenView %hook YTCreatorEndscreenView
- (void)setHidden:(BOOL)hidden { - (void)setHidden:(BOOL)hidden {
if (IsEnabled(@"hideHoverCards_enabled")) if (IS_ENABLED(@"hideHoverCards_enabled"))
hidden = YES; hidden = YES;
%orig; %orig;
} }
@@ -154,7 +144,7 @@ static BOOL oldDarkTheme() {
// YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm // YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm
%hook MDXPlaybackRouteButtonController %hook MDXPlaybackRouteButtonController
- (void)didPressButton:(id)arg1 { - (void)didPressButton:(id)arg1 {
if (IsEnabled(@"castConfirm_enabled")) { if (IS_ENABLED(@"castConfirm_enabled")) {
NSBundle *tweakBundle = uYouPlusBundle(); NSBundle *tweakBundle = uYouPlusBundle();
YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{ YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{
%orig; %orig;
@@ -234,18 +224,18 @@ static BOOL oldDarkTheme() {
// YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo // YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo
%hook YTMainAppVideoPlayerOverlayViewController %hook YTMainAppVideoPlayerOverlayViewController
- (void)setPaidContentWithPlayerData:(id)data { - (void)setPaidContentWithPlayerData:(id)data {
if (IsEnabled(@"hidePaidPromotionCard_enabled")) {} if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {}
else { return %orig; } else { return %orig; }
} }
- (void)playerOverlayProvider:(YTPlayerOverlayProvider *)provider didInsertPlayerOverlay:(YTPlayerOverlay *)overlay { - (void)playerOverlayProvider:(YTPlayerOverlayProvider *)provider didInsertPlayerOverlay:(YTPlayerOverlay *)overlay {
if ([[overlay overlayIdentifier] isEqualToString:@"player_overlay_paid_content"] && IsEnabled(@"hidePaidPromotionCard_enabled")) return; if ([[overlay overlayIdentifier] isEqualToString:@"player_overlay_paid_content"] && IS_ENABLED(@"hidePaidPromotionCard_enabled")) return;
%orig; %orig;
} }
%end %end
%hook YTInlineMutedPlaybackPlayerOverlayViewController %hook YTInlineMutedPlaybackPlayerOverlayViewController
- (void)setPaidContentWithPlayerData:(id)data { - (void)setPaidContentWithPlayerData:(id)data {
if (IsEnabled(@"hidePaidPromotionCard_enabled")) {} if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {}
else { return %orig; } else { return %orig; }
} }
%end %end
@@ -369,7 +359,7 @@ static void replaceTab(YTIGuideResponse *response) {
%hook YTSegmentableInlinePlayerBarView %hook YTSegmentableInlinePlayerBarView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (IsEnabled(@"snapToChapter_enabled")) { if (IS_ENABLED(@"snapToChapter_enabled")) {
self.enableSnapToChapter = NO; self.enableSnapToChapter = NO;
} }
} }
@@ -378,7 +368,7 @@ static void replaceTab(YTIGuideResponse *response) {
// Disable Pinch to zoom // Disable Pinch to zoom
%hook YTColdConfig %hook YTColdConfig
- (BOOL)videoZoomFreeZoomEnabledGlobalConfig { - (BOOL)videoZoomFreeZoomEnabledGlobalConfig {
return IsEnabled(@"pinchToZoom_enabled") ? NO : %orig; return IS_ENABLED(@"pinchToZoom_enabled") ? NO : %orig;
} }
%end %end
@@ -399,7 +389,7 @@ static void replaceTab(YTIGuideResponse *response) {
%hook YTDoubleTapToSeekController %hook YTDoubleTapToSeekController
- (void)enableDoubleTapToSeek:(BOOL)arg1 { - (void)enableDoubleTapToSeek:(BOOL)arg1 {
return IsEnabled(@"doubleTapToSeek_disabled") ? %orig(NO) : %orig; return IS_ENABLED(@"doubleTapToSeek_disabled") ? %orig(NO) : %orig;
} }
%end %end
@@ -407,10 +397,10 @@ static void replaceTab(YTIGuideResponse *response) {
// Hide CC / Autoplay switch // Hide CC / Autoplay switch
%hook YTMainAppControlsOverlayView %hook YTMainAppControlsOverlayView
- (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC button - (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC button
return IsEnabled(@"hideCC_enabled") ? %orig(NO) : %orig; return IS_ENABLED(@"hideCC_enabled") ? %orig(NO) : %orig;
} }
- (void)setAutoplaySwitchButtonRenderer:(id)arg1 { // hide Autoplay - (void)setAutoplaySwitchButtonRenderer:(id)arg1 { // hide Autoplay
if (IsEnabled(@"hideAutoplaySwitch_enabled")) {} if (IS_ENABLED(@"hideAutoplaySwitch_enabled")) {}
else { return %orig; } else { return %orig; }
} }
%end %end
@@ -418,14 +408,14 @@ static void replaceTab(YTIGuideResponse *response) {
// Hide HUD Messages // Hide HUD Messages
%hook YTHUDMessageView %hook YTHUDMessageView
- (id)initWithMessage:(id)arg1 dismissHandler:(id)arg2 { - (id)initWithMessage:(id)arg1 dismissHandler:(id)arg2 {
return IsEnabled(@"hideHUD_enabled") ? nil : %orig; return IS_ENABLED(@"hideHUD_enabled") ? nil : %orig;
} }
%end %end
// Hide Watermark // Hide Watermark
%hook YTAnnotationsViewController %hook YTAnnotationsViewController
- (void)loadFeaturedChannelWatermark { - (void)loadFeaturedChannelWatermark {
if (IsEnabled(@"hideChannelWatermark_enabled")) {} if (IS_ENABLED(@"hideChannelWatermark_enabled")) {}
else { return %orig; } else { return %orig; }
} }
%end %end
@@ -449,14 +439,14 @@ static void replaceTab(YTIGuideResponse *response) {
// Bring back the red progress bar - Broken?! // Bring back the red progress bar - Broken?!
%hook YTInlinePlayerBarContainerView %hook YTInlinePlayerBarContainerView
- (id)quietProgressBarColor { - (id)quietProgressBarColor {
return IsEnabled(@"redProgressBar_enabled") ? [UIColor redColor] : %orig; return IS_ENABLED(@"redProgressBar_enabled") ? [UIColor redColor] : %orig;
} }
%end %end
// Disable the right panel in fullscreen mode // Disable the right panel in fullscreen mode
%hook YTColdConfig %hook YTColdConfig
- (BOOL)isLandscapeEngagementPanelEnabled { - (BOOL)isLandscapeEngagementPanelEnabled {
return IsEnabled(@"hideRightPanel_enabled") ? NO : %orig; return IS_ENABLED(@"hideRightPanel_enabled") ? NO : %orig;
} }
%end %end
@@ -464,7 +454,7 @@ static void replaceTab(YTIGuideResponse *response) {
%hook _ASDisplayView %hook _ASDisplayView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if ((IsEnabled(@"hideBuySuperThanks_enabled")) && ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.suggested_action"])) { if ((IS_ENABLED(@"hideBuySuperThanks_enabled")) && ([self.accessibilityIdentifier isEqualToString:@"id.elements.components.suggested_action"])) {
self.hidden = YES; self.hidden = YES;
} }
} }
@@ -472,14 +462,14 @@ static void replaceTab(YTIGuideResponse *response) {
%hook YTReelWatchRootViewController %hook YTReelWatchRootViewController
- (void)setPausedStateCarouselView { - (void)setPausedStateCarouselView {
if (IsEnabled(@"hideSubcriptions_enabled")) {} if (IS_ENABLED(@"hideSubcriptions_enabled")) {}
else { return %orig; } else { return %orig; }
} }
%end %end
%hook YTShortsStartupCoordinator %hook YTShortsStartupCoordinator
- (id)evaluateResumeToShorts { - (id)evaluateResumeToShorts {
return IsEnabled(@"disableResumeToShorts") ? nil : %orig; return IS_ENABLED(@"disableResumeToShorts") ? nil : %orig;
} }
%end %end
@@ -594,7 +584,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook ASScrollView %hook ASScrollView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
self.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor];
} }
} }
@@ -604,7 +594,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook ASCollectionView %hook ASCollectionView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode() && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) { if (IS_DARK_APPEARANCE_ENABLED && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) {
self.superview.backgroundColor = [UIColor blackColor]; self.superview.backgroundColor = [UIColor blackColor];
} }
} }
@@ -614,7 +604,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook ELMView %hook ELMView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
self.subviews[0].backgroundColor = [UIColor clearColor]; self.subviews[0].backgroundColor = [UIColor clearColor];
} }
} }
@@ -642,14 +632,14 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
// Search View // Search View
%hook YTSearchBarView %hook YTSearchBarView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
// History Search view // History Search view
%hook YTSearchBoxView %hook YTSearchBoxView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
@@ -657,29 +647,29 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
// Comment view // Comment view
%hook YTCommentView %hook YTCommentView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
%hook YTCreateCommentAccessoryView %hook YTCreateCommentAccessoryView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
%hook YTCreateCommentTextView %hook YTCreateCommentTextView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
- (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment - (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment
return isDarkMode() ? %orig([UIColor whiteColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor whiteColor]) : %orig;
} }
%end %end
%hook YTCommentDetailHeaderCell %hook YTCommentDetailHeaderCell
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
self.subviews[2].backgroundColor = [UIColor blackColor]; self.subviews[2].backgroundColor = [UIColor blackColor];
} }
} }
@@ -687,27 +677,27 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook YTFormattedStringLabel // YT is werid... %hook YTFormattedStringLabel // YT is werid...
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor clearColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor clearColor]) : %orig;
} }
%end %end
// Live chat comment // Live chat comment
%hook YCHLiveChatActionPanelView %hook YCHLiveChatActionPanelView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
%hook YTEmojiTextView %hook YTEmojiTextView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
%hook YCHLiveChatView %hook YCHLiveChatView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
self.subviews[1].backgroundColor = [UIColor blackColor]; self.subviews[1].backgroundColor = [UIColor blackColor];
} }
} }
@@ -715,14 +705,14 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook YTCollectionView %hook YTCollectionView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
// //
%hook YTBackstageCreateRepostDetailView %hook YTBackstageCreateRepostDetailView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig([UIColor blackColor]) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig;
} }
%end %end
@@ -730,7 +720,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
%hook _ASDisplayView %hook _ASDisplayView
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; } if ([self.nextResponder isKindOfClass:%c(ASScrollView)]) { self.backgroundColor = [UIColor clearColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"eml.cvr"]) { self.backgroundColor = [UIColor blackColor]; }
if ([self.accessibilityIdentifier isEqualToString:@"eml.live_chat_text_message"]) { self.backgroundColor = [UIColor blackColor]; } if ([self.accessibilityIdentifier isEqualToString:@"eml.live_chat_text_message"]) { self.backgroundColor = [UIColor blackColor]; }
@@ -750,20 +740,20 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
// Open link with... // Open link with...
%hook ASWAppSwitchingSheetHeaderView %hook ASWAppSwitchingSheetHeaderView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig(raisedColor) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig;
} }
%end %end
%hook ASWAppSwitchingSheetFooterView %hook ASWAppSwitchingSheetFooterView
- (void)setBackgroundColor:(UIColor *)color { - (void)setBackgroundColor:(UIColor *)color {
return isDarkMode() ? %orig(raisedColor) : %orig; return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig;
} }
%end %end
%hook ASWAppSwitcherCollectionViewCell %hook ASWAppSwitcherCollectionViewCell
- (void)didMoveToWindow { - (void)didMoveToWindow {
%orig; %orig;
if (isDarkMode()) { if (IS_DARK_APPEARANCE_ENABLED) {
self.backgroundColor = raisedColor; self.backgroundColor = raisedColor;
self.subviews[1].backgroundColor = raisedColor; self.subviews[1].backgroundColor = raisedColor;
self.superview.backgroundColor = raisedColor; self.superview.backgroundColor = raisedColor;
@@ -874,7 +864,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
// YT startup animation // YT startup animation
%hook YTColdConfig %hook YTColdConfig
- (BOOL)mainAppCoreClientIosEnableStartupAnimation { - (BOOL)mainAppCoreClientIosEnableStartupAnimation {
return IsEnabled(@"ytStartupAnimation_enabled") ? YES : NO; return IS_ENABLED(@"ytStartupAnimation_enabled") ? YES : NO;
} }
%end %end
@@ -884,37 +874,37 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha:
// dlopen([[NSString stringWithFormat:@"%@/Frameworks/uYou.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY); // dlopen([[NSString stringWithFormat:@"%@/Frameworks/uYou.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY);
%init; %init;
if (IsEnabled(@"reExplore_enabled")) { if (IS_ENABLED(@"reExplore_enabled")) {
%init(gReExplore); %init(gReExplore);
} }
if (IsEnabled(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { if (IS_ENABLED(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
%init(Main); %init(Main);
} }
if (IsEnabled(@"hidePreviousAndNextButton_enabled")) { if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) {
%init(gHidePreviousAndNextButton); %init(gHidePreviousAndNextButton);
} }
if (IsEnabled(@"replacePreviousAndNextButton_enabled")) { if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) {
%init(gReplacePreviousAndNextButton); %init(gReplacePreviousAndNextButton);
} }
if (oledDarkTheme()) { if (IS_OLED_DARK_THEME_SELECTED) {
%init(gOLED); %init(gOLED);
} }
if (oldDarkTheme()) { if (IS_OLD_DARK_THEME_SELECTED) {
%init(gOldDarkTheme) %init(gOldDarkTheme)
} }
if (IsEnabled(@"oledKeyBoard_enabled")) { if (IS_ENABLED(@"oledKeyBoard_enabled")) {
%init(gOLEDKB); %init(gOLEDKB);
} }
if (IsEnabled(@"disableHints_enabled")) { if (IS_ENABLED(@"disableHints_enabled")) {
%init(gDisableHints); %init(gDisableHints);
} }
if (IsEnabled(@"hideChipBar_enabled")) { if (IS_ENABLED(@"hideChipBar_enabled")) {
%init(gHideChipBar); %init(gHideChipBar);
} }
if (IsEnabled(@"iPhoneLayout_enabled") && (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)) { if (IS_ENABLED(@"iPhoneLayout_enabled") && (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)) {
%init(giPhoneLayout); %init(giPhoneLayout);
} }
if (IsEnabled(@"stockVolumeHUD_enabled")) { if (IS_ENABLED(@"stockVolumeHUD_enabled")) {
%init(gStockVolumeHUD); %init(gStockVolumeHUD);
} }