mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-03-11 21:26:04 +00:00
uYou Adblock Fix - #457
The stuff was from YouTube Reborn v4.2.6 but modified it for uYouEnhanced.
This commit is contained in:
parent
f3e096d9b3
commit
da03edf564
1 changed files with 32 additions and 1 deletions
|
|
@ -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 <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;
|
||||
}
|
||||
%end
|
||||
|
||||
%hook YTWatchNextResultsViewController
|
||||
- (void)loadWithModel:(YTISectionListRenderer *)watchNextResults {
|
||||
if ([@"removeYouTubeAds" boolValue]) {
|
||||
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
|
||||
|
||||
// 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"; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue