mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-13 20:41:28 +00:00
hide Previous/Next button
This commit is contained in:
parent
8b50a3c1b7
commit
b94a5cc967
2 changed files with 51 additions and 29 deletions
14
Settings.xm
14
Settings.xm
|
|
@ -19,6 +19,7 @@ extern BOOL hideCC();
|
|||
extern BOOL hideAutoplaySwitch();
|
||||
extern BOOL castConfirm();
|
||||
extern BOOL ytMiniPlayer();
|
||||
extern BOOL hidePreviousAndNextButton();
|
||||
|
||||
// Settings
|
||||
%hook YTAppSettingsPresentationData
|
||||
|
|
@ -37,6 +38,15 @@ extern BOOL ytMiniPlayer();
|
|||
%new - (void)updateuYouPlusSectionWithEntry:(id)entry {
|
||||
YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
|
||||
|
||||
YTSettingsSectionItem *hidePreviousAndNextButton = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Previous and Next button" titleDescription:@""];
|
||||
hidePreviousAndNextButton.hasSwitch = YES;
|
||||
hidePreviousAndNextButton.switchVisible = YES;
|
||||
hidePreviousAndNextButton.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hidePreviousAndNextButton_enabled"];
|
||||
hidePreviousAndNextButton.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
||||
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hidePreviousAndNextButton_enabled"];
|
||||
return YES;
|
||||
};
|
||||
|
||||
YTSettingsSectionItem *ytMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Enable the Miniplayer for all YouTube videos" titleDescription:@""];
|
||||
ytMiniPlayer.hasSwitch = YES;
|
||||
ytMiniPlayer.switchVisible = YES;
|
||||
|
|
@ -46,7 +56,7 @@ extern BOOL ytMiniPlayer();
|
|||
return YES;
|
||||
};
|
||||
|
||||
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."];
|
||||
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV. App restart is required."];
|
||||
castConfirm.hasSwitch = YES;
|
||||
castConfirm.switchVisible = YES;
|
||||
castConfirm.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
|
||||
|
|
@ -136,7 +146,7 @@ extern BOOL ytMiniPlayer();
|
|||
return YES;
|
||||
};
|
||||
|
||||
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]];
|
||||
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hidePreviousAndNextButton, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]];
|
||||
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
|
||||
}
|
||||
|
||||
|
|
|
|||
66
uYouPlus.xm
66
uYouPlus.xm
|
|
@ -3,7 +3,6 @@
|
|||
#import <objc/runtime.h>
|
||||
#import "Header.h"
|
||||
#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
|
||||
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
|
||||
#import "Tweaks/YouTubeHeader/YTPlayerViewController.h"
|
||||
#import "Tweaks/YouTubeHeader/YTWatchController.h"
|
||||
#import "Tweaks/YouTubeHeader/YTIGuideResponse.h"
|
||||
|
|
@ -43,6 +42,9 @@ BOOL hideCC() {
|
|||
BOOL hideAutoplaySwitch() {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideAutoplaySwitch_enabled"];
|
||||
}
|
||||
BOOL hidePreviousAndNextButton() {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hidePreviousAndNextButton_enabled"];
|
||||
}
|
||||
BOOL castConfirm() {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
|
||||
}
|
||||
|
|
@ -69,6 +71,14 @@ BOOL ytMiniPlayer() {
|
|||
if (hideAutoplaySwitch()) {}
|
||||
else { return %orig; }
|
||||
}
|
||||
- (void)layoutSubviews {
|
||||
if (hidePreviousAndNextButton()) {
|
||||
MSHookIvar<YTMainAppControlsOverlayView *>(self, "_nextButton").hidden = YES;
|
||||
MSHookIvar<YTMainAppControlsOverlayView *>(self, "_previousButton").hidden = YES;
|
||||
%orig;
|
||||
}
|
||||
return %orig;
|
||||
}
|
||||
%end
|
||||
|
||||
// Hide HUD Messages
|
||||
|
|
@ -102,41 +112,40 @@ BOOL ytMiniPlayer() {
|
|||
%end
|
||||
|
||||
//YTCastConfirm: https://github.com/JamieBerghmans/YTCastConfirm
|
||||
%group gYTCastconfirm
|
||||
%hook MDXPlaybackRouteButtonController
|
||||
- (void)didPressButton:(id)arg1 {
|
||||
if (castConfirm()) {
|
||||
UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
|
||||
message:@"Are you sure you want to start casting?"
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
||||
%orig;
|
||||
}];
|
||||
UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
|
||||
message:@"Are you sure you want to start casting?"
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
|
||||
%orig;
|
||||
}];
|
||||
|
||||
UIAlertAction* noButton = [%c(UIAlertAction)
|
||||
actionWithTitle:@"Cancel"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler: ^(UIAlertAction * action) {
|
||||
return;
|
||||
}];
|
||||
UIAlertAction* noButton = [%c(UIAlertAction)
|
||||
actionWithTitle:@"Cancel"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler: ^(UIAlertAction * action) { return; }
|
||||
];
|
||||
|
||||
[alertController addAction:defaultAction];
|
||||
[alertController addAction:noButton];
|
||||
[alertController addAction:defaultAction];
|
||||
[alertController addAction:noButton];
|
||||
|
||||
id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
|
||||
if ([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
|
||||
rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
|
||||
}
|
||||
if ([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
|
||||
rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
|
||||
}
|
||||
if ([rootViewController presentedViewController] != nil) {
|
||||
rootViewController = [rootViewController presentedViewController];
|
||||
}
|
||||
[rootViewController presentViewController:alertController animated:YES completion:nil];
|
||||
id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
|
||||
if ([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
|
||||
rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
|
||||
}
|
||||
if ([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
|
||||
rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
|
||||
}
|
||||
if ([rootViewController presentedViewController] != nil) {
|
||||
rootViewController = [rootViewController presentedViewController];
|
||||
}
|
||||
[rootViewController presentViewController:alertController animated:YES completion:nil];
|
||||
return %orig;
|
||||
}
|
||||
%end
|
||||
%end
|
||||
|
||||
// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/12
|
||||
%hook YTAdsInnerTubeContextDecorator
|
||||
|
|
@ -559,4 +568,7 @@ static void replaceTab(YTIGuideResponse *response) {
|
|||
if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
|
||||
%init(Main);
|
||||
}
|
||||
if (castConfirm()) {
|
||||
%init(gYTCastconfirm);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue