Merge branch 'arichornlover:main' into main

This commit is contained in:
Suhail Saeed Usmani 2024-08-19 17:02:38 +05:30 committed by GitHub
commit 40f445178f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 127 additions and 95 deletions

2
.gitmodules vendored
View file

@ -45,7 +45,7 @@
url = https://github.com/Muirey03/RemoteLog url = https://github.com/Muirey03/RemoteLog
[submodule "Tweaks/DontEatMyContent"] [submodule "Tweaks/DontEatMyContent"]
path = Tweaks/DontEatMyContent path = Tweaks/DontEatMyContent
url = https://github.com/therealFoxster/DontEatMyContent url = https://github.com/arichornloverALT/DontEatMyContent
[submodule "Tweaks/iSponsorBlock"] [submodule "Tweaks/iSponsorBlock"]
path = Tweaks/iSponsorBlock path = Tweaks/iSponsorBlock
url = https://github.com/Galactic-Dev/iSponsorBlock.git url = https://github.com/Galactic-Dev/iSponsorBlock.git

View file

@ -37,6 +37,7 @@
#import <YouTubeHeader/YTIStringRun.h> #import <YouTubeHeader/YTIStringRun.h>
#import <YouTubeHeader/YTMainAppVideoPlayerOverlayViewController.h> #import <YouTubeHeader/YTMainAppVideoPlayerOverlayViewController.h>
#import <YouTubeHeader/YTMainAppVideoPlayerOverlayView.h> #import <YouTubeHeader/YTMainAppVideoPlayerOverlayView.h>
#import <YouTubeHeader/YTNavigationBarTitleView.h>
#import <YouTubeHeader/YTPlayerBarController.h> #import <YouTubeHeader/YTPlayerBarController.h>
#import <YouTubeHeader/YTPlayerBarRectangleDecorationView.h> #import <YouTubeHeader/YTPlayerBarRectangleDecorationView.h>
#import <YouTubeHeader/YTPlayerOverlay.h> #import <YouTubeHeader/YTPlayerOverlay.h>
@ -116,7 +117,12 @@
@interface YTWatchViewController (uYouEnhanced) @interface YTWatchViewController (uYouEnhanced)
- (UIInterfaceOrientationMask) supportedInterfaceOrientations; - (UIInterfaceOrientationMask) supportedInterfaceOrientations;
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation; - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation;
- (void)forceRightFullscreenOrientation; @end
// Center YouTube Logo (Custom Version) - @arichornlover
@interface YTNavigationBarTitleView (uYouEnhanced)
@property (nonatomic, strong) UIView *customView;
- (void)alignCustomViewToCenterOfWindow;
@end @end
// uYouPlus // uYouPlus
@ -124,9 +130,6 @@
@property(readonly, nonatomic) long long pageStyle; @property(readonly, nonatomic) long long pageStyle;
@end @end
@interface YTNavigationBarTitleView : UIView
@end
@interface YTChipCloudCell : UIView @interface YTChipCloudCell : UIView
@end @end

View file

