From ced5cf81df2b2566d4815b18c0384f302ab9683d Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Thu, 15 Feb 2024 09:25:57 +0700 Subject: [PATCH] prepare for uYou v3.0.2+ --- Sources/uYouPlus.xm | 6 +- Sources/uYouPlusPatches.xm | 172 +++++++++++++++++++------------------ 2 files changed, 90 insertions(+), 88 deletions(-) diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index ad364b0..9fb8655 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -332,9 +332,9 @@ NSBundle *tweakBundle = uYouPlusBundle(); if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) { %init(gHidePreviousAndNextButton); } - if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { - %init(gReplacePreviousAndNextButton); - } + // if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { + // %init(gReplacePreviousAndNextButton); + // } if (IS_ENABLED(@"disableHints_enabled")) { %init(gDisableHints); } diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 99ec0b1..a8132c6 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -62,36 +62,36 @@ %end // iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224 -%group iOS16 -%hook OBPrivacyLinkButton -%new -- (instancetype)initWithCaption:(NSString *)caption - buttonText:(NSString *)buttonText - image:(UIImage *)image - imageSize:(CGSize)imageSize - useLargeIcon:(BOOL)useLargeIcon { - return [self initWithCaption:caption - buttonText:buttonText - image:image - imageSize:imageSize - useLargeIcon:useLargeIcon - displayLanguage:[NSLocale currentLocale].languageCode]; -} -%end -%end +// %group iOS16 +// %hook OBPrivacyLinkButton +// %new +// - (instancetype)initWithCaption:(NSString *)caption +// buttonText:(NSString *)buttonText +// image:(UIImage *)image +// imageSize:(CGSize)imageSize +// useLargeIcon:(BOOL)useLargeIcon { +// return [self initWithCaption:caption +// buttonText:buttonText +// image:image +// imageSize:imageSize +// useLargeIcon:useLargeIcon +// displayLanguage:[NSLocale currentLocale].languageCode]; +// } +// %end +// %end // Fix uYou playback speed crashes YT v18.49.3+, see https://github.com/iCrazeiOS/uYouCrashFix -%hook YTPlayerViewController -%new --(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 { - return [[self activeVideo] playbackRate]; -} +// %hook YTPlayerViewController +// %new +// -(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 { +// return [[self activeVideo] playbackRate]; +// } -%new --(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 { - [[self activeVideo] setPlaybackRate:arg2]; -} -%end +// %new +// -(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 { +// [[self activeVideo] setPlaybackRate:arg2]; +// } +// %end // Fix streched artwork in uYou's player view - https://github.com/MiRO92/uYou-for-YouTube/issues/287 %hook ArtworkImageView @@ -116,61 +116,63 @@ %end // Fix uYou's appearance not updating if the app is backgrounded -DownloadsPagerVC *downloadsPagerVC; -NSUInteger selectedTabIndex; -static void refreshUYouAppearance() { - if (!downloadsPagerVC) return; - // View pager - [downloadsPagerVC updatePageStyles]; - // Views - for (UIViewController *vc in [downloadsPagerVC viewControllers]) { - if ([vc isKindOfClass:%c(DownloadingVC)]) { - // `Downloading` view - [(DownloadingVC *)vc updatePageStyles]; - for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells) - if ([cell isKindOfClass:%c(DownloadingCell)]) - [(DownloadingCell *)cell updatePageStyles]; - } - else if ([vc isKindOfClass:%c(DownloadedVC)]) { - // `All`, `Audios`, `Videos`, `Shorts` views - [(DownloadedVC *)vc updatePageStyles]; - for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells) - if ([cell isKindOfClass:%c(DownloadedCell)]) - [(DownloadedCell *)cell updatePageStyles]; - } - } - // View pager tabs - for (UIView *subview in [downloadsPagerVC view].subviews) { - if ([subview isKindOfClass:[UIScrollView class]]) { - UIScrollView *tabs = (UIScrollView *)subview; - NSUInteger i = 0; - for (UIView *item in tabs.subviews) { - if ([item isKindOfClass:[UILabel class]]) { - // Tab label - UILabel *tabLabel = (UILabel *)item; - if (i == selectedTabIndex) {} // Selected tab should be excluded - else [tabLabel setTextColor:[UILabel _defaultColor]]; - i++; - } - } - } - } -} -%hook DownloadsPagerVC -- (instancetype)init { - downloadsPagerVC = %orig; - return downloadsPagerVC; -} -- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { - %orig; selectedTabIndex = arg1; -} -%end -%hook UIViewController -- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { - %orig; - refreshUYouAppearance(); -} -%end +// DownloadsPagerVC *downloadsPagerVC; +// NSUInteger selectedTabIndex; +// static void refreshUYouAppearance() { +// if (!downloadsPagerVC) return; +// // View pager +// [downloadsPagerVC updatePageStyles]; +// // Views +// for (UIViewController *vc in [downloadsPagerVC viewControllers]) { +// if ([vc isKindOfClass:%c(DownloadingVC)]) { +// // `Downloading` view +// [(DownloadingVC *)vc updatePageStyles]; +// for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells) +// if ([cell isKindOfClass:%c(DownloadingCell)]) +// [(DownloadingCell *)cell updatePageStyles]; +// } +// else if ([vc isKindOfClass:%c(DownloadedVC)]) { +// // `All`, `Audios`, `Videos`, `Shorts` views +// [(DownloadedVC *)vc updatePageStyles]; +// for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells) +// if ([cell isKindOfClass:%c(DownloadedCell)]) +// [(DownloadedCell *)cell updatePageStyles]; +// } +// } +// // View pager tabs +// for (UIView *subview in [downloadsPagerVC view].subviews) { +// if ([subview isKindOfClass:[UIScrollView class]]) { +// UIScrollView *tabs = (UIScrollView *)subview; +// NSUInteger i = 0; +// for (UIView *item in tabs.subviews) { +// if ([item isKindOfClass:[UILabel class]]) { +// // Tab label +// UILabel *tabLabel = (UILabel *)item; +// if (i == selectedTabIndex) {} // Selected tab should be excluded +// else [tabLabel setTextColor:[UILabel _defaultColor]]; +// i++; +// } +// } +// } +// } +// } + +// %hook DownloadsPagerVC +// - (instancetype)init { +// downloadsPagerVC = %orig; +// return downloadsPagerVC; +// } +// - (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { +// %orig; selectedTabIndex = arg1; +// } +// %end + +// %hook UIViewController +// - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { +// %orig; +// refreshUYouAppearance(); +// } +// %end // Prevent uYou's playback from colliding with YouTube's %hook PlayerVC @@ -196,9 +198,9 @@ static void refreshUYouAppearance() { %ctor { %init; - if (@available(iOS 16, *)) { - %init(iOS16); - } + // if (@available(iOS 16, *)) { + // %init(iOS16); + // } // Disable broken options