Skip to content

Commit

Permalink
an option to replace Previous & Next button with Fast forward & Rewin…
Browse files Browse the repository at this point in the history
…d button
  • Loading branch information
qnblackcat committed Sep 7, 2022
1 parent 39849ca commit 2191478
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
11 changes: 10 additions & 1 deletion Settings.xm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -177,7 +186,7 @@ extern BOOL hidePaidPromotionCard();
return YES;
};

NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, fixGoogleSigin, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]];
NSMutableArray <YTSettingsSectionItem *> *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];
}

Expand Down
44 changes: 31 additions & 13 deletions uYouPlus.xm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ NSBundle *uYouPlusBundle() {
}
NSBundle *tweakBundle = uYouPlusBundle();

// Keychain patching
static NSString *accessGroupID() {
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass,
Expand Down Expand Up @@ -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
Expand All @@ -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); }
Expand All @@ -124,15 +128,22 @@ BOOL fixGoogleSigin() {
if (hideAutoplaySwitch()) {}
else { return %orig; }
}
- (void)layoutSubviews { // hide Next & Previous button
%orig;
if (hidePreviousAndNextButton()) {
MSHookIvar<YTMainAppControlsOverlayView *>(self, "_nextButton").hidden = YES;
MSHookIvar<YTMainAppControlsOverlayView *>(self, "_previousButton").hidden = YES;
MSHookIvar<YTTransportControlsButtonView *>(self, "_nextButtonView").hidden = YES;
MSHookIvar<YTTransportControlsButtonView *>(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
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 2191478

Please sign in to comment.