From 52ac2585bdb54be09aa2aaebf6a7c59863c303ab Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Fri, 28 Apr 2023 00:32:33 +0700 Subject: [PATCH] for #1080 --- uYouPlus.xm | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/uYouPlus.xm b/uYouPlus.xm index 5e0c78f..67c2b79 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -32,14 +32,14 @@ static BOOL oldDarkTheme() { // # pragma mark - uYou's patches // Workaround for qnblackcat/uYouPlus#10 -// %hook boolSettingsVC -// - (instancetype)initWithTitle:(NSString *)title sections:(NSArray *)sections footer:(NSString *)footer { -// if (@available(iOS 15, *)) -// if (![self valueForKey:@"_lastNotifiedTraitCollection"]) -// [self setValue:[UITraitCollection currentTraitCollection] forKey:@"_lastNotifiedTraitCollection"]; -// return %orig; -// } -// %end +%hook boolSettingsVC +- (instancetype)initWithTitle:(NSString *)title sections:(NSArray *)sections footer:(NSString *)footer { + if (@available(iOS 15, *)) + if (![self valueForKey:@"_lastNotifiedTraitCollection"]) + [self setValue:[UITraitCollection currentTraitCollection] forKey:@"_lastNotifiedTraitCollection"]; + return %orig; +} +%end // Prevent uYou player bar from showing when not playing downloaded media %hook PlayerManager @@ -248,18 +248,27 @@ static BOOL didFinishLaunching; } %end -%hook YTSectionListViewController -- (void)loadWithModel:(YTISectionListRenderer *)model { - 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; - }]; - [contentsArray removeObjectsAtIndexes:removeIndexes]; - %orig; -} -%end +// Hide search ads by @PoomSmart - https://github.com/PoomSmart/YouTube-X +// %hook YTIElementRenderer +// - (NSData *)elementData { +// if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) +// return nil; +// return %orig; +// } +// %end + +// %hook YTSectionListViewController +// - (void)loadWithModel:(YTISectionListRenderer *)model { +// 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; +// }]; +// [contentsArray removeObjectsAtIndexes:removeIndexes]; +// %orig; +// } +// %end // YTClassicVideoQuality: https://github.com/PoomSmart/YTClassicVideoQuality %hook YTVideoQualitySwitchControllerFactory