New File: Patches.xm
Also I reimplemented a long lost feature that was removed from uYouEnhanced. I have re-added the iOS 16 Patch!
This commit is contained in:
parent
dcb094b404
commit
b0d1f91791
1 changed files with 144 additions and 0 deletions
144
Source/Patches.xm
Normal file
144
Source/Patches.xm
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
#import "../uYouPlus.h"
|
||||
|
||||
# pragma mark - YouTube patches
|
||||
|
||||
// Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684)
|
||||
%hook NSBundle
|
||||
- (NSDictionary *)infoDictionary {
|
||||
NSMutableDictionary *info = %orig.mutableCopy;
|
||||
NSString *altBundleIdentifier = info[@"ALTBundleIdentifier"];
|
||||
if (altBundleIdentifier) info[@"CFBundleIdentifier"] = altBundleIdentifier;
|
||||
return info;
|
||||
}
|
||||
%end
|
||||
|
||||
// Workaround for MiRO92/uYou-for-YouTube#12, qnblackcat/uYouPlus#263
|
||||
%hook YTDataUtils
|
||||
+ (NSMutableDictionary *)spamSignalsDictionary {
|
||||
return nil;
|
||||
}
|
||||
+ (NSMutableDictionary *)spamSignalsDictionaryWithoutIDFA {
|
||||
return nil;
|
||||
}
|
||||
%end
|
||||
|
||||
%hook YTHotConfig
|
||||
- (BOOL)disableAfmaIdfaCollection { return NO; }
|
||||
%end
|
||||
|
||||
// Reposition "Create" Tab to the Center in the Pivot Bar - qnblackcat/uYouPlus#107
|
||||
/*
|
||||
static void repositionCreateTab(YTIGuideResponse *response) {
|
||||
NSMutableArray<YTIGuideResponseSupportedRenderers *> *renderers = [response itemsArray];
|
||||
for (YTIGuideResponseSupportedRenderers *guideRenderers in renderers) {
|
||||
YTIPivotBarRenderer *pivotBarRenderer = [guideRenderers pivotBarRenderer];
|
||||
NSMutableArray<YTIPivotBarSupportedRenderers *> *items = [pivotBarRenderer itemsArray];
|
||||
NSUInteger createIndex = [items indexOfObjectPassingTest:^BOOL(YTIPivotBarSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
|
||||
return [[[renderers pivotBarItemRenderer] pivotIdentifier] isEqualToString:@"FEuploads"];
|
||||
}];
|
||||
if (createIndex != NSNotFound) {
|
||||
YTIPivotBarSupportedRenderers *createTab = [items objectAtIndex:createIndex];
|
||||
[items removeObjectAtIndex:createIndex];
|
||||
NSUInteger centerIndex = items.count / 2;
|
||||
[items insertObject:createTab atIndex:centerIndex]; // Reposition the "Create" tab at the center
|
||||
}
|
||||
}
|
||||
}
|
||||
%hook YTGuideServiceCoordinator
|
||||
- (void)handleResponse:(YTIGuideResponse *)response withCompletion:(id)completion {
|
||||
repositionCreateTab(response);
|
||||
%orig(response, completion);
|
||||
}
|
||||
- (void)handleResponse:(YTIGuideResponse *)response error:(id)error completion:(id)completion {
|
||||
repositionCreateTab(response);
|
||||
%orig(response, error, completion);
|
||||
}
|
||||
%end
|
||||
*/
|
||||
|
||||
// https://github.com/PoomSmart/YouTube-X/blob/1e62b68e9027fcb849a75f54a402a530385f2a51/Tweak.x#L27
|
||||
// %hook YTAdsInnerTubeContextDecorator
|
||||
// - (void)decorateContext:(id)context {}
|
||||
// %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
|
||||
- (UITraitCollection *)traitCollection {
|
||||
@try {
|
||||
return %orig;
|
||||
} @catch(NSException *e) {
|
||||
return [UITraitCollection currentTraitCollection];
|
||||
}
|
||||
}
|
||||
%end
|
||||
|
||||
// Prevent uYou player bar from showing when not playing downloaded media
|
||||
%hook PlayerManager
|
||||
- (void)pause {
|
||||
if (isnan([self progress]))
|
||||
return;
|
||||
%orig;
|
||||
}
|
||||
%end
|
||||
|
||||
// Workaround for issue #54
|
||||
%hook YTMainAppVideoPlayerOverlayViewController
|
||||
- (void)updateRelatedVideos {
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"relatedVideosAtTheEndOfYTVideos"] == NO) {}
|
||||
else { return %orig; }
|
||||
}
|
||||
%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
|
||||
|
||||
// Fix streched artwork in uYou's player view - https://github.com/MiRO92/uYou-for-YouTube/issues/287
|
||||
%hook ArtworkImageView
|
||||
- (id)imageView {
|
||||
UIImageView * imageView = %orig;
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
// Make artwork a bit bigger
|
||||
UIView *artworkImageView = imageView.superview;
|
||||
if (artworkImageView != nil && !artworkImageView.translatesAutoresizingMaskIntoConstraints) {
|
||||
[artworkImageView.leftAnchor constraintEqualToAnchor:artworkImageView.superview.leftAnchor constant:16].active = YES;
|
||||
[artworkImageView.rightAnchor constraintEqualToAnchor:artworkImageView.superview.rightAnchor constant:-16].active = YES;
|
||||
}
|
||||
return imageView;
|
||||
}
|
||||
%end
|
||||
|
||||
%ctor {
|
||||
%init;
|
||||
if (@available(iOS 16, *)) {
|
||||
%init(iOS16);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue