Skip to content

Commit

Permalink
YouTube Reborn v4.2.6
Browse files Browse the repository at this point in the history
Includes stuff from v5.0.0 beta! #40 & #36
  • Loading branch information
arichornlover authored Mar 13, 2024
1 parent e9ce85a commit 177c797
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 47 deletions.
2 changes: 2 additions & 0 deletions Tweak.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import "YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
#import "YouTubeHeader/YTVideoWithContextNode.h"
#import "YouTubeHeader/YTIElementRenderer.h"
#import "YouTubeHeader/YTISectionListRenderer.h"
#import "YouTubeHeader/YTWatchNextResultsViewController.h"
#import "YouTubeHeader/ELMCellNode.h"
#import "YouTubeHeader/ELMNodeController.h"
#import "YouTubeHeader/YTIMenuConditionalServiceItemRenderer.h"
Expand Down
89 changes: 47 additions & 42 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -787,67 +787,72 @@ static NSString *accessGroupID() {
%hook YTHotConfig
- (BOOL)disableAfmaIdfaCollection { return NO; }
%end

%hook YTIPlayerResponse
- (BOOL)isMonetized {
return NO;
}
- (BOOL)isMonetized { return NO; }
%end

%hook YTDataUtils
+ (id)spamSignalsDictionary { return nil; }
+ (id)spamSignalsDictionaryWithoutIDFA { return nil; }
%end

%hook YTAdsInnerTubeContextDecorator
- (void)decorateContext:(id)arg1 {
}
- (void)decorateContext:(id)context {}
%end

%hook YTAccountScopedAdsInnerTubeContextDecorator
- (void)decorateContext:(id)context {}
%end

%hook YTIElementRenderer
- (NSData *)elementData {
if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) return nil;
return %orig;
}
%end

BOOL isAd(id node) {
if ([node isKindOfClass:NSClassFromString(@"YTVideoWithContextNode")]
&& [node respondsToSelector:@selector(parentResponder)]
&& [[(YTVideoWithContextNode *)node parentResponder] isKindOfClass:NSClassFromString(@"YTAdVideoElementsCellController")])
BOOL isAd(YTIElementRenderer *self) {
if (self != nil) {
NSString *description = [self description];
if ([description containsString:@"brand_promo"]
|| [description containsString:@"statement_banner"]
|| [description containsString:@"product_carousel"]
|| [description containsString:@"product_engagement_panel"]
|| [description containsString:@"product_item"]
|| [description containsString:@"expandable_list"]
|| [description containsString:@"text_search_ad"]
|| [description containsString:@"text_image_button_layout"]
|| [description containsString:@"carousel_headered_layout"]
|| [description containsString:@"carousel_footered_layout"]
|| [description containsString:@"square_image_layout"]
|| [description containsString:@"landscape_image_wide_button_layout"]
|| [description containsString:@"feed_ad_metadata"])
return YES;
if ([node isKindOfClass:NSClassFromString(@"ELMCellNode")]) {
NSString *description = [[[node controller] owningComponent] description];
if ([description containsString:@"brand_promo"]
|| [description containsString:@"statement_banner"]
|| [description containsString:@"product_carousel"]
|| [description containsString:@"product_engagement_panel"]
|| [description containsString:@"product_item"]
|| [description containsString:@"text_search_ad"]
|| [description containsString:@"text_image_button_layout"]
|| [description containsString:@"carousel_headered_layout"]
|| [description containsString:@"carousel_footered_layout"]
|| [description containsString:@"square_image_layout"] // install app ad
|| [description containsString:@"landscape_image_wide_button_layout"]
|| [description containsString:@"feed_ad_metadata"])
return YES;
}
return NO;
}return NO;
}
%hook YTSectionListViewController
- (void)loadWithModel:(YTISectionListRenderer *)model {
NSMutableArray <YTISectionListSupportedRenderers *> *contentsArray = model.contentsArray;
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer || isAd(firstObject.elementRenderer);
}];
[contentsArray removeObjectsAtIndexes:removeIndexes];
%orig;
}

