Update Patches.xm
This commit is contained in:
parent
e3a5ce60d7
commit
36da48986a
1 changed files with 111 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#import "../uYouPlus.h"
|
||||
#import "uYouPlusPatches.h"
|
||||
|
||||
# pragma mark - YouTube patches
|
||||
|
||||
|
|
@ -62,17 +62,6 @@ static void repositionCreateTab(YTIGuideResponse *response) {
|
|||
// %end
|
||||
|
||||
# pragma mark - uYou patches
|
||||
// Crash fix for uYou >= 18.43.4 (https://github.com/iCrazeiOS/uYouCrashFix)
|
||||
%hook YTPlayerViewController
|
||||
%new
|
||||
-(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 {
|
||||
return [[self activeVideo] playbackRate];
|
||||
}
|
||||
%new
|
||||
-(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 {
|
||||
[[self activeVideo] setPlaybackRate:arg2];
|
||||
}
|
||||
%end
|
||||
|
||||
// Workaround for qnblackcat/uYouPlus#10
|
||||
%hook UIViewController
|
||||
|
|
@ -121,6 +110,19 @@ static void repositionCreateTab(YTIGuideResponse *response) {
|
|||
%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];
|
||||
}
|
||||
|
||||
%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
|
||||
- (id)imageView {
|
||||
|
|
@ -136,9 +138,106 @@ static void repositionCreateTab(YTIGuideResponse *response) {
|
|||
}
|
||||
%end
|
||||
|
||||
// Fix navigation bar showing a lighter grey with default dark mode - https://github.com/therealFoxster/uYouPlus/commit/8db8197
|
||||
%hook YTCommonColorPalette
|
||||
- (UIColor *)brandBackgroundSolid {
|
||||
return self.pageStyle == 1 ? [UIColor colorWithRed:0.05882352941176471 green:0.05882352941176471 blue:0.05882352941176471 alpha:1.0] : %orig;
|
||||
}
|
||||
%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
|
||||
|
||||
// Prevent uYou's playback from colliding with YouTube's
|
||||
BOOL isYTPlaybackActive = NO;
|
||||
%hook HAMPlayerInternal
|
||||
- (void)play { %orig; isYTPlaybackActive = YES; }
|
||||
- (void)terminate { %orig; isYTPlaybackActive = NO; }
|
||||
%end
|
||||
%hook PlayerManager
|
||||
- (void)play {
|
||||
if (isYTPlaybackActive) return;
|
||||
%orig;
|
||||
}
|
||||
%end
|
||||
|
||||
// Temporarily disable uYou's bouncy animation cause it's buggy
|
||||
%hook SSBouncyButton
|
||||
- (void)beginShrinkAnimation {}
|
||||
- (void)beginEnlargeAnimation {}
|
||||
%end
|
||||
|
||||
%ctor {
|
||||
%init;
|
||||
if (@available(iOS 16, *)) {
|
||||
%init(iOS16);
|
||||
}
|
||||
|
||||
// Disable broken options
|
||||
|
||||
// Disable uYou's auto updates
|
||||
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"automaticallyCheckForUpdates"];
|
||||
|
||||
// Disable uYou's welcome screen (fix #1147)
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"showedWelcomeVC"];
|
||||
|
||||
// Disable uYou's disable age restriction
|
||||
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"disableAgeRestriction"];
|
||||
|
||||
// Disable uYou's playback speed controls (prevent crash on video playback https://github.com/therealFoxster/uYouPlus/issues/2#issuecomment-1894912963)
|
||||
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showPlaybackRate"];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue