mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-20 02:32:10 +00:00
Fix ASCollectionView
This commit is contained in:
parent
86677c720c
commit
9596faad77
1 changed files with 55 additions and 17 deletions
|
|
@ -1356,29 +1356,67 @@ static int contrastMode() {
|
|||
|
||||
// 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
|
||||
%hook ASCollectionView // This stopped working on May 14th 2024 due to a Server-Side Change from YouTube.
|
||||
- (CGSize)sizeForElement:(ASCollectionElement *)element {
|
||||
if ([self.accessibilityIdentifier isEqualToString:@"id.video.scrollable_action_bar"]) {
|
||||
ASCellNode *node = [element node];
|
||||
for (UIView *subview in node.view.subviews) {
|
||||
if ([subview isKindOfClass:[UIButton class]]) {
|
||||
UIButton *button = (UIButton *)subview;
|
||||
if ([button.accessibilityIdentifier isEqualToString:@"id.video.share.button"] && IS_ENABLED(@"hideShareButton_enabled")) {
|
||||
subview.hidden = YES;
|
||||
} else if ([button.accessibilityIdentifier isEqualToString:@"id.video.remix.button"] && IS_ENABLED(@"hideRemixButton_enabled")) {
|
||||
subview.hidden = YES;
|
||||
} else if ([button.accessibilityIdentifier isEqualToString:@"Thanks"] && IS_ENABLED(@"hideThanksButton_enabled")) {
|
||||
subview.hidden = YES;
|
||||
} else if ([button.accessibilityIdentifier isEqualToString:@"clip_button.eml"] && IS_ENABLED(@"hideClipButton_enabled")) {
|
||||
subview.hidden = YES;
|
||||
} else if ([button.accessibilityIdentifier isEqualToString:@"id.ui.add_to.offline.button"] && IS_ENABLED(@"hideDownloadButton_enabled")) {
|
||||
subview.hidden = YES;
|
||||
static BOOL findCell(ASNodeController *nodeController, NSArray <NSString *> *identifiers) {
|
||||
for (id child in [nodeController children]) {
|
||||
if ([child isKindOfClass:%c(ELMNodeController)]) {
|
||||
NSArray <ELMComponent *> *elmChildren = [(ELMNodeController * _Nullable)child children];
|
||||
for (ELMComponent *elmChild in elmChildren) {
|
||||
for (NSString *identifier in identifiers) {
|
||||
if ([[elmChild description] containsString:identifier])
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([child isKindOfClass:%c(ASNodeController)]) {
|
||||
ASDisplayNode *childNode = ((ASNodeController * _Nullable)child).node; // ELMContainerNode
|
||||
NSArray<id> *yogaChildren = childNode.yogaChildren;
|
||||
for (ASDisplayNode *displayNode in yogaChildren) {
|
||||
if ([identifiers containsObject:displayNode.accessibilityIdentifier])
|
||||
return YES;
|
||||
}
|
||||
|
||||
return findCell(child, identifiers);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
%hook ASCollectionView // This stopped working on May 14th 2024 due to a Server-Side Change from YouTube.
|
||||
|
||||
- (CGSize)sizeForElement:(ASCollectionElement * _Nullable)element {
|
||||
if ([self.accessibilityIdentifier isEqualToString:@"id.video.scrollable_action_bar"]) {
|
||||
ASCellNode *node = [element node];
|
||||
ASNodeController *nodeController = [node controller];
|
||||
if (IS_ENABLED(@"hideShareButton_enabled") && findCell(nodeController, @[@"id.video.share.button"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(@"hideRemixButton_enabled") && findCell(nodeController, @[@"id.video.remix.button"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(@"hideThanksButton_enabled") && findCell(nodeController, @[@"Thanks"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(@"hideClipButton_enabled") && findCell(nodeController, @[@"clip_button.eml"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(@"hideDownloadButton_enabled") && findCell(nodeController, @[@"id.ui.add_to.offline.button"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(@"hideCommentSection_enabled") && findCell(nodeController, @[@"id.ui.carousel_header"])) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
}
|
||||
return %orig;
|
||||
}
|
||||
|
||||
%end
|
||||
|
||||
// App Settings Overlay Options
|
||||
|
|
|
|||
Loading…
Reference in a new issue