diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index 60e60a1..887e1b2 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -120,32 +120,33 @@ static int contrastMode() { %end %end -// uYou AdBlock Workaround (for uYou Option) - @PoomSmart +// uYou AdBlock Workaround (Note: disables uYou's "Remove YouTube Ads" Option) - @PoomSmart, @arichornlover & @Dodieboy %group uYouAdBlockingWorkaround -// Workaround: uYou 3.0.3 Adblock fix - @PoomSmart +// Workaround: uYou 3.0.3 Adblock fix +%hook YTHotConfig +- (BOOL)disableAfmaIdfaCollection { return NO; } +%end +%hook YTIPlayerResponse +- (BOOL)isMonetized { return NO; } +%end +%hook YTDataUtils ++ (id)spamSignalsDictionary { return @{}; } ++ (id)spamSignalsDictionaryWithoutIDFA { return @{}; } +%end +%hook YTAdsInnerTubeContextDecorator +- (void)decorateContext:(id)context { %orig(nil); } +%end +%hook YTAccountScopedAdsInnerTubeContextDecorator +- (void)decorateContext:(id)context { %orig(nil); } +%end %hook YTReelInfinitePlaybackDataSource - (void)setReels:(NSMutableOrderedSet *)reels { - if ([NSUserDefaults.standardUserDefaults boolForKey:@"removeYouTubeAds"]) { - [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { - return [obj respondsToSelector:@selector(videoType)] ? obj.videoType == 3 : NO; - }]]; - } + [reels removeObjectsAtIndexes:[reels indexesOfObjectsPassingTest:^BOOL(YTReelModel *obj, NSUInteger idx, BOOL *stop) { + return [obj respondsToSelector:@selector(videoType)] ? obj.videoType == 3 : NO; + }]]; %orig; } %end - -%hook YTAdsInnerTubeContextDecorator -- (void)decorateContext:(id)context { - if ([NSUserDefaults.standardUserDefaults boolForKey:@"removeYouTubeAds"]) {} -} -%end - -%hook YTAccountScopedAdsInnerTubeContextDecorator -- (void)decorateContext:(id)context { - if ([NSUserDefaults.standardUserDefaults boolForKey:@"removeYouTubeAds"]) {} -} -%end - BOOL isAdString(NSString *description) { if ([description containsString:@"brand_promo"] || [description containsString:@"carousel_footered_layout"] @@ -155,19 +156,18 @@ BOOL isAdString(NSString *description) { || [description containsString:@"full_width_square_image_layout"] || [description containsString:@"home_video_with_context"] || [description containsString:@"landscape_image_wide_button_layout"] - // || [description containsString:@"product_carousel"] || [description containsString:@"product_engagement_panel"] || [description containsString:@"product_item"] || [description containsString:@"shelf_header"] - // || [description containsString:@"statement_banner"] - || [description containsString:@"square_image_layout"] // install app ad + || [description containsString:@"square_image_layout"] || [description containsString:@"text_image_button_layout"] || [description containsString:@"text_search_ad"] + || [description containsString:@"expandable_list"] + || [description containsString:@"expandable_metadata"] || [description containsString:@"video_display_full_buttoned_layout"]) return YES; return NO; } - %hook YTIElementRenderer - (NSData *)elementData { NSString *description = [self description]; @@ -176,34 +176,54 @@ BOOL isAdString(NSString *description) { return cellDividerData; } if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) return cellDividerData; - // if (isAdString(description)) return cellDividerData; return %orig; } %end - %hook YTInnerTubeCollectionViewController - (void)loadWithModel:(YTISectionListRenderer *)model { - if ([NSUserDefaults.standardUserDefaults boolForKey:@"removeYouTubeAds"]) { - if ([model isKindOfClass:%c(YTISectionListRenderer)]) { - NSMutableArray *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; - NSString *description = [elementRenderer description]; - return isAdString(description) - || [description containsString:@"post_shelf"] - || [description containsString:@"product_carousel"] - || [description containsString:@"statement_banner"]; - }]; - [contentsArray removeObjectsAtIndexes:removeIndexes]; - } + if ([model isKindOfClass:%c(YTISectionListRenderer)]) { + NSMutableArray *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; + NSString *description = [elementRenderer description]; + return isAdString(description) + || [description containsString:@"post_shelf"] + || [description containsString:@"product_carousel"] + || [description containsString:@"statement_banner"]; + }]; + [contentsArray removeObjectsAtIndexes:removeIndexes]; } %orig; } %end +%hook YTWatchNextResultsViewController +- (void)loadWithModel:(YTISectionListRenderer *)watchNextResults { + if ([watchNextResults isKindOfClass:%c(YTISectionListRenderer)]) { + NSMutableArray *contentsArray = watchNextResults.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; + NSString *description = [elementRenderer description]; + return isAdString(description); + }]; + [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 // Hide YouTube Logo - @dayanch96 @@ -1752,11 +1772,12 @@ static BOOL findCell(ASNodeController *nodeController, NSArray *ide [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"YouPiPEnabled"]; } if (![allKeys containsObject:@"uYouAdBlockingWorkaroundLite_enabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"uYouAdBlockingWorkaroundLite_enabled"]; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"uYouAdBlockingWorkaroundLite_enabled"]; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"]; } if (![allKeys containsObject:@"uYouAdBlockingWorkaround_enabled"]) { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"uYouAdBlockingWorkaround_enabled"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"uYouAdBlockingWorkaround_enabled"]; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"]; } // Broken uYou 3.0.3 setting: No Suggested Videos at The Video End // Set default to allow autoplay, user can disable later