Add link to uYou page

This commit is contained in:
Bryce Hackel 2024-04-14 16:20:50 -07:00
parent 4fb761fc6f
commit 7c39d6659d
No known key found for this signature in database
GPG key ID: F031960F08455E88
3 changed files with 70 additions and 21 deletions

View file

@ -33,6 +33,7 @@
#import <YouTubeHeader/YTIFormattedString.h>
#import <YouTubeHeader/GPBMessage.h>
#import <YouTubeHeader/YTIStringRun.h>
#import <YouTubeHeader/YTCellController.h>
// Hide buttons under the video player by @PoomSmart
#import <YouTubeHeader/ASCollectionElement.h>
@ -72,40 +73,49 @@
// Hide Premium Promo in You tab - @bhackel
@interface YTIIconThumbnailRenderer : GPBMessage
@property (nonatomic, strong) YTIIcon *icon;
- (bool)hasIcon;
@property (nonatomic, strong) YTIIcon *icon;
- (bool)hasIcon;
@end
@interface YTICompactListItemThumbnailSupportedRenderers : GPBMessage
@property (nonatomic, strong) YTIIconThumbnailRenderer *iconThumbnailRenderer;
- (bool)hasIconThumbnailRenderer;
@property (nonatomic, strong) YTIIconThumbnailRenderer *iconThumbnailRenderer;
- (bool)hasIconThumbnailRenderer;
@end
@interface YTICompactListItemRenderer : GPBMessage
@property (nonatomic, strong) YTICompactListItemThumbnailSupportedRenderers *thumbnail;
@property (nonatomic, strong) YTIFormattedString *title;
- (bool)hasThumbnail;
- (bool)hasTitle;
@property (nonatomic, strong) YTICompactListItemThumbnailSupportedRenderers *thumbnail;
@property (nonatomic, strong) YTIFormattedString *title;
- (bool)hasThumbnail;
- (bool)hasTitle;
@end
@interface YTIIcon (uYouEnhanced)
- (bool)hasIconType;
- (bool)hasIconType;
@end
@interface YTICompactLinkRenderer : GPBMessage
@property (nonatomic, strong) YTIIcon *icon;
@property (nonatomic, strong) YTIFormattedString *title;
@property (nonatomic, strong) YTICompactListItemThumbnailSupportedRenderers *thumbnail;
- (bool)hasIcon;
- (bool)hasThumbnail;
@property (nonatomic, strong) YTIIcon *icon;
@property (nonatomic, strong) YTIFormattedString *title;
@property (nonatomic, strong) YTICompactListItemThumbnailSupportedRenderers *thumbnail;
- (bool)hasIcon;
- (bool)hasThumbnail;
@end
@interface YTIItemSectionSupportedRenderers (uYouEnhanced)
@property(readonly, nonatomic) YTICompactLinkRenderer *compactLinkRenderer;
@property(readonly, nonatomic) YTICompactListItemRenderer *compactListItemRenderer;
- (bool)hasCompactLinkRenderer;
- (bool)hasCompactListItemRenderer;
@property(readonly, nonatomic) YTICompactLinkRenderer *compactLinkRenderer;
@property(readonly, nonatomic) YTICompactListItemRenderer *compactListItemRenderer;
- (bool)hasCompactLinkRenderer;
- (bool)hasCompactListItemRenderer;
@end
@interface YTAppCollectionViewController : YTInnerTubeCollectionViewController
- (void)uYouEnhancedFakePremiumModel:(YTISectionListRenderer *)model;
@end
@interface YTInnerTubeCollectionViewController (uYouEnhanced)
@property(readonly, nonatomic) YTISectionListRenderer *model;
@property(readonly, nonatomic) YTISectionListRenderer *model;
@end
@interface YTLinkCell : UICollectionViewCell
@end
@interface YTCompactListItemCellController : YTCellController
@property(nonatomic, weak, readwrite) id entry;
@end
@interface GLViewPagerViewController : UIViewController
@end
@interface DownloadsPagerVC : GLViewPagerViewController
@end
// uYouPlus

View file

@ -359,7 +359,6 @@ BOOL isAd(YTIElementRenderer *self) {
if (yourVideosCellIndex != -1 && subContentsArray[yourVideosCellIndex].accessibilityLabel == nil) {
// Create the fake Downloads page by copying the Your Videos page and modifying it
// Note that this must be done outside the loop to avoid a runtime exception
// TODO Link this to the uYou downloads page
YTIItemSectionSupportedRenderers *newItemSectionSupportedRenderers = [subContentsArray[yourVideosCellIndex] copy];
((YTIStringRun *)(newItemSectionSupportedRenderers.compactListItemRenderer.title.runsArray.firstObject)).text = LOC(@"FAKE_DOWNLOADS");
newItemSectionSupportedRenderers.compactListItemRenderer.thumbnail.iconThumbnailRenderer.icon.iconType = 147;
@ -368,6 +367,8 @@ BOOL isAd(YTIElementRenderer *self) {
// Inject a note to not modify this again
subContentsArray[yourVideosCellIndex].accessibilityLabel = @"uYouEnhanced Modified";
yourVideosCellIndex = -1;
// Insert accessibility info into the YTLinkCell so that it can be hooked later
newItemSectionSupportedRenderers.compactListItemRenderer.title.accessibility.accessibilityData.label = @"uYouEnhanced Fake Downloads";
}
}
}
@ -382,6 +383,44 @@ BOOL isAd(YTIElementRenderer *self) {
%orig;
}
%end
// Change the destination of the fake Downloads cell
%hook YTCompactListItemCellController
- (void)didSelectItem {
NSLog(@"bhackel: _handleMenuGesture");
id entry = self.entry;
// Avoid modifying the wrong things
if (![entry isKindOfClass:NSClassFromString(@"YTICompactListItemRenderer")]) {
%orig;
return;
}
YTICompactListItemRenderer *compactListItemRenderer = (YTICompactListItemRenderer *)entry;
// Check title for accessibility label that was stored
if ([compactListItemRenderer.title.accessibility.accessibilityData.label isEqualToString:@"uYouEnhanced Fake Downloads"]) {
NSLog(@"bhackel: uYouEnhanced Fake Downloads");
// Chatgpt generated code to show DownloadsPagerVC, which is the uYou page
// Instantiate your custom DownloadsPagerVC
// Avoid linker stuff
Class downloadsPagerVCClass = objc_getClass("DownloadsPagerVC");
if (downloadsPagerVCClass) {
id downloadsPagerVCid = [[downloadsPagerVCClass alloc] init];
// Now you can use `downloadsPagerVC` as needed
}
DownloadsPagerVC *downloadsPagerVC = (DownloadsPagerVC *)downloadsPagerVCid;
// Assuming you need navigation controller to push
UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
UINavigationController *navigationController = (UINavigationController *)rootViewController;
if ([navigationController isKindOfClass:[UINavigationController class]]) {
[navigationController pushViewController:downloadsPagerVC animated:YES];
} else {
// If not in a navigation controller context, present modally
[rootViewController presentViewController:downloadsPagerVC animated:YES completion:nil];
}
} else {
NSLog(@"bhackel: Not uYouEnhanced Fake Downloads");
%orig;
}
}
%end
%end

View file

@ -32,7 +32,7 @@
// @end
// Fix uYou's appearance not updating if the app is backgrounded
@interface DownloadsPagerVC : UIViewController
@interface DownloadsPagerVC (uYouEnhancedPatches)
- (NSArray<UIViewController *> *)viewControllers;
- (void)updatePageStyles;
@end