mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-18 04:51:41 +00:00
130 lines
No EOL
6.7 KiB
Text
130 lines
No EOL
6.7 KiB
Text
#import "Tweaks/YouTubeHeader/YTSettingsViewController.h"
|
|
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
|
|
#import "Tweaks/YouTubeHeader/YTSettingsSectionItemManager.h"
|
|
|
|
@interface YTSettingsSectionItemManager (YouPiP)
|
|
- (void)updateuYouPlusSectionWithEntry:(id)entry;
|
|
@end
|
|
|
|
static const NSInteger uYouPlusSection = 500;
|
|
|
|
extern BOOL hideHUD();
|
|
extern BOOL oled();
|
|
extern BOOL autoFullScreen();
|
|
extern BOOL noHoverCard();
|
|
extern BOOL ReExplore();
|
|
extern BOOL bigYTMiniPlayer();
|
|
extern BOOL hideCC();
|
|
extern BOOL hideAutoplaySwitch();
|
|
extern BOOL castConfirm();
|
|
|
|
// Settings
|
|
%hook YTAppSettingsPresentationData
|
|
+ (NSArray *)settingsCategoryOrder {
|
|
NSArray *order = %orig;
|
|
NSMutableArray *mutableOrder = [order mutableCopy];
|
|
NSUInteger insertIndex = [order indexOfObject:@(1)];
|
|
if (insertIndex != NSNotFound)
|
|
[mutableOrder insertObject:@(uYouPlusSection) atIndex:insertIndex + 1];
|
|
return mutableOrder;
|
|
}
|
|
|
|
%end
|
|
|
|
%hook YTSettingsSectionItemManager
|
|
%new - (void)updateuYouPlusSectionWithEntry:(id)entry {
|
|
YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
|
|
|
|
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."];
|
|
castConfirm.hasSwitch = YES;
|
|
castConfirm.switchVisible = YES;
|
|
castConfirm.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
|
|
castConfirm.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"castConfirm_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *hoverCardItem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide End screens hover cards (YTNoHoverCards)" titleDescription:@"Hide creator End screens (thumbnails) at the end of videos."];
|
|
hoverCardItem.hasSwitch = YES;
|
|
hoverCardItem.switchVisible = YES;
|
|
hoverCardItem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hover_cards_enabled"];
|
|
hoverCardItem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hover_cards_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *bigYTMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"New miniplayer bar style (BigYTMiniPlayer)" titleDescription:@"App restart is required."];
|
|
bigYTMiniPlayer.hasSwitch = YES;
|
|
bigYTMiniPlayer.switchVisible = YES;
|
|
bigYTMiniPlayer.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"bigYTMiniPlayer_enabled"];
|
|
bigYTMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"bigYTMiniPlayer_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *reExplore = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Replace Shorts tab with Explore tab (YTReExplore)" titleDescription:@"App restart is required."];
|
|
reExplore.hasSwitch = YES;
|
|
reExplore.switchVisible = YES;
|
|
reExplore.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"reExplore_enabled"];
|
|
reExplore.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *hideCC = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Subtitles button" titleDescription:@"Hide the Subtitles button in video controls overlay. "];
|
|
hideCC.hasSwitch = YES;
|
|
hideCC.switchVisible = YES;
|
|
hideCC.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideCC_enabled"];
|
|
hideCC.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideCC_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *hideAutoplaySwitch = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Autoplay switch" titleDescription:@"Hide the Autoplay switch button in video controls overlay."];
|
|
hideAutoplaySwitch.hasSwitch = YES;
|
|
hideAutoplaySwitch.switchVisible = YES;
|
|
hideAutoplaySwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideAutoplaySwitch_enabled"];
|
|
hideAutoplaySwitch.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideAutoplaySwitch_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen (YTAutoFullScreen)" titleDescription:@"Autoplay videos at full screen."];
|
|
autoFUll.hasSwitch = YES;
|
|
autoFUll.switchVisible = YES;
|
|
autoFUll.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"autofull_enabled"];
|
|
autoFUll.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"autofull_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *hideHUD = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide HUD Messages" titleDescription:@"Example: CC is turned on/off, Video loop is on,..."];
|
|
hideHUD.hasSwitch = YES;
|
|
hideHUD.switchVisible = YES;
|
|
hideHUD.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"];
|
|
hideHUD.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
YTSettingsSectionItem *Oleditem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"OLED Dark mode (Experimental)" titleDescription:@"WARNING: OLED Dark mode only works when YouTube is in Dark theme. App restart is required. (In case OLED dark mode doesn't work: just switch between Light/Dark theme, then restart the app)."];
|
|
Oleditem.hasSwitch = YES;
|
|
Oleditem.switchVisible = YES;
|
|
Oleditem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"oled_enabled"];
|
|
Oleditem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
|
|
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oled_enabled"];
|
|
return YES;
|
|
};
|
|
|
|
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[castConfirm, hoverCardItem, bigYTMiniPlayer, reExplore, hideCC, hideAutoplaySwitch, autoFUll, hideHUD, Oleditem]];
|
|
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
|
|
}
|
|
|
|
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry {
|
|
if (category == uYouPlusSection) {
|
|
[self updateuYouPlusSectionWithEntry:entry];
|
|
return;
|
|
}
|
|
%orig;
|
|
}
|
|
%end |