@ -53,6 +53,23 @@ NSBundle *tweakBundle = uYouPlusBundle();
} }
%end %end
// Fix App Group Directory by move it to document directory
%hook NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier {
if (groupIdentifier != nil) {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [paths lastObject];
return [documentsURL URLByAppendingPathComponent:@"AppGroup"];
}
return %orig(groupIdentifier);
}
%end
// Remove App Rating Prompt in YouTube (for Sideloaded - iOS 14+) - @arichornlover
%hook SKStoreReviewController
+ (void)requestReview { }
%end
// Enable Alternate Icons - @arichornlover // Enable Alternate Icons - @arichornlover
%hook UIApplication %hook UIApplication
- (BOOL)supportsAlternateIcons { - (BOOL)supportsAlternateIcons {
@ -88,6 +105,14 @@ NSBundle *tweakBundle = uYouPlusBundle();
- (void)decorateContext:(id)context { %orig(nil); } - (void)decorateContext:(id)context { %orig(nil); }
%end %end
%hook YTLocalPlaybackController
- (id)createAdsPlaybackCoordinator { return nil; }
%end
%hook MDXSession
- (void)adPlaying:(id)ad {}
%end
%hook YTReelInfinitePlaybackDataSource %hook YTReelInfinitePlaybackDataSource
- (void)setReels:(NSMutableOrderedSet <YTReelModel *> *)reels { - (void)setReels:(NSMutableOrderedSet <YTReelModel *> *)reels {
[reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) {
@ -121,6 +146,12 @@ NSBundle *tweakBundle = uYouPlusBundle();
%hook YTAccountScopedAdsInnerTubeContextDecorator %hook YTAccountScopedAdsInnerTubeContextDecorator
- (void)decorateContext:(id)context { %orig(nil); } - (void)decorateContext:(id)context { %orig(nil); }
%end %end
%hook YTLocalPlaybackController
- (id)createAdsPlaybackCoordinator { return nil; }
%end
%hook MDXSession
- (void)adPlaying:(id)ad {}
%end
%hook YTReelInfinitePlaybackDataSource %hook YTReelInfinitePlaybackDataSource
- (void)setReels:(NSMutableOrderedSet <YTReelModel *> *)reels { - (void)setReels:(NSMutableOrderedSet <YTReelModel *> *)reels {
[reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) {
@ -152,6 +183,8 @@ NSString *getAdString(NSString *description) {
return @"product_engagement_panel"; return @"product_engagement_panel";
if ([description containsString:@"product_item"]) if ([description containsString:@"product_item"])
return @"product_item"; return @"product_item";
if ([description containsString:@"shopping_carousel"])
return @"shopping_carousel";
if ([description containsString:@"statement_banner"]) if ([description containsString:@"statement_banner"])
return @"statement_banner"; return @"statement_banner";
if ([description containsString:@"square_image_layout"]) if ([description containsString:@"square_image_layout"])
@ -166,53 +199,48 @@ NSString *getAdString(NSString *description) {
return @"video_display_full_buttoned_layout"; return @"video_display_full_buttoned_layout";
return nil; return nil;
} }
static __strong NSData *cellDividerData; static BOOL isAdRenderer(YTIElementRenderer *elementRenderer, int kind) {
%hook YTIElementRenderer if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) {
- (NSData *)elementData { HBLogDebug(@"YTX adLogging %d %@", kind, elementRenderer);
NSString *description = [self description]; return YES;
if ([description containsString:@"cell_divider"]) {
if (!cellDividerData) cellDividerData = %orig;
return cellDividerData;
}
if (!cellDividerData) return %orig;
if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 1 %@", cellDividerData);
return cellDividerData;
} }
NSString *description = [elementRenderer description];
NSString *adString = getAdString(description); NSString *adString = getAdString(description);
if (adString) { if (adString) {
// HBLogInfo(@"YTX getAdString 1 %@ %@", adString, cellDividerData); HBLogDebug(@"YTX getAdString %d %@ %@", kind, adString, elementRenderer);
return cellDividerData; return YES;
} }
return %orig; return NO;
} }
%end static NSMutableArray <YTIItemSectionRenderer *> *filteredArray(NSArray <YTIItemSectionRenderer *> *array) {
%hook YTInnerTubeCollectionViewController NSMutableArray <YTIItemSectionRenderer *> *newArray = [array mutableCopy];
- (void)loadWithModel:(YTISectionListRenderer *)model { NSIndexSet *removeIndexes = [newArray indexesOfObjectsPassingTest:^BOOL(YTIItemSectionRenderer *sectionRenderer, NSUInteger idx, BOOL *stop) {
if ([model isKindOfClass:%c(YTISectionListRenderer)]) { if (![sectionRenderer isKindOfClass:%c(YTIItemSectionRenderer)])
NSMutableArray <YTISectionListSupportedRenderers *> *contentsArray = model.contentsArray;
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
if (![renderers isKindOfClass:%c(YTISectionListSupportedRenderers)])
return NO;
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
if ([elementRenderer respondsToSelector:@selector(hasCompatibilityOptions)] && elementRenderer.hasCompatibilityOptions && elementRenderer.compatibilityOptions.hasAdLoggingData) {
// HBLogInfo(@"YTX adLogging 2 %@", elementRenderer);
return YES;
}
NSString *description = [elementRenderer description];
NSString *adString = getAdString(description);
if (adString) {
// HBLogInfo(@"YTX getAdString 2 %@ %@", adString, elementRenderer);
return YES;
}
return NO; return NO;
}]; NSMutableArray <YTIItemSectionSupportedRenderers *> *contentsArray = sectionRenderer.contentsArray;
[contentsArray removeObjectsAtIndexes:removeIndexes]; if (contentsArray.count > 1) {
} NSIndexSet *removeContentsArrayIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTIItemSectionSupportedRenderers *sectionSupportedRenderers, NSUInteger idx2, BOOL *stop2) {
YTIElementRenderer *elementRenderer = sectionSupportedRenderers.elementRenderer;
return isAdRenderer(elementRenderer, 3);
}];
[contentsArray removeObjectsAtIndexes:removeContentsArrayIndexes];
}
YTIItemSectionSupportedRenderers *firstObject = [contentsArray firstObject];
YTIElementRenderer *elementRenderer = firstObject.elementRenderer;
return isAdRenderer(elementRenderer, 2);
}];
[newArray removeObjectsAtIndexes:removeIndexes];
return newArray;
}
%hook YTInnerTubeCollectionViewController
- (void)displaySectionsWithReloadingSectionControllerByRenderer:(id)renderer {
NSMutableArray *sectionRenderers = [self valueForKey:@"_sectionRenderers"];
[self setValue:filteredArray(sectionRenderers) forKey:@"_sectionRenderers"];
%orig; %orig;
} }
- (void)addSectionsFromArray:(NSArray <YTIItemSectionRenderer *> *)array {
%orig(filteredArray(array));
}
%end %end
%end %end
@ -234,36 +262,26 @@ static __strong NSData *cellDividerData;
%end %end
// Center YouTube Logo - @arichornlover // Center YouTube Logo - @arichornlover
%group gCenterYouTubeLogo // BROKEN %group gCenterYouTubeLogo
%hook YTNavigationBarTitleView %hook YTNavigationBarTitleView
- (void)setShouldCenterNavBarTitleView:(BOOL)center { // Doesn't do anything? - (void)setShouldCenterNavBarTitleView:(BOOL)center {
%orig(YES); %orig(center);
if (center) {
[self alignCustomViewToCenterOfWindow];
}
} }
- (BOOL)shouldCenterNavBarTitleView { - (BOOL)shouldCenterNavBarTitleView {
return YES; return YES;
} }
%new;
- (void)alignCustomViewToCenterOfWindow { - (void)alignCustomViewToCenterOfWindow {
CGRect frame = self.customView.frame;
frame.origin.x = (self.window.frame.size.width - frame.size.width) / 2;
self.customView.frame = frame;
} }
%end %end
%end %end
// Fix App Group Directory by move it to document directory
%hook NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier {
if (groupIdentifier != nil) {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [paths lastObject];
return [documentsURL URLByAppendingPathComponent:@"AppGroup"];
}
return %orig(groupIdentifier);
}
%end
// Remove App Rating Prompt in YouTube (for Sideloaded - iOS 14+) - @arichornlover
%hook SKStoreReviewController
+ (void)requestReview { }
%end
// YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
%hook YTWatchMiniBarViewController %hook YTWatchMiniBarViewController
- (void)updateMiniBarPlayerStateFromRenderer { - (void)updateMiniBarPlayerStateFromRenderer {
@ -852,28 +870,13 @@ static int contrastMode() {
%end %end
%end %end
// Fullscreen to the Right (iPhone-exclusive) - @arichornlover // Fullscreen to the Right (iPhone-exclusive) - @arichornlover & @bhackel
// NOTE: Please turn off the “Portrait Fullscreen” Option while the code below is active // WARNING: Please turn off the “Portrait Fullscreen” and "iPad Layout" Options while the option "Fullscreen to the Right" is enabled below.
%group gFullscreenToTheRight %group gFullscreenToTheRight
%hook YTWatchViewController %hook YTWatchViewController
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { - (UIInterfaceOrientationMask)allowedFullScreenOrientations {
if ([self isFullscreen] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { UIInterfaceOrientationMask orientations = UIInterfaceOrientationMaskLandscapeRight;
return UIInterfaceOrientationLandscapeRight; return orientations;
}
return %orig;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
if ([self isFullscreen] && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskLandscape;
}
return %orig;
}
%new
- (void)forceRightFullscreenOrientation { // custom void
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
} }
%end %end
%end %end
@ -1094,7 +1097,16 @@ static int contrastMode() {
- (BOOL)fullscreenButtonDisabled { return YES; } - (BOOL)fullscreenButtonDisabled { return YES; }
- (BOOL)canShowFullscreenButton { return NO; } - (BOOL)canShowFullscreenButton { return NO; }
- (BOOL)canShowFullscreenButtonExperimental { return NO; } - (BOOL)canShowFullscreenButtonExperimental { return NO; }
// - (void)setFullscreenButtonDisabled:(BOOL) // Uncomment and might implement this if needed - @arichornlover // - (void)setFullscreenButtonDisabled:(BOOL) // Might implement this if useful - @arichornlover
- (void)layoutSubviews {
%orig;
if (self.exitFullscreenButton && !self.exitFullscreenButton.hidden) {
self.exitFullscreenButton.hidden = YES;
}
if (self.enterFullscreenButton && !self.enterFullscreenButton.hidden) {
self.enterFullscreenButton.hidden = YES;
}
}
%end %end
%end %end
@ -1111,7 +1123,6 @@ static int contrastMode() {
return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig; return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig;
} }
%end %end
// Hide Channel Watermark (for Backwards Compatibility)
%hook YTAnnotationsViewController %hook YTAnnotationsViewController
- (void)loadFeaturedChannelWatermark { - (void)loadFeaturedChannelWatermark {
if (IS_ENABLED(@"hideChannelWatermark_enabled")) {} if (IS_ENABLED(@"hideChannelWatermark_enabled")) {}
@ -1163,7 +1174,7 @@ static int contrastMode() {
%end %end
%end %end
// Hide Video Title (in Fullscreen) - @arichornlover // Hide Video Title when in Fullscreen - @arichornlover
%hook YTMainAppControlsOverlayView %hook YTMainAppControlsOverlayView
- (BOOL)titleViewHidden { - (BOOL)titleViewHidden {
return IS_ENABLED(@"hideVideoTitle_enabled") ? YES : %orig; return IS_ENABLED(@"hideVideoTitle_enabled") ? YES : %orig;
@ -1597,7 +1608,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end %end
%end %end
// Hide Videos in Fullscreen - @arichornlover // Hide Videos when in Fullscreen - @arichornlover
%group gNoVideosInFullscreen %group gNoVideosInFullscreen
%hook YTFullScreenEngagementOverlayView %hook YTFullScreenEngagementOverlayView
- (void)setRelatedVideosView:(id)view { - (void)setRelatedVideosView:(id)view {
@ -1621,9 +1632,9 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
// iPhone Layout - @LillieH1000 & @arichornlover // iPhone Layout - @LillieH1000 & @arichornlover
%group giPhoneLayout %group giPhoneLayout
%hook UIDevice %hook UIDevice
- (long long)userInterfaceIdiom { - (UIUserInterfaceIdiom)userInterfaceIdiom {
return NO; return UIUserInterfaceIdiomPhone;
} }
%end %end
%hook UIStatusBarStyleAttributes %hook UIStatusBarStyleAttributes
- (long long)idiom { - (long long)idiom {
@ -1632,12 +1643,20 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end %end
%hook UIKBTree %hook UIKBTree
- (long long)nativeIdiom { - (long long)nativeIdiom {
return YES; if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
} }
%end %end
%hook UIKBRenderer %hook UIKBRenderer
- (long long)assetIdiom { - (long long)assetIdiom {
return NO; if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else {
return YES;
}
} }
%end %end
%end %end

View file

@ -2,8 +2,8 @@
# pragma mark - YouTube patches # pragma mark - YouTube patches
/*
// Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684) // Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684)
%group gGoogleSignInPatch
%hook NSBundle %hook NSBundle
- (NSDictionary *)infoDictionary { - (NSDictionary *)infoDictionary {
NSMutableDictionary *info = %orig.mutableCopy; NSMutableDictionary *info = %orig.mutableCopy;
@ -12,7 +12,7 @@
return info; return info;
} }
%end %end
*/ %end
// Workaround for MiRO92/uYou-for-YouTube#12, qnblackcat/uYouPlus#263 // Workaround for MiRO92/uYou-for-YouTube#12, qnblackcat/uYouPlus#263
%hook YTDataUtils %hook YTDataUtils
@ -98,6 +98,7 @@ typedef NS_ENUM(NSInteger, ShareEntityType) {
ShareEntityFieldVideo = 1, ShareEntityFieldVideo = 1,
ShareEntityFieldPlaylist = 2, ShareEntityFieldPlaylist = 2,
ShareEntityFieldChannel = 3, ShareEntityFieldChannel = 3,
ShareEntityFieldPost = 6,
ShareEntityFieldClip = 8 ShareEntityFieldClip = 8
}; };
@ -110,6 +111,7 @@ static inline NSString* extractIdWithFormat(GPBUnknownFieldSet *fields, NSIntege
NSString *id = [[NSString alloc] initWithData:[idField.lengthDelimitedList firstObject] encoding:NSUTF8StringEncoding]; NSString *id = [[NSString alloc] initWithData:[idField.lengthDelimitedList firstObject] encoding:NSUTF8StringEncoding];
return [NSString stringWithFormat:format, id]; return [NSString stringWithFormat:format, id];
} }
static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *sourceView) { static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *sourceView) {
GPBMessage *shareEntity = [%c(GPBMessage) deserializeFromString:serializedShareEntity]; GPBMessage *shareEntity = [%c(GPBMessage) deserializeFromString:serializedShareEntity];
GPBUnknownFieldSet *fields = shareEntity.unknownFields; GPBUnknownFieldSet *fields = shareEntity.unknownFields;
@ -138,6 +140,9 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source
if (!shareUrl) if (!shareUrl)
shareUrl = extractIdWithFormat(fields, ShareEntityFieldVideo, @"https://youtube.com/watch?v=%@"); shareUrl = extractIdWithFormat(fields, ShareEntityFieldVideo, @"https://youtube.com/watch?v=%@");
if (!shareUrl)
shareUrl = extractIdWithFormat(fields, ShareEntityFieldPost, @"https://youtube.com/post/%@");
if (!shareUrl) if (!shareUrl)
return NO; return NO;
@ -171,6 +176,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *source
} }
%end %end
/* ------------------- iPhone Layout ------------------- */ /* ------------------- iPhone Layout ------------------- */
%hook ELMPBShowActionSheetCommand %hook ELMPBShowActionSheetCommand
@ -331,6 +337,9 @@ static void refreshUYouAppearance() {
%ctor { %ctor {
%init; %init;
if (IS_ENABLED(@"googleSignInPatch_enabled")) {
%init(gGoogleSignInPatch);
}
// if (@available(iOS 16, *)) { // if (@available(iOS 16, *)) {
// %init(iOS16); // %init(iOS16);
// } // }

View file

@ -1340,6 +1340,7 @@ extern NSBundle *uYouPlusBundle();
# pragma mark - Miscellaneous # pragma mark - Miscellaneous
SECTION_HEADER(LOC(@"MISCELLANEOUS")); SECTION_HEADER(LOC(@"MISCELLANEOUS"));
SWITCH_ITEM2(LOC(@"YouTube Sign-In Patch"), LOC(@"When enabled, it will allow you to sign in on the YouTube App when sideloaded.\nUnwanted Side Effects: Most Icons in the app will be Invisible & Notifications might not work."), @"googleSignInPatch_enabled");
SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND_LITE"), LOC(@"ADBLOCK_WORKAROUND_LITE_DESC"), @"uYouAdBlockingWorkaroundLite_enabled"); SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND_LITE"), LOC(@"ADBLOCK_WORKAROUND_LITE_DESC"), @"uYouAdBlockingWorkaroundLite_enabled");
SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND"), LOC(@"ADBLOCK_WORKAROUND_DESC"), @"uYouAdBlockingWorkaround_enabled"); SWITCH_ITEM2(LOC(@"ADBLOCK_WORKAROUND"), LOC(@"ADBLOCK_WORKAROUND_DESC"), @"uYouAdBlockingWorkaround_enabled");
SWITCH_ITEM3( SWITCH_ITEM3(