%hook YTAsyncCollectionView
- (id)collectionView:(id)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
_ASCollectionViewCell *cell = %orig;
if ([cell isKindOfClass:NSClassFromString(@"YTCompactPromotedVideoCell")]
|| ([cell isKindOfClass:NSClassFromString(@"_ASCollectionViewCell")]
&& [cell respondsToSelector:@selector(node)]
&& isAd([cell node])))
[self deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
return cell;
%end
%hook YTWatchNextResultsViewController
- (void)loadWithModel:(YTISectionListRenderer *)watchNextResults {
NSMutableArray <YTISectionListSupportedRenderers *> *contentsArray = watchNextResults.contentsArray;
NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
YTIItemSectionRenderer *sectionRenderer = renderers.itemSectionRenderer;
YTIItemSectionSupportedRenderers *firstObject = [sectionRenderer.contentsArray firstObject];
return firstObject.hasPromotedVideoRenderer || firstObject.hasCompactPromotedVideoRenderer || firstObject.hasPromotedVideoInlineMutedRenderer || isAd(firstObject.elementRenderer);
}];
[contentsArray removeObjectsAtIndexes:removeIndexes];
%orig;
}
%end
%hook _ASDisplayView
- (void)didMoveToWindow {
%orig();
if ([self.accessibilityIdentifier isEqualToString:@"id.products_in_video_with_preview_overlay_badge.view"]) self.hidden = YES;
}
%end
%end
Expand Down
8 changes: 4 additions & 4 deletions YouTubeExtractor/YouTubeExtractor.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ + (NSDictionary *)youtubePlayerRequest :(NSString *)client :(NSString *)videoID
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
if ([client isEqual:@"android"]) {
[request setValue:@"com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip" forHTTPHeaderField:@"User-Agent"];
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"ANDROID\",\"clientVersion\":\"17.31.35\",\"androidSdkVersion\":30}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
[request setValue:@"com.google.android.youtube/19.05.36 (Linux; U; Android 11) gzip" forHTTPHeaderField:@"User-Agent"];
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"ANDROID\",\"clientVersion\":\"19.05.36\",\"androidSdkVersion\":30,\"playbackContext\":{\"contentPlaybackContext\":{\"vis\":0,\"splay\":false,\"autoCaptionsDefaultOn\":false,\"autonavState\":\"STATE_OFF\",\"signatureTimestamp\":\"sts\",\"html5Preference\":\"HTML5_PREF_WANTS\",\"lactMilliseconds\":\"-1\"}}}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
[request setHTTPBody:[jsonBody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
} else if ([client isEqual:@"ios"]) {
[request setValue:@"com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)" forHTTPHeaderField:@"User-Agent"];
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"IOS\",\"clientVersion\":\"17.33.2\",\"deviceModel\":\"iPhone14,3\"}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
[request setValue:@"com.google.ios.youtube/19.06.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)" forHTTPHeaderField:@"User-Agent"];
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"IOS\",\"clientVersion\":\"19.06.2\",\"deviceModel\":\"iPhone14,3\",\"playbackContext\":{\"contentPlaybackContext\":{\"vis\":0,\"splay\":false,\"autoCaptionsDefaultOn\":false,\"autonavState\":\"STATE_OFF\",\"signatureTimestamp\":\"sts\",\"html5Preference\":\"HTML5_PREF_WANTS\",\"lactMilliseconds\":\"-1\"}}}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
[request setHTTPBody:[jsonBody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
}

Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: h.ryan.youtubereborn
Name: YouTube Reborn
Version: 4.2.4
Version: 4.2.6
Architecture: iphoneos-arm
Description: YouTube Customizer
Maintainer: Lillie
Expand Down

0 comments on commit 177c797

Please sign in to comment.