Feature: Fake Premium in You tab

This commit is contained in:
Bryce Hackel 2024-04-07 14:11:53 -05:00
parent ae75588dcc
commit 12c6c4fb5a
No known key found for this signature in database
GPG key ID: F031960F08455E88

View file

@ -214,7 +214,6 @@ BOOL isAd(YTIElementRenderer *self) {
// YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards // YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards
%hook YTCreatorEndscreenView %hook YTCreatorEndscreenView
- (void)setHidden:(BOOL)hidden { - (void)setHidden:(BOOL)hidden {
NSLog(@"bhackel debug: setHidden method called");
if (IS_ENABLED(@"hideHoverCards_enabled")) if (IS_ENABLED(@"hideHoverCards_enabled"))
hidden = YES; hidden = YES;
%orig; %orig;
@ -275,127 +274,107 @@ BOOL isAd(YTIElementRenderer *self) {
- (BOOL)savedSettingShouldExpire { return NO; } - (BOOL)savedSettingShouldExpire { return NO; }
%end %end
// Hide Premium promos in "You" tab - @bhackel // Hide "Get Youtube Premium" in "You" tab - @bhackel
%group gHidePremiumPromos %group gHidePremiumPromos
// Hide "Get Youtube Premium" in the "You" tab %hook YTAppCollectionViewController
%hook YTAppCollectionViewController - (void)loadWithModel:(YTISectionListRenderer *)model {
- (void)loadWithModel:(YTISectionListRenderer *)model { NSMutableArray <YTISectionListSupportedRenderers *> *overallContentsArray = model.contentsArray;
NSLog(@"bhackel debug: loadWithModel method called"); // Check each item in the overall array - this represents the whole You page
NSMutableArray <YTISectionListSupportedRenderers *> *overallContentsArray = model.contentsArray; YTISectionListSupportedRenderers *supportedRenderers;
// Check each item in the overall array - this represents the whole You page for (supportedRenderers in overallContentsArray) {
YTISectionListSupportedRenderers *supportedRenderers; YTIItemSectionRenderer *itemSectionRenderer = supportedRenderers.itemSectionRenderer;
for (supportedRenderers in overallContentsArray) { // Check each subobject - this would be visible as a cell in the You page
NSLog(@"bhackel debug: in 1st loop"); NSMutableArray <YTIItemSectionSupportedRenderers *> *subContentsArray = itemSectionRenderer.contentsArray;
YTIItemSectionRenderer *itemSectionRenderer = supportedRenderers.itemSectionRenderer; bool found = NO;
// Check each subobject - this would be visible as a cell in the You page YTIItemSectionSupportedRenderers *itemSectionSupportedRenderers;
NSMutableArray <YTIItemSectionSupportedRenderers *> *subContentsArray = itemSectionRenderer.contentsArray; for (itemSectionSupportedRenderers in subContentsArray) {
bool found = NO; // Check for a link cell
YTIItemSectionSupportedRenderers *itemSectionSupportedRenderers; if ([itemSectionSupportedRenderers hasCompactLinkRenderer]) {
for (itemSectionSupportedRenderers in subContentsArray) { YTICompactLinkRenderer *compactLinkRenderer = [itemSectionSupportedRenderers compactLinkRenderer];
NSLog(@"bhackel debug: in 2nd loop"); // Check for an icon in this cell
// Check for a link cell if ([compactLinkRenderer hasIcon]) {
if ([itemSectionSupportedRenderers hasCompactLinkRenderer]) { YTIIcon *icon = [compactLinkRenderer icon];
NSLog(@"bhackel debug: hasCompactLinkRenderer"); // Check if the icon is for the premium promo
YTICompactLinkRenderer *compactLinkRenderer = [itemSectionSupportedRenderers compactLinkRenderer]; if ([icon hasIconType] && icon.iconType == 117) {
// Check for an icon in this cell found = YES;
if ([compactLinkRenderer hasIcon]) { break;
NSLog(@"bhackel debug: hasIcon");
YTIIcon *icon = [compactLinkRenderer icon];
// Check if the icon is for the premium promo
if ([icon hasIconType] && icon.iconType == 117) {
NSLog(@"bhackel debug: iconType == 117, found... :D");
found = YES;
break;
}
} }
} }
} }
// Remove object from array - perform outside of loop to avoid error
if (found) {
NSLog(@"bhackel debug: removing...");
[subContentsArray removeObject:itemSectionSupportedRenderers];
break;
}
} }
%orig; // Remove object from array - perform outside of loop to avoid error
if (found) {
[subContentsArray removeObject:itemSectionSupportedRenderers];
break;
}
} }
%end %orig;
}
%end
%end %end
// Fake premium in the You tab - @bhackel // Fake premium in the You tab - @bhackel
%group gYouTabFakePremium %group gYouTabFakePremium
%hook YTAppCollectionViewController %hook YTAppCollectionViewController
- (void)loadWithModel:(YTISectionListRenderer *)model { - (void)loadWithModel:(YTISectionListRenderer *)model {
NSLog(@"bhackel debug: loadWithModel method called"); NSUInteger yourVideosIndex = -1;
NSUInteger yourVideosIndex = -1; NSMutableArray <YTISectionListSupportedRenderers *> *overallContentsArray = model.contentsArray;
NSMutableArray <YTISectionListSupportedRenderers *> *overallContentsArray = model.contentsArray; // Check each item in the overall array - this represents the whole You page
// Check each item in the overall array - this represents the whole You page YTISectionListSupportedRenderers *supportedRenderers;
YTISectionListSupportedRenderers *supportedRenderers; for (supportedRenderers in overallContentsArray) {
for (supportedRenderers in overallContentsArray) { YTIItemSectionRenderer *itemSectionRenderer = supportedRenderers.itemSectionRenderer;
NSLog(@"bhackel debug: in 1st loop"); // Check each subobject - this would be visible as a cell in the You page
YTIItemSectionRenderer *itemSectionRenderer = supportedRenderers.itemSectionRenderer; NSMutableArray <YTIItemSectionSupportedRenderers *> *subContentsArray = itemSectionRenderer.contentsArray;
// Check each subobject - this would be visible as a cell in the You page YTIItemSectionSupportedRenderers *itemSectionSupportedRenderers;
NSMutableArray <YTIItemSectionSupportedRenderers *> *subContentsArray = itemSectionRenderer.contentsArray; for (itemSectionSupportedRenderers in subContentsArray) {
YTIItemSectionSupportedRenderers *itemSectionSupportedRenderers; // Check for a specific type of cell of type CompactLinkRenderer
for (itemSectionSupportedRenderers in subContentsArray) { if ([itemSectionSupportedRenderers hasCompactLinkRenderer]) {
NSLog(@"bhackel debug: in 2nd loop"); YTICompactLinkRenderer *compactLinkRenderer = [itemSectionSupportedRenderers compactLinkRenderer];
// Check for a specific type of cell of type CompactLinkRenderer // Check for an icon in this cell
if ([itemSectionSupportedRenderers hasCompactLinkRenderer]) { if ([compactLinkRenderer hasIcon]) {
NSLog(@"bhackel debug: hasCompactLinkRenderer"); YTIIcon *icon = [compactLinkRenderer icon];
YTICompactLinkRenderer *compactLinkRenderer = [itemSectionSupportedRenderers compactLinkRenderer]; // Check if the icon is for the premium promo
// Check for an icon in this cell if ([icon hasIconType] && icon.iconType == 117) {
if ([compactLinkRenderer hasIcon]) { // Modify the icon type to be Premium
NSLog(@"bhackel debug: hasIcon"); icon.iconType = 741;
YTIIcon *icon = [compactLinkRenderer icon]; // Modify the text
// Check if the icon is for the premium promo ((YTIStringRun *)(compactLinkRenderer.title.runsArray.firstObject)).text = @"Your Premium benefits";
if ([icon hasIconType] && icon.iconType == 117) {
NSLog(@"bhackel debug: iconType == 117, found... :D");
// Modify the icon type to be Premium
icon.iconType = 741;
// Modify the text
((YTIStringRun *)(compactLinkRenderer.title.runsArray.firstObject)).text = @"Your Premium benefits";
}
} }
} }
// Check for a specific type of cell of type CompactListItemRenderer }
if ([itemSectionSupportedRenderers hasCompactListItemRenderer]) { // Check for a specific type of cell of type CompactListItemRenderer
NSLog(@"bhackel debug: 2 hasCompactListItemRenderer"); if ([itemSectionSupportedRenderers hasCompactListItemRenderer]) {
YTICompactListItemRenderer *compactListItemRenderer = itemSectionSupportedRenderers.compactListItemRenderer; YTICompactListItemRenderer *compactListItemRenderer = itemSectionSupportedRenderers.compactListItemRenderer;
if ([compactListItemRenderer hasThumbnail]) { if ([compactListItemRenderer hasThumbnail]) {
NSLog(@"bhackel debug: 2 hasThumbnail"); YTICompactListItemThumbnailSupportedRenderers *thumbnail = compactListItemRenderer.thumbnail;
YTICompactListItemThumbnailSupportedRenderers *thumbnail = compactListItemRenderer.thumbnail; if ([thumbnail hasIconThumbnailRenderer]) {
if ([thumbnail hasIconThumbnailRenderer]) { YTIIconThumbnailRenderer *iconThumbnailRenderer = thumbnail.iconThumbnailRenderer;
NSLog(@"bhackel debug: 2 hasIconThumbnailRenderer"); if ([iconThumbnailRenderer hasIcon]) {
YTIIconThumbnailRenderer *iconThumbnailRenderer = thumbnail.iconThumbnailRenderer; YTIIcon *icon = iconThumbnailRenderer.icon;
if ([iconThumbnailRenderer hasIcon]) { if ([icon hasIconType] && icon.iconType == 658) {
NSLog(@"bhackel debug: 2 hasIcon"); // Note the index of this cell in the array
YTIIcon *icon = iconThumbnailRenderer.icon; yourVideosIndex = [subContentsArray indexOfObject:itemSectionSupportedRenderers];
if ([icon hasIconType] && icon.iconType == 658) {
NSLog(@"bhackel debug: 2 iconType == 658, found... :D");
// Note the index of this cell in the array
yourVideosIndex = [subContentsArray indexOfObject:itemSectionSupportedRenderers];
}
} }
} }
} }
} }
} }
if (yourVideosIndex != -1) {
NSLog(@"bhackel debug: yourVideosIndex != -1");
// Create a new cell with the same properties as the original cell
YTIItemSectionSupportedRenderers *newItemSectionSupportedRenderers = [subContentsArray[yourVideosIndex] copy];
// Modify the text
((YTIStringRun *)(newItemSectionSupportedRenderers.compactListItemRenderer.title.runsArray.firstObject)).text = @"Downloads";
// Modify the icon
newItemSectionSupportedRenderers.compactListItemRenderer.thumbnail.iconThumbnailRenderer.icon.iconType = 147;
// Insert the new cell at the index of the original cell
[subContentsArray insertObject:newItemSectionSupportedRenderers atIndex:yourVideosIndex + 1];
yourVideosIndex = -1;
}
} }
%orig; if (yourVideosIndex != -1) {
// Create a new cell with the same properties as the original cell
YTIItemSectionSupportedRenderers *newItemSectionSupportedRenderers = [subContentsArray[yourVideosIndex] copy];
// Modify the text
((YTIStringRun *)(newItemSectionSupportedRenderers.compactListItemRenderer.title.runsArray.firstObject)).text = @"Downloads";
// Modify the icon
newItemSectionSupportedRenderers.compactListItemRenderer.thumbnail.iconThumbnailRenderer.icon.iconType = 147;
// Insert the new cell at the index of the original cell
[subContentsArray insertObject:newItemSectionSupportedRenderers atIndex:yourVideosIndex + 1];
yourVideosIndex = -1;
}
} }
%end %orig;
}
%end
%end %end