diff --git a/Sources/Settings.xm b/Sources/Settings.xm index 41adf96..8d3d592 100644 --- a/Sources/Settings.xm +++ b/Sources/Settings.xm @@ -6,12 +6,6 @@ #import "../Tweaks/YouTubeHeader/YTSettingsPickerViewController.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; @interface YTSettingsSectionItemManager (uYouPlus) @@ -62,7 +56,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK") titleDescription:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"doubleTapToSeek_disabled") + switchOn:IS_ENABLED(@"doubleTapToSeek_disabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"doubleTapToSeek_disabled"]; return YES; @@ -72,7 +66,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"SNAP_TO_CHAPTER") titleDescription:LOC(@"SNAP_TO_CHAPTER_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"snapToChapter_enabled") + switchOn:IS_ENABLED(@"snapToChapter_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"snapToChapter_enabled"]; return YES; @@ -82,7 +76,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"PINCH_TO_ZOOM") titleDescription:LOC(@"PINCH_TO_ZOOM_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"pinchToZoom_enabled") + switchOn:IS_ENABLED(@"pinchToZoom_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"pinchToZoom_enabled"]; return YES; @@ -92,7 +86,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_MINIPLAYER") titleDescription:LOC(@"YT_MINIPLAYER_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"ytMiniPlayer_enabled") + switchOn:IS_ENABLED(@"ytMiniPlayer_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"]; return YES; @@ -102,7 +96,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"STOCK_VOLUME_HUD") titleDescription:LOC(@"STOCK_VOLUME_HUD_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"stockVolumeHUD_enabled") + switchOn:IS_ENABLED(@"stockVolumeHUD_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"stockVolumeHUD_enabled"]; return YES; @@ -122,7 +116,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_AUTOPLAY_SWITCH") titleDescription:LOC(@"HIDE_AUTOPLAY_SWITCH_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideAutoplaySwitch_enabled") + switchOn:IS_ENABLED(@"hideAutoplaySwitch_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"]; return YES; @@ -132,7 +126,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBTITLES_BUTTON") titleDescription:LOC(@"HIDE_SUBTITLES_BUTTON_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideCC_enabled") + switchOn:IS_ENABLED(@"hideCC_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"]; return YES; @@ -142,7 +136,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HUD_MESSAGES") titleDescription:LOC(@"HIDE_HUD_MESSAGES_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideHUD_enabled") + switchOn:IS_ENABLED(@"hideHUD_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"]; return YES; @@ -152,7 +146,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PAID_PROMOTION_CARDS") titleDescription:LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hidePaidPromotionCard_enabled") + switchOn:IS_ENABLED(@"hidePaidPromotionCard_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePaidPromotionCard_enabled"]; return YES; @@ -162,7 +156,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHANNEL_WATERMARK") titleDescription:LOC(@"HIDE_CHANNEL_WATERMARK_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideChannelWatermark_enabled") + switchOn:IS_ENABLED(@"hideChannelWatermark_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChannelWatermark_enabled"]; return YES; @@ -172,7 +166,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON") titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hidePreviousAndNextButton_enabled") + switchOn:IS_ENABLED(@"hidePreviousAndNextButton_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePreviousAndNextButton_enabled"]; return YES; @@ -182,7 +176,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON") titleDescription:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"replacePreviousAndNextButton_enabled") + switchOn:IS_ENABLED(@"replacePreviousAndNextButton_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"replacePreviousAndNextButton_enabled"]; return YES; @@ -192,7 +186,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RED_PROGRESS_BAR") titleDescription:LOC(@"RED_PROGRESS_BAR_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"redProgressBar_enabled") + switchOn:IS_ENABLED(@"redProgressBar_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"redProgressBar_enabled"]; return YES; @@ -202,7 +196,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HOVER_CARD") titleDescription:LOC(@"HIDE_HOVER_CARD_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideHoverCards_enabled") + switchOn:IS_ENABLED(@"hideHoverCards_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHoverCards_enabled"]; return YES; @@ -212,7 +206,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_RIGHT_PANEL") titleDescription:LOC(@"HIDE_RIGHT_PANEL_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideRightPanel_enabled") + switchOn:IS_ENABLED(@"hideRightPanel_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideRightPanel_enabled"]; return YES; @@ -231,7 +225,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUPER_THANKS") titleDescription:LOC(@"HIDE_SUPER_THANKS_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideBuySuperThanks_enabled") + switchOn:IS_ENABLED(@"hideBuySuperThanks_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideBuySuperThanks_enabled"]; return YES; @@ -241,7 +235,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUBCRIPTIONS") titleDescription:LOC(@"HIDE_SUBCRIPTIONS_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideSubcriptions_enabled") + switchOn:IS_ENABLED(@"hideSubcriptions_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideSubcriptions_enabled"]; return YES; @@ -251,7 +245,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_RESUME_TO_SHORTS") titleDescription:LOC(@"DISABLE_RESUME_TO_SHORTS_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"disableResumeToShorts") + switchOn:IS_ENABLED(@"disableResumeToShorts") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableResumeToShorts"]; return YES; @@ -268,7 +262,7 @@ extern NSBundle *uYouPlusBundle(); YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"THEME_OPTIONS") accessibilityIdentifier:nil detailTextBlock:^NSString *() { - switch (GetSelection(@"appTheme")) { + switch (APP_THEME_IDX) { case 1: return LOC(@"OLED_DARK_THEME_2"); case 2: @@ -299,14 +293,14 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"OLED_KEYBOARD") titleDescription:LOC(@"OLED_KEYBOARD_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"oledKeyBoard_enabled") + switchOn:IS_ENABLED(@"oledKeyBoard_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oledKeyBoard_enabled"]; return YES; } 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]; return YES; }]; @@ -318,7 +312,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"CAST_CONFIRM") titleDescription:LOC(@"CAST_CONFIRM_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"castConfirm_enabled") + switchOn:IS_ENABLED(@"castConfirm_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"]; return YES; @@ -328,7 +322,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_HINTS") titleDescription:LOC(@"DISABLE_HINTS_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"disableHints_enabled") + switchOn:IS_ENABLED(@"disableHints_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"disableHints_enabled"]; return YES; @@ -338,7 +332,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_FLEX") titleDescription:LOC(@"ENABLE_FLEX_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"flex_enabled") + switchOn:IS_ENABLED(@"flex_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"flex_enabled"]; return YES; @@ -348,7 +342,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"ENABLE_YT_STARTUP_ANIMATION") titleDescription:LOC(@"ENABLE_YT_STARTUP_ANIMATION_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"ytStartupAnimation_enabled") + switchOn:IS_ENABLED(@"ytStartupAnimation_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytStartupAnimation_enabled"]; return YES; @@ -358,7 +352,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_CHIP_BAR") titleDescription:LOC(@"HIDE_CHIP_BAR_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideChipBar_enabled") + switchOn:IS_ENABLED(@"hideChipBar_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideChipBar_enabled"]; return YES; @@ -368,7 +362,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE") titleDescription:LOC(@"HIDE_PLAY_NEXT_IN_QUEUE_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"hidePlayNextInQueue_enabled") + switchOn:IS_ENABLED(@"hidePlayNextInQueue_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePlayNextInQueue_enabled"]; return YES; @@ -378,7 +372,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"IPHONE_LAYOUT") titleDescription:LOC(@"IPHONE_LAYOUT_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"iPhoneLayout_enabled") + switchOn:IS_ENABLED(@"iPhoneLayout_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"iPhoneLayout_enabled"]; return YES; @@ -388,7 +382,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"NEW_MINIPLAYER_STYLE") titleDescription:LOC(@"NEW_MINIPLAYER_STYLE_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"bigYTMiniPlayer_enabled") + switchOn:IS_ENABLED(@"bigYTMiniPlayer_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"]; return YES; @@ -398,7 +392,7 @@ extern NSBundle *uYouPlusBundle(); [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"YT_RE_EXPLORE") titleDescription:LOC(@"YT_RE_EXPLORE_DESC") accessibilityIdentifier:nil - switchOn:IsEnabled(@"reExplore_enabled") + switchOn:IS_ENABLED(@"reExplore_enabled") switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"]; return YES; diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index 0b37baa..4250c6f 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -1,5 +1,3 @@ -#import "../Tweaks/YouTubeHeader/YTAppDelegate.h" -#import "../Tweaks/YouTubeHeader/YTPlayerViewController.h" #import #import #import @@ -7,6 +5,9 @@ #import #import #import + +#import "../Tweaks/YouTubeHeader/YTAppDelegate.h" +#import "../Tweaks/YouTubeHeader/YTPlayerViewController.h" #import "../Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h" #import "../Tweaks/YouTubeHeader/YTPlayerViewController.h" #import "../Tweaks/YouTubeHeader/YTWatchController.h" @@ -29,6 +30,8 @@ #define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil] #define YT_BUNDLE_ID @"com.google.ios.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 // IAmYouTube diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index f35631e..4ee98dc 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -1,5 +1,9 @@ #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 NSBundle *uYouPlusBundle() { static NSBundle *bundle = nil; @@ -15,20 +19,6 @@ NSBundle *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 // FLEX @@ -37,7 +27,7 @@ static BOOL oldDarkTheme() { didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL didFinishLaunching = %orig; - if (IsEnabled(@"flex_enabled")) { + if (IS_ENABLED(@"flex_enabled")) { [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; } @@ -45,7 +35,7 @@ static BOOL oldDarkTheme() { } - (void)appWillResignActive:(id)arg1 { %orig; - if (IsEnabled(@"flex_enabled")) { + if (IS_ENABLED(@"flex_enabled")) { [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; } } @@ -137,7 +127,7 @@ static BOOL oldDarkTheme() { // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/ %hook YTWatchMiniBarViewController - (void)updateMiniBarPlayerStateFromRenderer { - if (IsEnabled(@"ytMiniPlayer_enabled")) {} + if (IS_ENABLED(@"ytMiniPlayer_enabled")) {} else { return %orig; } } %end @@ -145,7 +135,7 @@ static BOOL oldDarkTheme() { // YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards %hook YTCreatorEndscreenView - (void)setHidden:(BOOL)hidden { - if (IsEnabled(@"hideHoverCards_enabled")) + if (IS_ENABLED(@"hideHoverCards_enabled")) hidden = YES; %orig; } @@ -154,7 +144,7 @@ static BOOL oldDarkTheme() { // YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm %hook MDXPlaybackRouteButtonController - (void)didPressButton:(id)arg1 { - if (IsEnabled(@"castConfirm_enabled")) { + if (IS_ENABLED(@"castConfirm_enabled")) { NSBundle *tweakBundle = uYouPlusBundle(); YTAlertView *alertView = [%c(YTAlertView) confirmationDialogWithAction:^{ %orig; @@ -234,18 +224,18 @@ static BOOL oldDarkTheme() { // YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo %hook YTMainAppVideoPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data { - if (IsEnabled(@"hidePaidPromotionCard_enabled")) {} + if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {} else { return %orig; } } - (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; } %end %hook YTInlineMutedPlaybackPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data { - if (IsEnabled(@"hidePaidPromotionCard_enabled")) {} + if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {} else { return %orig; } } %end @@ -369,7 +359,7 @@ static void replaceTab(YTIGuideResponse *response) { %hook YTSegmentableInlinePlayerBarView - (void)didMoveToWindow { %orig; - if (IsEnabled(@"snapToChapter_enabled")) { + if (IS_ENABLED(@"snapToChapter_enabled")) { self.enableSnapToChapter = NO; } } @@ -378,7 +368,7 @@ static void replaceTab(YTIGuideResponse *response) { // Disable Pinch to zoom %hook YTColdConfig - (BOOL)videoZoomFreeZoomEnabledGlobalConfig { - return IsEnabled(@"pinchToZoom_enabled") ? NO : %orig; + return IS_ENABLED(@"pinchToZoom_enabled") ? NO : %orig; } %end @@ -399,7 +389,7 @@ static void replaceTab(YTIGuideResponse *response) { %hook YTDoubleTapToSeekController - (void)enableDoubleTapToSeek:(BOOL)arg1 { - return IsEnabled(@"doubleTapToSeek_disabled") ? %orig(NO) : %orig; + return IS_ENABLED(@"doubleTapToSeek_disabled") ? %orig(NO) : %orig; } %end @@ -407,10 +397,10 @@ static void replaceTab(YTIGuideResponse *response) { // Hide CC / Autoplay switch %hook YTMainAppControlsOverlayView - (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 - if (IsEnabled(@"hideAutoplaySwitch_enabled")) {} + if (IS_ENABLED(@"hideAutoplaySwitch_enabled")) {} else { return %orig; } } %end @@ -418,14 +408,14 @@ static void replaceTab(YTIGuideResponse *response) { // Hide HUD Messages %hook YTHUDMessageView - (id)initWithMessage:(id)arg1 dismissHandler:(id)arg2 { - return IsEnabled(@"hideHUD_enabled") ? nil : %orig; + return IS_ENABLED(@"hideHUD_enabled") ? nil : %orig; } %end // Hide Watermark %hook YTAnnotationsViewController - (void)loadFeaturedChannelWatermark { - if (IsEnabled(@"hideChannelWatermark_enabled")) {} + if (IS_ENABLED(@"hideChannelWatermark_enabled")) {} else { return %orig; } } %end @@ -449,14 +439,14 @@ static void replaceTab(YTIGuideResponse *response) { // Bring back the red progress bar - Broken?! %hook YTInlinePlayerBarContainerView - (id)quietProgressBarColor { - return IsEnabled(@"redProgressBar_enabled") ? [UIColor redColor] : %orig; + return IS_ENABLED(@"redProgressBar_enabled") ? [UIColor redColor] : %orig; } %end // Disable the right panel in fullscreen mode %hook YTColdConfig - (BOOL)isLandscapeEngagementPanelEnabled { - return IsEnabled(@"hideRightPanel_enabled") ? NO : %orig; + return IS_ENABLED(@"hideRightPanel_enabled") ? NO : %orig; } %end @@ -464,7 +454,7 @@ static void replaceTab(YTIGuideResponse *response) { %hook _ASDisplayView - (void)didMoveToWindow { %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; } } @@ -472,14 +462,14 @@ static void replaceTab(YTIGuideResponse *response) { %hook YTReelWatchRootViewController - (void)setPausedStateCarouselView { - if (IsEnabled(@"hideSubcriptions_enabled")) {} + if (IS_ENABLED(@"hideSubcriptions_enabled")) {} else { return %orig; } } %end %hook YTShortsStartupCoordinator - (id)evaluateResumeToShorts { - return IsEnabled(@"disableResumeToShorts") ? nil : %orig; + return IS_ENABLED(@"disableResumeToShorts") ? nil : %orig; } %end @@ -594,7 +584,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %hook ASScrollView - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { self.backgroundColor = [UIColor clearColor]; } } @@ -604,7 +594,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %hook ASCollectionView - (void)didMoveToWindow { %orig; - if (isDarkMode() && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) { + if (IS_DARK_APPEARANCE_ENABLED && [self.nextResponder isKindOfClass:%c(_ASDisplayView)]) { self.superview.backgroundColor = [UIColor blackColor]; } } @@ -614,7 +604,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %hook ELMView - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { 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 %hook YTSearchBarView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end // History Search view %hook YTSearchBoxView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end @@ -657,29 +647,29 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: // Comment view %hook YTCommentView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end %hook YTCreateCommentAccessoryView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end %hook YTCreateCommentTextView - (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 - return isDarkMode() ? %orig([UIColor whiteColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor whiteColor]) : %orig; } %end %hook YTCommentDetailHeaderCell - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { 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... - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor clearColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor clearColor]) : %orig; } %end // Live chat comment %hook YCHLiveChatActionPanelView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end %hook YTEmojiTextView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end %hook YCHLiveChatView - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { 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 - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end // %hook YTBackstageCreateRepostDetailView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig([UIColor blackColor]) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig([UIColor blackColor]) : %orig; } %end @@ -730,7 +720,7 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: %hook _ASDisplayView - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { 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.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... %hook ASWAppSwitchingSheetHeaderView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(raisedColor) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig; } %end %hook ASWAppSwitchingSheetFooterView - (void)setBackgroundColor:(UIColor *)color { - return isDarkMode() ? %orig(raisedColor) : %orig; + return IS_DARK_APPEARANCE_ENABLED ? %orig(raisedColor) : %orig; } %end %hook ASWAppSwitcherCollectionViewCell - (void)didMoveToWindow { %orig; - if (isDarkMode()) { + if (IS_DARK_APPEARANCE_ENABLED) { self.backgroundColor = raisedColor; self.subviews[1].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 %hook YTColdConfig - (BOOL)mainAppCoreClientIosEnableStartupAnimation { - return IsEnabled(@"ytStartupAnimation_enabled") ? YES : NO; + return IS_ENABLED(@"ytStartupAnimation_enabled") ? YES : NO; } %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); %init; - if (IsEnabled(@"reExplore_enabled")) { + if (IS_ENABLED(@"reExplore_enabled")) { %init(gReExplore); } - if (IsEnabled(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { + if (IS_ENABLED(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { %init(Main); } - if (IsEnabled(@"hidePreviousAndNextButton_enabled")) { + if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) { %init(gHidePreviousAndNextButton); } - if (IsEnabled(@"replacePreviousAndNextButton_enabled")) { + if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { %init(gReplacePreviousAndNextButton); } - if (oledDarkTheme()) { + if (IS_OLED_DARK_THEME_SELECTED) { %init(gOLED); } - if (oldDarkTheme()) { + if (IS_OLD_DARK_THEME_SELECTED) { %init(gOldDarkTheme) } - if (IsEnabled(@"oledKeyBoard_enabled")) { + if (IS_ENABLED(@"oledKeyBoard_enabled")) { %init(gOLEDKB); } - if (IsEnabled(@"disableHints_enabled")) { + if (IS_ENABLED(@"disableHints_enabled")) { %init(gDisableHints); } - if (IsEnabled(@"hideChipBar_enabled")) { + if (IS_ENABLED(@"hideChipBar_enabled")) { %init(gHideChipBar); } - if (IsEnabled(@"iPhoneLayout_enabled") && (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)) { + if (IS_ENABLED(@"iPhoneLayout_enabled") && (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)) { %init(giPhoneLayout); } - if (IsEnabled(@"stockVolumeHUD_enabled")) { + if (IS_ENABLED(@"stockVolumeHUD_enabled")) { %init(gStockVolumeHUD); }