diff --git a/Sources/AppIconOptionsController.m b/Sources/AppIconOptionsController.m index d09c369..c080407 100644 --- a/Sources/AppIconOptionsController.m +++ b/Sources/AppIconOptionsController.m @@ -2,11 +2,9 @@ #import @interface AppIconOptionsController () - @property (strong, nonatomic) UITableView *tableView; @property (strong, nonatomic) NSArray *appIcons; @property (assign, nonatomic) NSInteger selectedIconIndex; - @end @implementation AppIconOptionsController @@ -15,8 +13,6 @@ [super viewDidLoad]; self.title = @"Change App Icon"; - [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"YTSans-Bold" size:22], NSForegroundColorAttributeName: [UIColor whiteColor]}]; - self.selectedIconIndex = -1; self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; @@ -25,28 +21,11 @@ [self.view addSubview:self.tableView]; self.backButton = [UIButton buttonWithType:UIButtonTypeCustom]; - NSBundle *backIcon = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]]; - UIImage *backImage = [UIImage imageNamed:@"Back.png" inBundle:backIcon compatibleWithTraitCollection:nil]; - backImage = [self resizeImage:backImage newSize:CGSizeMake(24, 24)]; - backImage = [backImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - [self.backButton setTintColor:[UIColor whiteColor]]; - [self.backButton setImage:backImage forState:UIControlStateNormal]; + [self.backButton setImage:[UIImage customBackButtonImage] forState:UIControlStateNormal]; [self.backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; - [self.backButton setFrame:CGRectMake(0, 0, 24, 24)]; UIBarButtonItem *customBackButton = [[UIBarButtonItem alloc] initWithCustomView:self.backButton]; self.navigationItem.leftBarButtonItem = customBackButton; - UIColor *buttonColor = [UIColor colorWithRed:203.0/255.0 green:22.0/255.0 blue:51.0/255.0 alpha:1.0]; - UIImage *resetImage = [UIImage systemImageNamed:@"arrow.clockwise.circle.fill"]; - UIBarButtonItem *resetButton = [[UIBarButtonItem alloc] initWithImage:resetImage style:UIBarButtonItemStylePlain target:self action:@selector(resetIcon)]; - resetButton.tintColor = buttonColor; - - UIImage *saveImage = [UIImage systemImageNamed:@"square.and.arrow.up.fill"]; - UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithImage:saveImage style:UIBarButtonItemStylePlain target:self action:@selector(saveIcon)]; - saveButton.tintColor = buttonColor; - - self.navigationItem.rightBarButtonItems = @[saveButton, resetButton]; - NSString *path = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]; NSBundle *bundle = [NSBundle bundleWithPath:path]; self.appIcons = [bundle pathsForResourcesOfType:@"png" inDirectory:@"AppIcons"]; @@ -77,14 +56,8 @@ cell.imageView.image = iconImage; cell.imageView.layer.cornerRadius = 10.0; cell.imageView.clipsToBounds = YES; - cell.imageView.frame = CGRectMake(10, 10, 40, 40); - cell.textLabel.frame = CGRectMake(60, 10, self.view.frame.size.width - 70, 40); - if (indexPath.row == self.selectedIconIndex) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } + cell.accessoryType = (indexPath.row == self.selectedIconIndex) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; return cell; } @@ -97,11 +70,6 @@ } - (void)resetIcon { - NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; - NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath]; - [infoDict removeObjectForKey:@"ALTAppIcon"]; - [infoDict writeToFile:plistPath atomically:YES]; - [[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) { if (error) { NSLog(@"Error resetting icon: %@", error.localizedDescription); @@ -109,70 +77,37 @@ } else { NSLog(@"Icon reset successfully"); [self showAlertWithTitle:@"Success" message:@"Icon reset successfully"]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); + [self.tableView reloadData]; } }]; } - (void)saveIcon { - if (![UIApplication sharedApplication].supportsAlternateIcons) { - NSLog(@"Alternate icons are not supported on this device."); + if (self.selectedIconIndex < 0) { + [self showAlertWithTitle:@"Error" message:@"No icon selected"]; return; } - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSString *selectedIcon = self.selectedIconIndex >= 0 ? self.appIcons[self.selectedIconIndex] : nil; - if (selectedIcon) { - NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension]; - - NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; - NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath]; - [infoDict setObject:iconName forKey:@"ALTAppIcon"]; - [infoDict writeToFile:plistPath atomically:YES]; - - [[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) { - if (error) { - NSLog(@"Error setting alternate icon: %@", error.localizedDescription); - [self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"]; - } else { - NSLog(@"Alternate icon set successfully"); - [self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); - } - }]; + + NSString *selectedIcon = self.appIcons[self.selectedIconIndex]; + NSString *iconName = [selectedIcon.lastPathComponent stringByDeletingPathExtension]; + + [[UIApplication sharedApplication] setAlternateIconName:iconName completionHandler:^(NSError * _Nullable error) { + if (error) { + NSLog(@"Error setting alternate icon: %@", error.localizedDescription); + [self showAlertWithTitle:@"Error" message:@"Failed to set alternate icon"]; } else { - NSLog(@"Selected icon path is nil"); + NSLog(@"Alternate icon set successfully"); + [self showAlertWithTitle:@"Success" message:@"Alternate icon set successfully"]; + [self.tableView reloadData]; } - }); -} - -- (UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size { - UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); - [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; - UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return resizedImage; -} - -- (UIImage *)resizeImage:(UIImage *)image newSize:(CGSize)newSize { - UIGraphicsBeginImageContextWithOptions(newSize, NO, [UIScreen mainScreen].scale); - [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; - UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return newImage; + }]; } - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message { - dispatch_async(dispatch_get_main_queue(), ^{ - UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; - [alert addAction:okAction]; - [self presentViewController:alert animated:YES completion:nil]; - }); + UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; } - (void)back { diff --git a/Sources/BigYTMiniPlayer.xm b/Sources/BigYTMiniPlayer.xm index d364521..896460d 100644 --- a/Sources/BigYTMiniPlayer.xm +++ b/Sources/BigYTMiniPlayer.xm @@ -25,7 +25,7 @@ %end %ctor { - if (IS_ENABLED(@"bigYTMiniPlayer_enabled") && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { + if (IS_ENABLED(kBigYTMiniPlayer) && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { %init(BigYTMiniPlayer); } } diff --git a/Sources/LowContrastMode.xm b/Sources/LowContrastMode.xm index 72e7a4e..0e4c94f 100644 --- a/Sources/LowContrastMode.xm +++ b/Sources/LowContrastMode.xm @@ -10,10 +10,13 @@ static BOOL lowContrastMode() { static BOOL customContrastMode() { return IS_ENABLED(@"lowContrastMode_enabled") && contrastMode() == 1; } +// static UIColor *whiteTextColor() { +// return [UIColor whiteColor]; +// } UIColor *lcmHexColor; -%group gLowContrastMode // Low Contrast Mode v1.5.2 (Compatible with only YouTube v17.33.2-v17.38.10) +%group gLowContrastMode // Low Contrast Mode v1.6.0 BETA (Compatible with only YouTube v17.33.2-v17.38.10) %hook UIColor + (UIColor *)whiteColor { // Dark Theme Color return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00]; @@ -54,39 +57,51 @@ UIColor *lcmHexColor; %end %hook YTCommonColorPalette - (UIColor *)textPrimary { + NSLog(@"LowContrastMode: textPrimary called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)textSecondary { + NSLog(@"LowContrastMode: textSecondary called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)overlayTextPrimary { + NSLog(@"LowContrastMode: overlayTextPrimary called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)overlayTextSecondary { + NSLog(@"LowContrastMode: overlayTextSecondary called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)iconActive { + NSLog(@"LowContrastMode: iconActive called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)iconActiveOther { + NSLog(@"LowContrastMode: iconActiveOther called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)brandIconActive { + NSLog(@"LowContrastMode: brandIconActive called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)staticBrandWhite { + NSLog(@"LowContrastMode: staticBrandWhite called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)overlayIconActiveOther { + NSLog(@"LowContrastMode: overlayIconActiveOther called"); return self.pageStyle == 1 ? [UIColor whiteColor] : %orig; } - (UIColor *)overlayIconInactive { + NSLog(@"LowContrastMode: overlayIconInactive called"); return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.7] : %orig; } - (UIColor *)overlayIconDisabled { + NSLog(@"LowContrastMode: overlayIconDisabled called"); return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.3] : %orig; } - (UIColor *)overlayFilledButtonActive { + NSLog(@"LowContrastMode: overlayFilledButtonActive called"); return self.pageStyle == 1 ? [[UIColor whiteColor] colorWithAlphaComponent:0.2] : %orig; } %end @@ -246,12 +261,21 @@ UIColor *lcmHexColor; [modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; %orig(modifiedAttributes, state); } +- (void)setCustomTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { + NSMutableDictionary *customAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; + [customAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; + %orig(customAttributes, state); +} %end %hook UIButton - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state { color = [UIColor whiteColor]; %orig(color, state); } +- (void)setCustomTitleColor:(UIColor *)color forState:(UIControlState)state { + color = [UIColor whiteColor]; + %orig(color, state); +} %end %hook UIBarButtonItem - (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { @@ -259,6 +283,11 @@ UIColor *lcmHexColor; [modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; %orig(modifiedAttributes, state); } +- (void)setCustomTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { + NSMutableDictionary *customAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; + [customAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; + %orig(customAttributes, state); +} %end %hook NSAttributedString - (instancetype)initWithString:(NSString *)str attributes:(NSDictionary *)attrs { @@ -550,7 +579,18 @@ UIColor *lcmHexColor; %end %hook CATextLayer - (void)setTextColor:(CGColorRef)textColor { - %orig([UIColor whiteColor].CGColor); + %orig([[UIColor whiteColor] CGColor]); +} +%end +%hook _ASDisplayView +- (void)setAttributedText:(NSAttributedString *)attributedText { + NSMutableAttributedString *newAttributedString = [attributedText mutableCopy]; + [newAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, newAttributedString.length)]; + %orig(newAttributedString); +} +- (void)setTextColor:(UIColor *)textColor { + textColor = [UIColor whiteColor]; + %orig(textColor); } %end %hook ASTextNode @@ -563,20 +603,20 @@ UIColor *lcmHexColor; %end %hook ASTextFieldNode - (void)setTextColor:(UIColor *)textColor { - %orig([UIColor whiteColor]); + %orig([UIColor whiteColor]); } %end %hook ASTextView - (void)setTextColor:(UIColor *)textColor { - %orig([UIColor whiteColor]); + %orig([UIColor whiteColor]); } %end %hook ASButtonNode - (void)setTextColor:(UIColor *)textColor { - %orig([UIColor whiteColor]); + %orig([UIColor whiteColor]); } %end -%hook UIControl // snackbar fix for lcm +%hook UIControl - (UIColor *)backgroundColor { return [UIColor blackColor]; } diff --git a/Sources/SettingsKeys.h b/Sources/SettingsKeys.h index 07274bd..0a74fac 100644 --- a/Sources/SettingsKeys.h +++ b/Sources/SettingsKeys.h @@ -1,16 +1,11 @@ #import "uYouPlus.h" +#import "uYouPlusSettings.h" // Keys for "Copy settings" button (for: uYouEnhanced) // In alphabetical order for tweaks after uYouEnhanced NSArray *NSUserDefaultsCopyKeys = @[ // uYouEnhanced - gathered using get_keys.py - @"autoHideHomeBar_enabled", @"bigYTMiniPlayer_enabled", @"centerYouTubeLogo_enabled", @"classicVideoPlayer_enabled", @"disableAmbientMode_enabled", @"disableAnimatedYouTubeLogo_enabled", @"disableChapterSkip_enabled", @"disableCollapseButton_enabled", @"disableFullscreenButton_enabled", @"disableHints_enabled", - @"disableLiveChatSection_enabled", @"disableManageAllHistorySection_enabled", @"disableModernButtons_enabled", @"disableModernFlags_enabled", @"disableNotificationsSection_enabled", @"disablePrivacySection_enabled", @"disablePullToFull_enabled", @"disableRemainingTime_enabled", @"disableResumeToShorts_enabled",@"disableRoundedHints_enabled", @"disableTryNewFeaturesSection_enabled", @"disableVideoQualityPreferencesSection_enabled", @"disableAccountSection_enabled", - @"doubleTapToSeek_disabled", @"enableShareButton_enabled", @"enableSaveToButton_enabled", @"enableVersionSpoofer_enabled", @"fixLowContrastMode_enabled", @"flex_enabled", @"hideAutoplaySwitch_enabled", @"hideBuySuperThanks_enabled", @"hideCC_enabled", @"hideChannelHeaderLinks_enabled", @"hideChannelWatermark_enabled", - @"hideChipBar_enabled", @"hideClipButton_enabled", @"hideCommentSection_enabled", @"hideCommunityPosts_enabled", @"hideConnectButton_enabled", @"hideDownloadButton_enabled", @"hideDoubleTapToSeekOverlay_enabled", @"hideFullscreenActions_enabled", @"hideHeatwaves_enabled", @"hideHomeTab_enabled", @"hideHoverCards_enabled", @"hideHUD_enabled", @"hideModernFlags_enabled", @"hidePaidPromotionCard_enabled", @"hidePlayNextInQueue_enabled", - @"hidePreviewCommentSection_enabled", @"hidePreviousAndNextButton_enabled", @"hideRemixButton_enabled", @"hideReportButton_enabled", @"hideRightPanel_enabled", @"hideShareButton_enabled", @"hideSponsorBlockButton_enabled", @"hideSubcriptions_enabled", @"hideSubscriptionsNotificationBadge_enabled", @"hideThanksButton_enabled", @"hideVideoPlayerShadowOverlayButtons_enabled", @"hideVideoTitle_enabled", @"hideYouTubeLogo_enabled", - @"lowContrastMode_enabled", @"newSettingsUI_enabled", @"noRelatedWatchNexts_enabled", @"noSuggestedVideo_enabled", @"noVideosInFullscreen_enabled", - @"pinchToZoom_enabled", @"portraitFullscreen_enabled", @"redProgressBar_enabled", @"redSubscribeButton_enabled", @"reExplore_enabled", @"shortsQualityPicker_enabled", @"slideToSeek_enabled", @"snapToChapter_enabled", @"stockVolumeHUD_enabled", @"stickNavigationBar_enabled", @"uYouAdBlockingWorkaround_enabled", @"uYouAdBlockingWorkaroundLite_enabled", @"ytMiniPlayer_enabled", @"ytNoModernUI_enabled", @"ytStartupAnimation_enabled", + kReplaceCopyandPasteButtons, kAppTheme, kOLEDKeyboard, kPortraitFullscreen, kFullscreenToTheRight, kSlideToSeek, kYTTapToSeek, kDoubleTapToSeek, kSnapToChapter, kPinchToZoom, kYTMiniPlayer, kStockVolumeHUD, kReplaceYTDownloadWithuYou, kDisablePullToFull, kDisableChapterSkip, kAlwaysShowRemainingTime, kDisableRemainingTime, kEnableShareButton, kEnableSaveToButton, kHideYTMusicButton, kHideAutoplaySwitch, kHideCC, kHideVideoTitle, kDisableCollapseButton, kDisableFullscreenButton, kHideHUD, kHidePaidPromotionCard, kHideChannelWatermark, kHideVideoPlayerShadowOverlayButtons, kHidePreviousAndNextButton, kRedProgressBar, kHideHoverCards, kHideRightPanel, kHideFullscreenActions, kHideSuggestedVideo, kHideHeatwaves, kHideDoubleTapToSeekOverlay, kHideOverlayDarkBackground, kDisableAmbientMode, kHideVideosInFullscreen, kHideRelatedWatchNexts, kHideBuySuperThanks, kHideSubscriptions, kShortsQualityPicker, kRedSubscribeButton, kHideButtonContainers, kHideConnectButton, kHideShareButton, kHideRemixButton, kHideThanksButton, kHideDownloadButton, kHideClipButton, kHideSaveToPlaylistButton, kHideReportButton, kHidePreviewCommentSection, kHideCommentSection, kDisableAccountSection, kDisableAutoplaySection, kDisableTryNewFeaturesSection, kDisableVideoQualityPreferencesSection, kDisableNotificationsSection, kDisableManageAllHistorySection, kDisableYourDataInYouTubeSection, kDisablePrivacySection, kDisableLiveChatSection, kHidePremiumPromos, kHideHomeTab, kLowContrastMode, kClassicVideoPlayer, kFixLowContrastMode, kDisableModernButtons, kDisableRoundedHints, kDisableModernFlags, kYTNoModernUI, kEnableVersionSpoofer, kGoogleSignInPatch, kAdBlockWorkaroundLite, kAdBlockWorkaround, kYouTabFakePremium, kDisableAnimatedYouTubeLogo, kCenterYouTubeLogo, kHideYouTubeLogo, kYTStartupAnimation, kDisableHints, kStickNavigationBar, kHideiSponsorBlockButton, kHideChipBar, kHidePlayNextInQueue, kHideCommunityPosts, kHideChannelHeaderLinks, kiPhoneLayout, kBigYTMiniPlayer, kReExplore, kAutoHideHomeBar, kHideSubscriptionsNotificationBadge, kFixCasting, kNewSettingsUI, kFlex, kGoogleSigninFix, // uYou - https://github.com/MiRO92/uYou-for-YouTube @"showedWelcomeVC", @"hideShortsTab", @"hideCreateTab", @"hideCastButton", @"relatedVideosAtTheEndOfYTVideos", @"removeYouTubeAds", @"backgroundPlayback", @"disableAgeRestriction", @"iPadLayout", @"noSuggestedVideoAtEnd", @"shortsProgressBar", @"hideShortsCells", @"removeShortsCell", @"startupPage", // DEMC - https://github.com/therealFoxster/DontEatMyContent/blob/master/Tweak.h diff --git a/Sources/YTMiniPlayerEnabler.x.bak b/Sources/YTMiniPlayerEnabler.x.bak index 79b8a64..703e862 100644 --- a/Sources/YTMiniPlayerEnabler.x.bak +++ b/Sources/YTMiniPlayerEnabler.x.bak @@ -3,7 +3,7 @@ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/ %hook YTWatchMiniBarViewController - (void)updateMiniBarPlayerStateFromRenderer { - if (IS_ENABLED(@"ytMiniPlayer_enabled")) {} + if (IS_ENABLED(kYTMiniPlayer)) {} else { return %orig; } } %end diff --git a/Sources/YTNoHoverCards.x.bak b/Sources/YTNoHoverCards.x.bak index 012ed6d..1197ac7 100644 --- a/Sources/YTNoHoverCards.x.bak +++ b/Sources/YTNoHoverCards.x.bak @@ -3,7 +3,7 @@ // YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards %hook YTCreatorEndscreenView - (void)setHidden:(BOOL)hidden { - if (IS_ENABLED(@"hideHoverCards_enabled")) + if (IS_ENABLED(kHideHoverCards)) hidden = YES; %orig; } diff --git a/Sources/YTNoPaidPromo.x.bak b/Sources/YTNoPaidPromo.x.bak index 46825e0..9b1ba89 100644 --- a/Sources/YTNoPaidPromo.x.bak +++ b/Sources/YTNoPaidPromo.x.bak @@ -5,18 +5,18 @@ // YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo %hook YTMainAppVideoPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data { - if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {} + if (IS_ENABLED(kHidePaidPromotionCard)) {} else { return %orig; } } - (void)playerOverlayProvider:(YTPlayerOverlayProvider *)provider didInsertPlayerOverlay:(YTPlayerOverlay *)overlay { - if ([[overlay overlayIdentifier] isEqualToString:@"player_overlay_paid_content"] && IS_ENABLED(@"hidePaidPromotionCard_enabled")) return; + if ([[overlay overlayIdentifier] isEqualToString:@"player_overlay_paid_content"] && IS_ENABLED(kHidePaidPromotionCard)) return; %orig; } %end %hook YTInlineMutedPlaybackPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data { - if (IS_ENABLED(@"hidePaidPromotionCard_enabled")) {} + if (IS_ENABLED(kHidePaidPromotionCard)) {} else { return %orig; } } %end diff --git a/Sources/YTReExplore.x b/Sources/YTReExplore.x index 070f426..34f17c5 100644 --- a/Sources/YTReExplore.x +++ b/Sources/YTReExplore.x @@ -38,7 +38,7 @@ static void replaceTab(YTIGuideResponse *response) { %end %ctor { - if (IS_ENABLED(@"reExplore_enabled")) { + if (IS_ENABLED(kReExplore)) { %init(YTReExplore); } } diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index b70c04d..325240f 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -12,6 +12,9 @@ #import #import #import +#import +#import +#import #import #import #import @@ -62,6 +65,117 @@ #define DEFAULT_RATE 1.0f // YTSpeed #define LOWCONTRASTMODE_CUTOFF_VERSION @"17.38.10" // LowContrastMode (v17.33.2-17.38.10) +// Keys +// Copy/Paste Settings +static NSString *const kReplaceCopyandPasteButtons = @"replaceCopyandPasteButtons_enabled"; +// App appearance +static NSString *const kAppTheme = @"appTheme"; +static NSString *const kOLEDKeyboard = @"oledKeyBoard_enabled"; +// Video player +static NSString *const kPortraitFullscreen = @"portraitFullscreen_enabled"; +static NSString *const kFullscreenToTheRight = @"fullscreenToTheRight_enabled"; +static NSString *const kSlideToSeek = @"slideToSeek_enabled"; +static NSString *const kYTTapToSeek = @"YTTapToSeek_enabled"; +static NSString *const kDoubleTapToSeek = @"doubleTapToSeek_enabled"; +static NSString *const kSnapToChapter = @"snapToChapter_enabled"; +static NSString *const kPinchToZoom = @"pinchToZoom_enabled"; +static NSString *const kYTMiniPlayer = @"ytMiniPlayer_enabled"; +static NSString *const kStockVolumeHUD = @"stockVolumeHUD_enabled"; +static NSString *const kReplaceYTDownloadWithuYou = @"kReplaceYTDownloadWithuYou_enabled"; +static NSString *const kDisablePullToFull = @"disablePullToFull_enabled"; +static NSString *const kDisableChapterSkip = @"disableChapterSkip_enabled"; +static NSString *const kAlwaysShowRemainingTime = @"alwaysShowRemainingTime_enabled"; +static NSString *const kDisableRemainingTime = @"disableRemainingTime_enabled"; +// Video controls overlay +static NSString *const kEnableShareButton = @"enableShareButton_enabled"; +static NSString *const kEnableSaveToButton = @"enableSaveToButton_enabled"; +static NSString *const kHideYTMusicButton = @"hideYTMusicButton_enabled"; +static NSString *const kHideAutoplaySwitch = @"hideAutoplaySwitch_enabled"; +static NSString *const kHideCC = @"hideCC_enabled"; +static NSString *const kHideVideoTitle = @"hideVideoTitle_enabled"; +static NSString *const kDisableCollapseButton = @"disableCollapseButton_enabled"; +static NSString *const kDisableFullscreenButton = @"disableFullscreenButton_enabled"; +static NSString *const kHideHUD = @"hideHUD_enabled"; +static NSString *const kHidePaidPromotionCard = @"hidePaidPromotionCard_enabled"; +static NSString *const kHideChannelWatermark = @"hideChannelWatermark_enabled"; +static NSString *const kHideVideoPlayerShadowOverlayButtons = @"hideVideoPlayerShadowOverlayButtons_enabled"; +static NSString *const kHidePreviousAndNextButton = @"hidePreviousAndNextButton_enabled"; +static NSString *const kRedProgressBar = @"redProgressBar_enabled"; +static NSString *const kHideHoverCards = @"hideHoverCards_enabled"; +static NSString *const kHideRightPanel = @"hideRightPanel_enabled"; +static NSString *const kHideFullscreenActions = @"hideFullscreenActions_enabled"; +static NSString *const kHideSuggestedVideo = @"hideSuggestedVideo_enabled"; +static NSString *const kHideHeatwaves = @"hideHeatwaves_enabled"; +static NSString *const kHideDoubleTapToSeekOverlay = @"hideDoubleTapToSeekOverlay_enabled"; +static NSString *const kHideOverlayDarkBackground = @"hideOverlayDarkBackground_enabled"; +static NSString *const kDisableAmbientMode = @"disableAmbientMode_enabled"; +static NSString *const kHideVideosInFullscreen = @"hideVideosInFullscreen_enabled"; +static NSString *const kHideRelatedWatchNexts = @"hideRelatedWatchNexts_enabled"; +// Shorts control overlay +static NSString *const kHideBuySuperThanks = @"hideBuySuperThanks_enabled"; +static NSString *const kHideSubscriptions = @"hideSubscriptions_enabled"; +static NSString *const kShortsQualityPicker = @"shortsQualityPicker_enabled"; +// Video player buttons +static NSString *const kRedSubscribeButton = @"redSubscribeButton_enabled"; +static NSString *const kHideButtonContainers = @"hideButtonContainers_enabled"; +static NSString *const kHideConnectButton = @"hideConnectButton_enabled"; +static NSString *const kHideShareButton = @"hideShareButton_enabled"; +static NSString *const kHideRemixButton = @"hideRemixButton_enabled"; +static NSString *const kHideThanksButton = @"hideRemixButton_enabled"; +static NSString *const kHideDownloadButton = @"hideDownloadButton_enabled"; +static NSString *const kHideClipButton = @"hideClipButton_enabled"; +static NSString *const kHideSaveToPlaylistButton = @"hideSaveToPlaylistButton_enabled"; +static NSString *const kHideReportButton = @"hideReportButton_enabled"; +static NSString *const kHidePreviewCommentSection = @"hidePreviewCommentSection_enabled"; +static NSString *const kHideCommentSection = @"hideCommentSection_enabled"; +// App settings overlay +static NSString *const kDisableAccountSection = @"disableAccountSection_enabled"; +static NSString *const kDisableAutoplaySection = @"disableAutoplaySection_enabled"; +static NSString *const kDisableTryNewFeaturesSection = @"disableTryNewFeaturesSection_enabled"; +static NSString *const kDisableVideoQualityPreferencesSection = @"disableVideoQualityPreferencesSection_enabled"; +static NSString *const kDisableNotificationsSection = @"disableNotificationsSection_enabled"; +static NSString *const kDisableManageAllHistorySection = @"disableManageAllHistorySection_enabled"; +static NSString *const kDisableYourDataInYouTubeSection = @"disableYourDataInYouTubeSection_enabled"; +static NSString *const kDisablePrivacySection = @"disablePrivacySection_enabled"; +static NSString *const kDisableLiveChatSection = @"disableLiveChatSection_enabled"; +static NSString *const kHidePremiumPromos = @"hidePremiumPromos_enabled"; +// UI Interface +static NSString *const kHideHomeTab = @"hideHomeTab_enabled"; +static NSString *const kLowContrastMode = @"lowContrastMode_enabled"; +static NSString *const kClassicVideoPlayer = @"classicVideoPlayer_enabled"; +static NSString *const kFixLowContrastMode = @"fixLowContrastMode_enabled"; +static NSString *const kDisableModernButtons = @"disableModernButtons_enabled"; +static NSString *const kDisableRoundedHints = @"disableRoundedHints_enabled"; +static NSString *const kDisableModernFlags = @"disableModernFlags_enabled"; +static NSString *const kYTNoModernUI = @"ytNoModernUI_enabled"; +static NSString *const kEnableVersionSpoofer = @"enableVersionSpoofer_enabled"; +// Miscellaneous +static NSString *const kGoogleSignInPatch = @"googleSignInPatch_enabled"; +static NSString *const kAdBlockWorkaroundLite = @"adBlockWorkaroundLite_enabled"; +static NSString *const kAdBlockWorkaround = @"adBlockWorkaround_enabled"; +static NSString *const kYouTabFakePremium = @"youTabFakePremium_enabled"; +static NSString *const kDisableAnimatedYouTubeLogo = @"disableAnimatedYouTubeLogo_enabled"; +static NSString *const kCenterYouTubeLogo = @"centerYouTubeLogo_enabled"; +static NSString *const kHideYouTubeLogo = @"hideYouTubeLogo_enabled"; +static NSString *const kYTStartupAnimation = @"ytStartupAnimation_enabled"; +static NSString *const kDisableHints = @"disableHints_enabled"; +static NSString *const kStickNavigationBar = @"stickNavigationBar_enabled"; +static NSString *const kHideiSponsorBlockButton = @"hideiSponsorBlockButton_enabled"; +static NSString *const kHideChipBar = @"hideChipBar_enabled"; +static NSString *const kHidePlayNextInQueue = @"hidePlayNextInQueue_enabled"; +static NSString *const kHideCommunityPosts = @"hideCommunityPosts_enabled"; +static NSString *const kHideChannelHeaderLinks = @"hideChannelHeaderLinks_enabled"; +static NSString *const kiPhoneLayout = @"iPhoneLayout_enabled"; +static NSString *const kBigYTMiniPlayer = @"bigYTMiniPlayer_enabled"; +static NSString *const kReExplore = @"reExplore_enabled"; +static NSString *const kAutoHideHomeBar = @"autoHideHomeBar_enabled"; +static NSString *const kHideSubscriptionsNotificationBadge = @"hideSubscriptionsNotificationBadge_enabled"; +static NSString *const kFixCasting = @"fixCasting_enabled"; +static NSString *const kNewSettingsUI = @"newSettingsUI_enabled"; +static NSString *const kFlex = @"flex_enabled"; +// unused (uYouEnhanced) +static NSString *const kGoogleSigninFix = @"googleSigninFix_enabled"; + // Always show remaining time in video player - @bhackel // Header has been moved to https://github.com/PoomSmart/YouTubeHeader/blob/main/YTPlayerBarController.h // Header has been moved to https://github.com/PoomSmart/YouTubeHeader/blob/main/YTInlinePlayerBarContainerView.h @@ -167,6 +281,9 @@ @interface YTPlaybackButton : UIControl @end +@interface HelperVC : UIViewController +@end + @interface YTPlaylistHeaderViewController : UIViewController @property UIButton *downloadsButton; @end diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index ab46f68..66b60f1 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -1,4 +1,5 @@ #import "uYouPlus.h" +#import "uYouPlusPatches.h" // Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f NSBundle *uYouPlusBundle() { @@ -16,6 +17,142 @@ NSBundle *uYouPlusBundle() { NSBundle *tweakBundle = uYouPlusBundle(); // +// LEGACY VERSION ⚠️ +// Hide the (Connect / Thanks / Save / Report) Buttons under the Video Player - 17.33.2 and up - @arichornlover (inspired by @PoomSmart's version) +%hook _ASDisplayView +- (void)layoutSubviews { + %orig; + BOOL hideConnectButton = IS_ENABLED(@"hideConnectButton_enabled"); + BOOL hideThanksButton = IS_ENABLED(@"hideThanksButton_enabled"); + BOOL hideSaveToPlaylistButton = IS_ENABLED(@"hideSaveToPlaylistButton_enabled"); + BOOL hideReportButton = IS_ENABLED(@"hideReportButton_enabled"); + + for (UIView *subview in self.subviews) { + if ([subview.accessibilityLabel isEqualToString:@"connect account"]) { + subview.hidden = hideConnectButton; + } else if ([subview.accessibilityLabel isEqualToString:@"Thanks"]) { + subview.hidden = hideThanksButton; + } else if ([subview.accessibilityLabel isEqualToString:@"Save to playlist"]) { + subview.hidden = hideSaveToPlaylistButton; + } else if ([subview.accessibilityLabel isEqualToString:@"Report"]) { + subview.hidden = hideReportButton; + } + } +} +%end + +// UPDATED VERSION +// Hide the (Connect / Share / Remix / Thanks / Download / Clip / Save / Report) Buttons under the Video Player - 17.33.2 and up - @PoomSmart (inspired by @arichornlover) - METHOD BROKE Server-Side on May 14th 2024 +static BOOL findCell(ASNodeController *nodeController, NSArray *identifiers) { + for (id child in [nodeController children]) { + NSLog(@"Child: %@", [child description]); + + if ([child isKindOfClass:%c(ELMNodeController)]) { + NSArray *elmChildren = [(ELMNodeController * _Nullable)child children]; + for (ELMComponent *elmChild in elmChildren) { + for (NSString *identifier in identifiers) { + if ([[elmChild description] containsString:identifier]) { + NSLog(@"Found identifier: %@", identifier); + return YES; + } + } + } + } + + if ([child isKindOfClass:%c(ASNodeController)]) { + ASDisplayNode *childNode = ((ASNodeController * _Nullable)child).node; // ELMContainerNode + NSArray *yogaChildren = childNode.yogaChildren; + for (ASDisplayNode *displayNode in yogaChildren) { + NSLog(@"Yoga Child: %@", displayNode.accessibilityIdentifier); + + if ([identifiers containsObject:displayNode.accessibilityIdentifier]) { + NSLog(@"Found identifier: %@", displayNode.accessibilityIdentifier); + return YES; + } + + if (findCell(child, identifiers)) { + return YES; + } + } + } + } + return NO; +} + +%hook ASCollectionView // This stopped working on May 14th 2024 due to a Server-Side Change from YouTube. +- (CGSize)sizeForElement:(ASCollectionElement * _Nullable)element { + if ([self.accessibilityIdentifier isEqualToString:@"id.video.scrollable_action_bar"]) { + ASCellNode *node = [element node]; + ASNodeController *nodeController = [node controller]; + + if (IS_ENABLED(@"hideShareButton_enabled") && findCell(nodeController, @[@"id.video.share.button"])) { + return CGSizeZero; + } + + if (IS_ENABLED(@"hideRemixButton_enabled") && findCell(nodeController, @[@"id.video.remix.button"])) { + return CGSizeZero; + } + + if (IS_ENABLED(@"hideThanksButton_enabled") && findCell(nodeController, @[@"Thanks"])) { + return CGSizeZero; + } + + if (IS_ENABLED(@"hideClipButton_enabled") && findCell(nodeController, @[@"clip_button.eml"])) { + return CGSizeZero; + } + + if (IS_ENABLED(@"hideDownloadButton_enabled") && findCell(nodeController, @[@"id.ui.add_to.offline.button"])) { + return CGSizeZero; + } + + if (IS_ENABLED(@"hideCommentSection_enabled") && findCell(nodeController, @[@"id.ui.carousel_header"])) { + return CGSizeZero; + } + } + return %orig; +} +%end + +// Replace YouTube's download with uYou's +YTMainAppControlsOverlayView *controlsOverlayView; +%hook YTMainAppControlsOverlayView +- (id)initWithDelegate:(id)arg1 { + controlsOverlayView = %orig; + return controlsOverlayView; +} +%end +%hook YTElementsDefaultSheetController ++ (void)showSheetController:(id)arg1 showCommand:(id)arg2 commandContext:(id)arg3 handler:(id)arg4 { + if (IS_ENABLED(kReplaceYTDownloadWithuYou) && [arg2 isKindOfClass:%c(ELMPBShowActionSheetCommand)]) { + ELMPBShowActionSheetCommand *showCommand = (ELMPBShowActionSheetCommand *)arg2; + NSArray *listOptions = [showCommand listOptionArray]; + for (ELMPBElement *element in listOptions) { + ELMPBProperties *properties = [element properties]; + ELMPBIdentifierProperties *identifierProperties = [properties firstSubmessage]; + // 19.30.2 + if ([identifierProperties respondsToSelector:@selector(identifier)]) { + NSString *identifier = [identifierProperties identifier]; + if ([identifier containsString:@"offline_upsell_dialog"]) { + if ([controlsOverlayView respondsToSelector:@selector(uYou)]) { + [controlsOverlayView uYou]; + } + return; + } + } + // 19.20.2 + NSString *description = [identifierProperties description]; + if ([description containsString:@"offline_upsell_dialog"]) { + if ([controlsOverlayView respondsToSelector:@selector(uYou)]) { + [controlsOverlayView uYou]; + } + return; + } + } + } + %orig; +} +%end + # pragma mark - Other hooks // Activate FLEX @@ -24,7 +161,7 @@ NSBundle *tweakBundle = uYouPlusBundle(); didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL didFinishLaunching = %orig; - if (IS_ENABLED(@"flex_enabled")) { + if (IS_ENABLED(kFlex)) { [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; } @@ -32,7 +169,7 @@ NSBundle *tweakBundle = uYouPlusBundle(); } - (void)appWillResignActive:(id)arg1 { %orig; - if (IS_ENABLED(@"flex_enabled")) { + if (IS_ENABLED(kFlex)) { [[%c(FLEXManager) performSelector:@selector(sharedManager)] performSelector:@selector(showExplorer)]; } } @@ -77,7 +214,7 @@ NSBundle *tweakBundle = uYouPlusBundle(); } %end -// uYou AdBlock Workaround LITE (This Version will only remove ads from Videos/Shorts!) - @PoomSmart +// uYou AdBlock Workaround LITE (This Version will only remove ads from only Videos/Shorts!) - @PoomSmart %group uYouAdBlockingWorkaroundLite %hook YTHotConfig - (BOOL)disableAfmaIdfaCollection { return NO; } @@ -244,6 +381,27 @@ static NSMutableArray *filteredArray(NSArray *filteredArray(NSArray *filteredArray(NSArray