MiRO92 / uYou-for-YouTube

Enhance Your YouTube Experience
https://miro92.com
2.41k stars 14.19k forks source link

Stuff for uYou 3.0.4 [Useful Code to help uYou! - March 20th 2024] #327

Closed arichornlover closed 9 months ago

arichornlover commented 1 year ago

UPDATED March 20th 2024

Hello @MiRO92 I have some more features or fixes that can be useful to uYou! here’s the first one


The code below is something I have made. a tweak that only works with v17.xx.x or higher. being able to hide the Remix, Thanks, Download, Clip & Save buttons under the video player. however. I wasn’t fully smart enough with the implementation so whenever it hides the button, it will have gaps. GAPS

// DEPRECATED ⚠️ as of March 20th 2024
// Hide the (Connect / Share / Remix / Thanks / Download / Clip / Save) Buttons under the Video Player - 17.x.x and up - @arichornlover - [Issue: It will have gaps! wasn’t smart enough to even try to remove them]
%hook _ASDisplayView
- (void)layoutSubviews {
    %orig;
    BOOL hideConnectButton = IS_ENABLED(@"hideConnectButton_enabled");
    BOOL hideShareButton = IS_ENABLED(@"hideShareButton_enabled");
    BOOL hideRemixButton = IS_ENABLED(@"hideRemixButton_enabled");
    BOOL hideThanksButton = IS_ENABLED(@"hideThanksButton_enabled");
    BOOL hideAddToOfflineButton = IS_ENABLED(@"hideAddToOfflineButton_enabled");
    BOOL hideClipButton = IS_ENABLED(@"hideClipButton_enabled");
    BOOL hideSaveToPlaylistButton = IS_ENABLED(@"hideSaveToPlaylistButton_enabled");

    for (UIView *subview in self.subviews) {
        if ([subview.accessibilityLabel isEqualToString:@"connect account"]) {
            subview.hidden = hideConnectButton;
        } else if ([subview.accessibilityIdentifier isEqualToString:@"id.video.share.button"] || [subview.accessibilityLabel isEqualToString:@"Share"]) {
            subview.hidden = hideShareButton;
        } else if ([subview.accessibilityIdentifier isEqualToString:@"id.video.remix.button"] || [subview.accessibilityLabel isEqualToString:@"Create a Short with this video"]) {
            subview.hidden = hideRemixButton;
        } else if ([subview.accessibilityLabel isEqualToString:@"Thanks"]) {
            subview.hidden = hideThanksButton;
        } else if ([subview.accessibilityIdentifier isEqualToString:@"id.ui.add_to.offline.button"] || [subview.accessibilityLabel isEqualToString:@"Download"]) {
            subview.hidden = hideAddToOfflineButton;
        } else if ([subview.accessibilityLabel isEqualToString:@"Clip"]) {
            subview.hidden = hideClipButton;
        } else if ([subview.accessibilityLabel isEqualToString:@"Save to playlist"]) {
            subview.hidden = hideSaveToPlaylistButton;
        }
    }
}
%end

This implementation is something that is Customizable in the Video Player Overlay. Having the ability to remove the Button Background on all 5 of the Buttons in the video player. Play/Pause, Previous, Next, Rewind & Forward

%hook YTMainAppControlsOverlayView
- (void)layoutSubviews {
    %orig();
    MSHookIvar<YTTransportControlsButtonView *>(self, "_previousButtonView").backgroundColor = nil;
    MSHookIvar<YTTransportControlsButtonView *>(self, "_nextButtonView").backgroundColor = nil;
    MSHookIvar<YTTransportControlsButtonView *>(self, "_seekBackwardAccessibilityButtonView").backgroundColor = nil;
    MSHookIvar<YTTransportControlsButtonView *>(self, "_seekForwardAccessibilityButtonView").backgroundColor = nil;
    MSHookIvar<YTPlaybackButton *>(self, "_playPauseButton").backgroundColor = nil;
}
%end

the option uYou Shorts > Always Show Progress Bar is broken but it can be fixed for by adding the extra code below!

%hook YTShortsPlayerViewController
- (BOOL)shouldAlwaysEnablePlayerBar { return YES; }
- (BOOL)shouldEnablePlayerBarOnlyOnPause { return NO; }
%end

Here’s the next one as a new Option, and it’s hiding the YouTube Logo on the top left, not sure if that’s needed though.

%hook YTHeaderLogoController
- (YTHeaderLogoController *)init {
    return NULL;
}
%end

YouTube added a feature called Suggested Videos in the Video Player. @bhackel made this option to hide it. Good job to them! 😁

// YTNoSuggestedVideo - https://github.com/bhackel/YTNoSuggestedVideo
%hook YTMainAppVideoPlayerOverlayViewController
- (bool)shouldShowAutonavEndscreen {
        return false;
}
%end

This is an updated version of Hide Upgrade Dialog. It simply just removes any prompt to update to the latest version of the app. However this is a very important thing for uYou to prevent issues like https://github.com/MiRO92/uYou-for-YouTube/issues/358 from ever happening.

// Hide Upgrade Dialog (updated)
%hook YTGlobalConfig
- (BOOL)shouldBlockUpgradeDialog { return YES;}
- (BOOL)shouldForceUpgrade { return NO;}
- (BOOL)shouldShowUpgrade { return NO;}
- (BOOL)shouldShowUpgradeDialog { return NO;}
%end

however, if you don’t like this version you can use this version of the Hide Upgrade Dialog by 0xilis below https://github.com/0xilis/LetMePass/blob/main/dylib.c


other There is stuff that I was unable to solve but you can check this out below if you want! 😁 https://github.com/arichornlover/uYouEnhanced/issues/73, https://github.com/arichornlover/uYouEnhanced/issues/57, https://github.com/arichornlover/uYouEnhanced/issues/311 <-- conflicts new YTSpeed update
Sauce-cod3 commented 1 year ago

Great suggestions arichorn. Both Miro, yourself and all of the other contributors are helping to keep this amazing app alive.

arichornlover commented 1 year ago

I’m just glad I helped out. Including PoomSmart, LillieH1000 & the others.

arichornlover commented 1 year ago

uYou 3.0.1 will crash when playing a video if you are using YouTube v18.43.4 or higher.

MiRO92 commented 9 months ago

Once again thanks a lot for your help @arichornlover

arichornlover commented 9 months ago

MiRO92, you did forget to close https://github.com/MiRO92/uYou-for-YouTube/issues/331 Issue 331 is related to this issue because without that issue, the code above wouldn’t even exist.

edit: I edited this response due to spelling mistakes. I apologize.