From de4f2f73737c4bba8bd8d7730595c70eef2a766a Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Sun, 24 Apr 2022 22:23:05 +0700 Subject: [PATCH] clean up code --- Header.h | 27 ++++++++++++ Makefile | 4 +- Settings.xm | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 Header.h create mode 100644 Settings.xm diff --git a/Header.h b/Header.h new file mode 100644 index 0000000..9f0f6f3 --- /dev/null +++ b/Header.h @@ -0,0 +1,27 @@ +#import "Tweaks/YouTubeHeader/YTPlayerViewController.h" + +@interface YTMainAppVideoPlayerOverlayView : UIView +-(UIViewController *)_viewControllerForAncestor; +@end + +@interface YTWatchMiniBarView : UIView +@end + +@interface YTAsyncCollectionView : UIView +@end + +@interface YTPlayerViewController (YTAFS) +- (void)autoFullscreen; +@end + +//@interface ASCollectionView : UIView +//@end + +@interface YTLightweightQTMButton : UIView +@end + +@interface YTELMView : UIView +@end + +@interface NIAttributedLabel : UIView +@end diff --git a/Makefile b/Makefile index e44cf01..e5a1ecc 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ TWEAK_NAME = uYouPlus DISPLAY_NAME = YouTube BUNDLE_ID = com.google.ios.youtube -uYouPlus_FILES = uYouPlus.xm -uYouPlus_IPA = /path/to/decrypted/YouTube/IPA +uYouPlus_FILES = uYouPlus.xm Settings.xm +uYouPlus_IPA = /path/to/your/decrypted/YouTube/IPA ### Important: edit the path to your decrypted YouTube IPA!!! include $(THEOS)/makefiles/common.mk diff --git a/Settings.xm b/Settings.xm new file mode 100644 index 0000000..905da3a --- /dev/null +++ b/Settings.xm @@ -0,0 +1,115 @@ +#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h" + +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 YTSettingsViewController +- (void)setSectionItems:(NSMutableArray *)sectionItems forCategory:(NSInteger)category title:(NSString *)title titleDescription:(NSString *)titleDescription headerHidden:(BOOL)headerHidden { + if (category == 1) { + NSUInteger statsForNerdsIndex = [sectionItems indexOfObjectPassingTest:^BOOL (YTSettingsSectionItem *item, NSUInteger idx, BOOL *stop) { + return item.settingItemId == 265; + }]; + if (statsForNerdsIndex != NSNotFound) { + // + YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking the 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; + }; + [sectionItems insertObject:castConfirm atIndex:statsForNerdsIndex + 1]; + // + YTSettingsSectionItem *hoverCardItem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Show End screens hover cards (YTNoHoverCards)" titleDescription:@"Allows creator End screens (thumbnails) to appear 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; + }; + [sectionItems insertObject:hoverCardItem atIndex:statsForNerdsIndex + 1]; + // + 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; + }; + [sectionItems insertObject:bigYTMiniPlayer atIndex:statsForNerdsIndex + 2]; + // + 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; + }; + [sectionItems insertObject:reExplore atIndex:statsForNerdsIndex + 2]; + // + 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; + }; + [sectionItems insertObject:hideCC atIndex:statsForNerdsIndex + 1]; + // + 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; + }; + [sectionItems insertObject:hideAutoplaySwitch atIndex:statsForNerdsIndex + 1]; + // + 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; + }; + [sectionItems insertObject:autoFUll atIndex:statsForNerdsIndex + 3]; + // + YTSettingsSectionItem *hideHUD = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide HUD Messages" titleDescription:@"Example: CC is turned on/off, Video loop is on,... App restart is required."]; + 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; + }; + [sectionItems insertObject:hideHUD atIndex:statsForNerdsIndex + 1]; + // + 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."]; + 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; + }; + [sectionItems insertObject:Oleditem atIndex:statsForNerdsIndex + 1]; + } + } + %orig; + } +%end \ No newline at end of file