From 2191478712ca12f6f1bb8039e0c5032f1ff0808c Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Wed, 7 Sep 2022 21:30:15 +0700 Subject: [PATCH] an option to replace Previous & Next button with Fast forward & Rewind button --- Settings.xm | 11 ++++++++++- uYouPlus.xm | 44 +++++++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/Settings.xm b/Settings.xm index ef3abc5b85..33d4b93f49 100644 --- a/Settings.xm +++ b/Settings.xm @@ -51,6 +51,15 @@ extern BOOL hidePaidPromotionCard(); exit(0); }]; + YTSettingsSectionItem *replacePreviousAndNextButton = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON") titleDescription:LOC(@"REPLACE_PREVIOUS_NEXT_BUTTON_DESC")]; + replacePreviousAndNextButton.hasSwitch = YES; + replacePreviousAndNextButton.switchVisible = YES; + replacePreviousAndNextButton.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"replacePreviousAndNextButton_enabled"]; + replacePreviousAndNextButton.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"replacePreviousAndNextButton_enabled"]; + return YES; + }; + YTSettingsSectionItem *fixGoogleSigin = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"FIX_GOOGLE_SIGNIN") titleDescription:LOC(@"FIX_GOOGLE_SIGNIN_DESC")]; fixGoogleSigin.hasSwitch = YES; fixGoogleSigin.switchVisible = YES; @@ -177,7 +186,7 @@ extern BOOL hidePaidPromotionCard(); return YES; }; - NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, fixGoogleSigin, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]]; + NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, fixGoogleSigin, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, replacePreviousAndNextButton, reExplore]]; [delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO]; } diff --git a/uYouPlus.xm b/uYouPlus.xm index a986a94ea8..9350e89b65 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -30,6 +30,7 @@ NSBundle *uYouPlusBundle() { } NSBundle *tweakBundle = uYouPlusBundle(); +// Keychain patching static NSString *accessGroupID() { NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys: (__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass, @@ -93,6 +94,9 @@ BOOL hidePaidPromotionCard() { BOOL fixGoogleSigin() { return [[NSUserDefaults standardUserDefaults] boolForKey:@"fixGoogleSigin_enabled"]; } +BOOL replacePreviousAndNextButton() { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"replacePreviousAndNextButton_enabled"]; +} # pragma mark - Tweaks // Enable Reorder videos from playlist while on the Watch page - @PoomSmart @@ -114,7 +118,7 @@ BOOL fixGoogleSigin() { } %end -// Hide CC / Autoplay switch / Next & Previous button +// Hide CC / Autoplay switch %hook YTMainAppControlsOverlayView - (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC button if (hideCC()) { return %orig(NO); } @@ -124,15 +128,22 @@ BOOL fixGoogleSigin() { if (hideAutoplaySwitch()) {} else { return %orig; } } -- (void)layoutSubviews { // hide Next & Previous button - %orig; - if (hidePreviousAndNextButton()) { - MSHookIvar(self, "_nextButton").hidden = YES; - MSHookIvar(self, "_previousButton").hidden = YES; - MSHookIvar(self, "_nextButtonView").hidden = YES; - MSHookIvar(self, "_previousButtonView").hidden = YES; - } -} +%end + +// Hide Next & Previous button +%group gHidePreviousAndNextButton +%hook YTColdConfig +- (BOOL)removeNextPaddleForSingletonVideos { return YES; } +- (BOOL)removePreviousPaddleForSingletonVideos { return YES; } +%end +%end + +// Replace Next & Previous button with Fast forward & Rewind button +%group gReplacePreviousAndNextButton +%hook YTColdConfig +- (BOOL)replaceNextPaddleWithFastForwardButtonForSingletonVods { return YES; } +- (BOOL)replacePreviousPaddleWithRewindButtonForSingletonVods { return YES; } +%end %end // Hide HUD Messages @@ -250,6 +261,7 @@ BOOL fixGoogleSigin() { // YouRememberCaption: https://poomsmart.github.io/repo/depictions/youremembercaption.html %hook YTColdConfig - (BOOL)respectDeviceCaptionSetting { return NO; } +- (BOOL)isLandscapeEngagementPanelSwipeRightToDismissEnabled { return YES; } %end // NOYTPremium - https://github.com/PoomSmart/NoYTPremium/ @@ -350,9 +362,9 @@ BOOL fixGoogleSigin() { // Prevent uYou player bar from showing when not playing downloaded media %hook PlayerManager - (void)pause { - if (isnan([self progress])) - return; - %orig; + if (isnan([self progress])) + return; + %orig; } %end @@ -874,6 +886,12 @@ static void replaceTab(YTIGuideResponse *response) { if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { %init(Main); } + if (hidePreviousAndNextButton()) { + %init(gHidePreviousAndNextButton); + } + if (replacePreviousAndNextButton()) { + %init(gReplacePreviousAndNextButton); + } if (@available(iOS 16, *)) { %init(iOS16); }