diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index 1f803dc..8c0b577 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -87,7 +87,7 @@ static NSString *accessGroupID() { %end %end -// YouTube Premium Logo - @arichorn - this doesn't always function +// YouTube Premium Logo - @arichornlover - this doesn't always function. %group gPremiumYouTubeLogo %hook YTHeaderLogoController - (void)setPremiumLogo:(BOOL)isPremiumLogo { @@ -101,6 +101,37 @@ static NSString *accessGroupID() { } %end +// Workaround: uYou 3.0.3 Adblock fix. +%hook YTSectionListViewController +- (void)loadWithModel:(YTISectionListRenderer *)model { + if ([@"removeYouTubeAds" boolValue]) { + NSMutableArray *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; +} +%end + +%hook YTWatchNextResultsViewController +- (void)loadWithModel:(YTISectionListRenderer *)watchNextResults { + if ([@"removeYouTubeAds" boolValue]) { + NSMutableArray *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 + // Workaround: fix YouTube Premium Logo not working on v18.35.4 or above. %hook YTVersionUtils // Working Version for Premium Logo + (NSString *)appVersion { return @"18.34.5"; }