Merge changes from main branch

This commit is contained in:
arichornlover 2024-06-22 17:33:50 -05:00 committed by GitHub
parent 7970ffb29d
commit 09829f0d70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -70,6 +70,11 @@ NSBundle *tweakBundle = uYouPlusBundle();
- (BOOL)isMonetized { return NO; }
%end
%hook YTAdShieldUtils
+ (id)spamSignalsDictionary { return @{}; }
+ (id)spamSignalsDictionaryWithoutIDFA { return @{}; }
%end
%hook YTDataUtils
+ (id)spamSignalsDictionary { return @{}; }
+ (id)spamSignalsDictionaryWithoutIDFA { return @{}; }
@ -102,6 +107,10 @@ NSBundle *tweakBundle = uYouPlusBundle();
%hook YTIPlayerResponse
- (BOOL)isMonetized { return NO; }
%end
%hook YTAdShieldUtils
+ (id)spamSignalsDictionary { return @{}; }
+ (id)spamSignalsDictionaryWithoutIDFA { return @{}; }
%end
%hook YTDataUtils
+ (id)spamSignalsDictionary { return @{}; }
+ (id)spamSignalsDictionaryWithoutIDFA { return @{}; }
@ -129,9 +138,12 @@ 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:@"post_shelf"]
|| [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"]
|| [description containsString:@"text_image_button_layout"]
|| [description containsString:@"text_search_ad"]
@ -142,14 +154,32 @@ BOOL isAdString(NSString *description) {
return YES;
return NO;
}
NSData *cellDividerData;
#define cellDividerDataBytesLength 720
static __strong NSData *cellDividerData;
static uint8_t cellDividerDataBytes[] = {
0xa, 0x8d, 0x5, 0xca, 0xeb, 0xea, 0x83, 0x5, 0x86, 0x5,
0x1a, 0x29, 0x92, 0xcb, 0xa1, 0x90, 0x5, 0x23, 0xa, 0x21,
0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x64, 0x69, 0x76, 0x69, 0x64,
0x65, 0x72, 0x2e, 0x65, 0x6d, 0x6c, 0x7c, 0x39, 0x33, 0x62,
0x65, 0x63, 0x30, 0x39, 0x37, 0x37, 0x63, 0x66, 0x64, 0x33,
0x61, 0x31, 0x37, 0x2a, 0xef, 0x3, 0xea, 0x84, 0xef, 0xab,
0xa, 0xe8, 0x3, 0x8, 0x3, 0x12, 0x0, 0x2d, 0x0, 0x0,
0x0, 0x41, 0x32, 0xdc, 0x3, 0xfa, 0x3e, 0x4, 0x8, 0x5,
0x10, 0x1, 0x92, 0x3f, 0x4, 0xa, 0x2, 0x8, 0x1, 0xc2,
0xb8, 0x89, 0xbe, 0xa, 0x86, 0x1, 0xa, 0x81, 0x1, 0x38,
0x1, 0x40, 0x1, 0x50, 0x1, 0x58, 0x1, 0x60, 0x5, 0x78,
0x1, 0x80, 0x1, 0x1, 0x90, 0x1, 0x1, 0x98, 0x1, 0x1,
0xa0, 0x1, 0x1, 0xa8, 0x1, 0x1, 0xe0, 0x1, 0x1, 0x88,
0x2, 0x1, 0xa0, 0x2, 0x1, 0xd0, 0x2, 0x1, 0x98, 0x3,
0x1, 0xa0, 0x3, 0x1, 0xb0, 0x3, 0x1, 0xd0, 0x3, 0x1,
0xd8, 0x3, 0x1, 0xe8, 0x3, 0x1, 0xf0, 0x3, 0x1, 0x98,
0x4, 0x1, 0xd0, 0x4, 0x1, 0xe8, 0x4, 0x1, 0xf0, 0x4,
0x1, 0xf8, 0x4, 0x1, 0xd8, 0x5, 0x1, 0xe5, 0x5, 0xcd,
0xcc, 0x4c, 0x3f, 0xed, 0x5, 0xcd, 0xcc, 0x4c, 0x3f, 0xf5,
};
%hook YTIElementRenderer
- (NSData *)elementData {
NSString *description = [self description];
if ([description containsString:@"cell_divider"]) {
if (!cellDividerData) cellDividerData = %orig;
return cellDividerData;
}
// NSString *description = [self description];
if ([self respondsToSelector:@selector(hasCompatibilityOptions)] && self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) return cellDividerData;
return %orig;
}
@ -165,10 +195,7 @@ NSData *cellDividerData;
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"];
return isAdString(description);
}];
[contentsArray removeObjectsAtIndexes:removeIndexes];
}
@ -285,6 +312,9 @@ NSData *cellDividerData;
- (BOOL)isLandscapeEngagementPanelSwipeRightToDismissEnabled { return YES; } // Swipe right to dismiss the right panel in fullscreen mode
- (BOOL)enableModularPlayerBarController { return NO; } // fixes some of the iSponorBlock problems
- (BOOL)mainAppCoreClientEnableCairoSettings { return IS_ENABLED(@"newSettingsUI_enabled"); } // New grouped settings UI
- (BOOL)enableIosFloatingMiniplayer { return IS_ENABLED(@"floatingMiniplayer_enabled"); } // Floating Miniplayer
- (BOOL)enableIosFloatingMiniplayerSwipeUpToExpand { return IS_ENABLED(@"floatingMiniplayer_enabled"); } // Floating Miniplayer
- (BOOL)enableIosFloatingMiniplayerRepositioning { return IS_ENABLED(@"floatingMiniplayer2_enabled"); } // Floating Miniplayer (Repositioning Support, Removes Swiping Up Gesture)
%end
// Fix Casting: https://github.com/arichornlover/uYouEnhanced/issues/606#issuecomment-2098289942
@ -334,6 +364,7 @@ NSData *cellDividerData;
%end
// Restore Settings Button in Navigaton Bar - @arichornlover & @bhackel - https://github.com/arichornlover/uYouEnhanced/issues/178
/* WILL RESULT IN LOSING THE SETTINGS BUTTON!
%hook YTRightNavigationButtons
- (id)visibleButtons {
Class YTVersionUtilsClass = %c(YTVersionUtils);
@ -345,6 +376,7 @@ NSData *cellDividerData;
return [self dynamicButtons];
}
%end
*/
// Hide "Get Youtube Premium" in "You" tab - @bhackel
%group gHidePremiumPromos
@ -622,7 +654,7 @@ static int contrastMode() {
*/
%end
// Disable Modern/Rounded Buttons (_ASDisplayView Version's not included) - @arichornlover
// Disable Modern/Rounded Buttons (_ASDisplayView Version's not supported) - @arichornlover
%group gDisableModernButtons
%hook YTQTMButton // Disable Modern/Rounded Buttons
+ (BOOL)buttonModernizationEnabled { return NO; }
@ -842,7 +874,6 @@ static int contrastMode() {
}
%end
// Disable snap to chapter
%hook YTSegmentableInlinePlayerBarView
- (void)didMoveToWindow {
@ -853,7 +884,6 @@ static int contrastMode() {
}
%end
// Disable Pinch to zoom
%hook YTColdConfig
- (BOOL)videoZoomFreeZoomEnabledGlobalConfig {
@ -1022,6 +1052,7 @@ static int contrastMode() {
}
%end
// LEGACY VERSION ⚠️
// Hide Fullscreen Button - @arichornlover - PoomSmart's Newer Version of the *YouQuality* tweak breaks when enabling this
%hook YTInlinePlayerBarContainerView
- (void)layoutSubviews {
@ -1040,6 +1071,12 @@ static int contrastMode() {
}
%end
// NEW VERSION
// Hide Fullscreen Button - @arichornlover
// %hook YTInlinePlayerBarContainerView
// ..Work-in-progres..
// %end
// Hide HUD Messages
%hook YTHUDMessageView
- (id)initWithMessage:(id)arg1 dismissHandler:(id)arg2 {
@ -1053,7 +1090,7 @@ static int contrastMode() {
return IS_ENABLED(@"hideChannelWatermark_enabled") ? NO : %orig;
}
%end
// Hide Channel Watermark (for Old YouTube Versions / Backwards Compatibility)
// Hide Channel Watermark (for Backwards Compatibility)
%hook YTAnnotationsViewController
- (void)loadFeaturedChannelWatermark {
if (IS_ENABLED(@"hideChannelWatermark_enabled")) {}
@ -1235,31 +1272,17 @@ static int contrastMode() {
}
%end
/*
// Hide Shorts Cells - @PoomSmart, @iCrazeiOS & @Dayanch96
/* DISABLED DUE TO CONFLICTS
// Hide Community Posts - @michael-winay, @arichornlover, @iCrazeiOS @PoomSmart & @Dayanch96
%hook YTIElementRenderer
- (NSData *)elementData {
NSString *description = [self description];
if ([NSUserDefaults.standardUserDefaults boolForKey:@"removeShortsCell"]) { // uYou (Hide Shorts Cells)
if ([description containsString:@"shorts_shelf.eml"] || [description containsString:@"#shorts"] || [description containsString:@"shorts_video_cell.eml"] || [description containsString:@"6Shorts"]) {
if (![description containsString:@"history*"]) {
if (!cellDividerData) cellDividerData = %orig;
return cellDividerData;
}
}
}
// Hide Community Posts @michael-winay & @arichornlover
if (IS_ENABLED(@"hideCommunityPosts_enabled")) {
if ([description containsString:@"post_base_wrapper.eml"]) {
if (!cellDividerData) cellDividerData = %orig;
if (!cellDividerData) cellDividerData = [NSData dataWithBytes:cellDividerDataBytes length:cellDividerDataBytesLength];
return cellDividerData;
}
}
// etc. - @Dayanch96
BOOL hasShorts = ([description containsString:@"shorts_shelf.eml"] || [description containsString:@"shorts_video_cell.eml"] || [description containsString:@"6Shorts"]) && ![description containsString:@"history*"];
BOOL hasShortsInHistory = [description containsString:@"compact_video.eml"] && [description containsString:@"youtube_shorts_"];
if (hasShorts || hasShortsInHistory) return cellDividerData;
return %orig;
}
%end
@ -1274,21 +1297,22 @@ static int contrastMode() {
color = [UIColor redColor];
}
}
// Hide the Button Containers under the Video Player - 17.33.2 and up - @arichornlover
// Hide the Button Containers under the Video Player - 17.33.2 and up - @arichornlover
if (IS_ENABLED(@"hideButtonContainers_enabled")) {
if ([description containsString:@"id.video.like.button"] ||
[description containsString:@"id.video.dislike.button"] ||
[description containsString:@"id.video.share.button"] ||
[description containsString:@"id.video.remix.button"] ||
[description containsString:@"id.ui.add_to.offline.button"]) {
color = [UIColor clearColor];
// self.hidden = YES;
}
}
%orig(color);
}
%end
// Hide the (Connect / Thanks / Save / Report) Buttons under the Video Player - 17.33.2 and up - @arichornlover (inspired by @PoomSmart's version) LEGACY METHOD ⚠️
// LEGACY VERSION ⚠️
// Hide the (Connect / Thanks / Save / Report) Buttons under the Video Player - 17.33.2 and up - @arichornlover (inspired by @PoomSmart's version)
%hook _ASDisplayView
- (void)layoutSubviews {
%orig;
@ -1311,6 +1335,7 @@ static int contrastMode() {
}
%end
// UPDATED VERSION
// Hide the (Connect / Share / Remix / Thanks / Download / Clip / Save / Report) Buttons under the Video Player - 17.33.2 and up - @PoomSmart (inspired by @arichornlover) - METHOD BROKE Server-Side on May 14th 2024
static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *identifiers) {
for (id child in [nodeController children]) {
@ -1479,19 +1504,6 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
}
%end
// %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;
// }];
// [contentsArray removeObjectsAtIndexes:removeIndexes];
// %orig;
// }
// %end
// Disable hints - https://github.com/LillieH001/YouTube-Reborn/blob/v4/
%group gDisableHints
%hook YTSettings
@ -1534,7 +1546,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
%end
// Hide the chip bar under the video player?
// %hook YTChipCloudCell //
// %hook YTChipCloudCell
// - (void)didMoveToWindow {
// %orig;
// self.hidden = YES;
@ -1636,6 +1648,8 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
// Load uYou first so its functions are available for hooks.
// dlopen([[NSString stringWithFormat:@"%@/Frameworks/uYou.dylib", [[NSBundle mainBundle] bundlePath]] UTF8String], RTLD_LAZY);
cellDividerData = [NSData dataWithBytes:cellDividerDataBytes length:cellDividerDataBytesLength];
%init;
if (IS_ENABLED(@"hideYouTubeLogo_enabled")) {
%init(gHideYouTubeLogo);
@ -1812,6 +1826,7 @@ static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *ide
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"];
}
if (![allKeys containsObject:@"uYouAdBlockingWorkaround_enabled"]) {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"uYouAdBlockingWorkaroundLite_enabled"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"uYouAdBlockingWorkaround_enabled"];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"];
}