1- #import < Foundation/Foundation.h>
21#import < UIKit/UIKit.h>
2+ #import < Foundation/Foundation.h>
3+ #import < objc/runtime.h>
34#import " Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
45#import " Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
56#import " Tweaks/YouTubeHeader/YTPlayerViewController.h"
67#import " Tweaks/YouTubeHeader/YTWatchController.h"
7-
8+ #import " Tweaks/YouTubeHeader/YTIGuideResponse.h"
9+ #import " Tweaks/YouTubeHeader/YTIGuideResponseSupportedRenderers.h"
10+ #import " Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h"
11+ #import " Tweaks/YouTubeHeader/YTIPivotBarRenderer.h"
12+ #import " Tweaks/YouTubeHeader/YTIBrowseRequest.h"
13+ #include < RemoteLog.h>
14+
15+ @interface YTMainAppVideoPlayerOverlayView : UIView
16+ -(UIViewController *)_viewControllerForAncestor ;
17+ @end
18+ @interface YTWatchMiniBarView : UIView
19+ @end
820@interface YTAsyncCollectionView : UIView
921@end
1022@interface YTPlayerViewController (YTAFS )
@@ -25,6 +37,12 @@ BOOL autoFullScreen() {
2537BOOL noHoverCard () {
2638 return [[NSUserDefaults standardUserDefaults ] boolForKey: @" hover_cards_enabled" ];
2739}
40+ BOOL ReExplore () {
41+ return [[NSUserDefaults standardUserDefaults ] boolForKey: @" reExplore_enabled" ];
42+ }
43+ BOOL bigYTMiniPlayer () {
44+ return [[NSUserDefaults standardUserDefaults ] boolForKey: @" bigYTMiniPlayer_enabled" ];
45+ }
2846
2947// Settings
3048%hook YTSettingsViewController
@@ -34,16 +52,16 @@ BOOL noHoverCard() {
3452 return item.settingItemId == 265 ;
3553 }];
3654 if (statsForNerdsIndex != NSNotFound ) {
37- //
38- YTSettingsSectionItem *hideHUD = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Hide HUD Messages " titleDescription: @" Example: CC is turned on/off, Video loop is on,... App restart is required ." ];
39- hideHUD .hasSwitch = YES ;
40- hideHUD .switchVisible = YES ;
41- hideHUD .on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" hideHUD_enabled " ];
42- hideHUD .switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
43- [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" hideHUD_enabled " ];
55+ //
56+ 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 ." ];
57+ hoverCardItem .hasSwitch = YES ;
58+ hoverCardItem .switchVisible = YES ;
59+ hoverCardItem .on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" hover_cards_enabled " ];
60+ hoverCardItem .switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
61+ [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" hover_cards_enabled " ];
4462 return YES ;
4563 };
46- [sectionItems insertObject: hideHUD atIndex: statsForNerdsIndex];
64+ [sectionItems insertObject: hoverCardItem atIndex: statsForNerdsIndex + 2 ];
4765 //
4866 YTSettingsSectionItem *Oleditem = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" OLED Dark mode (Experimental)" titleDescription: @" WARNING: You must set YouTube's appearance to Dark theme before enabling OLED dark mode (not tested on iPad yet). App restart is required." ];
4967 Oleditem.hasSwitch = YES ;
@@ -55,25 +73,45 @@ BOOL noHoverCard() {
5573 };
5674 [sectionItems insertObject: Oleditem atIndex: statsForNerdsIndex - 11 ];
5775 //
58- YTSettingsSectionItem *autoFUll = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Auto Full Screen" titleDescription: @" Autoplay videos at full screen." ];
76+ YTSettingsSectionItem *autoFUll = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Auto Full Screen (YTAutoFullScreen) " titleDescription: @" Autoplay videos at full screen." ];
5977 autoFUll.hasSwitch = YES ;
6078 autoFUll.switchVisible = YES ;
6179 autoFUll.on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" autofull_enabled" ];
6280 autoFUll.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
6381 [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" autofull_enabled" ];
6482 return YES ;
6583 };
66- [sectionItems insertObject: autoFUll atIndex: statsForNerdsIndex + 1 ];
84+ [sectionItems insertObject: autoFUll atIndex: statsForNerdsIndex + 2 ];
6785 //
68- YTSettingsSectionItem *hoverCardItem = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Show End screens hover cards" titleDescription: @" Allows creator End screens (thumbnails) to appear at the end of videos." ];
69- hoverCardItem.hasSwitch = YES ;
70- hoverCardItem.switchVisible = YES ;
71- hoverCardItem.on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" hover_cards_enabled" ];
72- hoverCardItem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
73- [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" hover_cards_enabled" ];
86+ YTSettingsSectionItem *hideHUD = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Hide HUD Messages" titleDescription: @" Example: CC is turned on/off, Video loop is on,... App restart is required." ];
87+ hideHUD.hasSwitch = YES ;
88+ hideHUD.switchVisible = YES ;
89+ hideHUD.on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" hideHUD_enabled" ];
90+ hideHUD.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
91+ [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" hideHUD_enabled" ];
92+ return YES ;
93+ };
94+ [sectionItems insertObject: hideHUD atIndex: statsForNerdsIndex + 2 ];
95+ //
96+ YTSettingsSectionItem *reExplore = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Replace Shorts tab with Explore tab (YTReExplore)" titleDescription: @" App restart is required." ];
97+ reExplore.hasSwitch = YES ;
98+ reExplore.switchVisible = YES ;
99+ reExplore.on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" reExplore_enabled" ];
100+ reExplore.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
101+ [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" reExplore_enabled" ];
74102 return YES ;
75103 };
76- [sectionItems insertObject: hoverCardItem atIndex: statsForNerdsIndex + 4 ];
104+ [sectionItems insertObject: reExplore atIndex: statsForNerdsIndex + 4 ];
105+ //
106+ YTSettingsSectionItem *bigYTMiniPlayer = [[%c (YTSettingsSectionItem) alloc ] initWithTitle: @" Bigger miniplayer bar (BigYTMiniPlayer)" titleDescription: @" App restart is required." ];
107+ bigYTMiniPlayer.hasSwitch = YES ;
108+ bigYTMiniPlayer.switchVisible = YES ;
109+ bigYTMiniPlayer.on = [[NSUserDefaults standardUserDefaults ] boolForKey: @" bigYTMiniPlayer_enabled" ];
110+ bigYTMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
111+ [[NSUserDefaults standardUserDefaults ] setBool: enabled forKey: @" bigYTMiniPlayer_enabled" ];
112+ return YES ;
113+ };
114+ [sectionItems insertObject: bigYTMiniPlayer atIndex: statsForNerdsIndex + 4 ];
77115 }
78116 }
79117 %orig ;
@@ -83,17 +121,18 @@ BOOL noHoverCard() {
83121// Hide HUD Messages
84122%hook YTHUDMessageView
85123- (id )initWithMessage:(id )arg1 dismissHandler:(id )arg2 {
86- if (hideHUD ())
124+ if (hideHUD ()) {
87125 return NULL ;
88- else
89- return %orig ;
126+ }
127+ else
128+ return %orig ;
90129}
91130%end
92131
93132// YTAutoFullScreen: https://github.com/PoomSmart/YTAutoFullScreen/
94133%hook YTPlayerViewController
95134- (void )loadWithPlayerTransition:(id )arg1 playbackConfig:(id )arg2 {
96- if (autoFullScreen ()) {
135+ if (autoFullScreen ()) {
97136 %orig ;
98137 [NSTimer scheduledTimerWithTimeInterval: 0.75 target: self selector: @selector (autoFullscreen ) userInfo: nil repeats: NO ];
99138 } else { return %orig ; }
@@ -108,8 +147,8 @@ if (autoFullScreen()) {
108147// YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards
109148%hook YTCreatorEndscreenView
110149- (void )setHidden:(BOOL )hidden {
111- if (!noHoverCard ())
112- hidden = YES ;
150+ if (!noHoverCard ())
151+ hidden = YES ;
113152 %orig ;
114153}
115154%end
@@ -139,7 +178,7 @@ if (!noHoverCard())
139178- (BOOL )respectDeviceCaptionSetting { return NO ; }
140179%end
141180
142- // OLED Dark mode
181+ // OLED
143182// Thanks u/DGh0st for his very well explained comment - https://www.reddit.com/r/jailbreakdevelopers/comments/9uape7/comment/e94sq80/
144183// Thanks sinfool for his flex patch which brings OLED Dark mode for YouTube - "Color Customizer (YouTube) OLED"
145184%group gOLED
@@ -365,21 +404,7 @@ if (!noHoverCard())
365404 arg1 = oledColor;
366405 %orig ;
367406}
368- %end
369-
370- %hook ASWAppSwitchingSheetFooterView // open link
371- -(void )setBackgroundColor:(id )arg1 {
372- arg1 = oledColor;
373- %orig ;
374- }
375- %end
376-
377- %hook ASWAppSwitchingSheetHeaderView // open link
378- -(void )setBackgroundColor:(id )arg1 {
379- arg1 = oledColor;
380- %orig ;
381- }
382- %end
407+ %end
383408
384409%hook YTCollectionSeparatorView
385410-(void )setBackgroundColor:(id )arg1 {
@@ -407,21 +432,18 @@ if (!noHoverCard())
407432 %orig;
408433}
409434%end
410-
411435%hook YTChannelProfileNameEditorView // edit profile Name
412436-(void)setBackgroundColor:(id)arg1 {
413437 arg1 = oledColor;
414438 %orig;
415439}
416440%end
417-
418441hook GOOTextField
419442-(void)setBackgroundColor:(id)arg1 { // edit profile Description
420443 arg1 = oledColor;
421444 %orig;
422445}
423446%end
424-
425447%hook GOOMultilineTextField//
426448-(void)setBackgroundColor:(id)arg1 { // edit profile Name
427449 arg1 = oledColor;
@@ -432,9 +454,74 @@ hook GOOTextField
432454
433455%end
434456
457+ // YTReExplore: https://github.com/PoomSmart/YTReExplore/
458+ %group gReExplore
459+ static void replaceTab (YTIGuideResponse *response) {
460+ NSMutableArray <YTIGuideResponseSupportedRenderers *> *renderers = [response itemsArray ];
461+ for (YTIGuideResponseSupportedRenderers *guideRenderers in renderers) {
462+ YTIPivotBarRenderer *pivotBarRenderer = [guideRenderers pivotBarRenderer ];
463+ NSMutableArray <YTIPivotBarSupportedRenderers *> *items = [pivotBarRenderer itemsArray ];
464+ NSUInteger shortIndex = [items indexOfObjectPassingTest: ^BOOL (YTIPivotBarSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
465+ return [[[renderers pivotBarItemRenderer ] pivotIdentifier ] isEqualToString: @" FEshorts" ];
466+ }];
467+ if (shortIndex != NSNotFound ) {
468+ [items removeObjectAtIndex: shortIndex];
469+ NSUInteger exploreIndex = [items indexOfObjectPassingTest: ^BOOL (YTIPivotBarSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) {
470+ return [[[renderers pivotBarItemRenderer ] pivotIdentifier ] isEqualToString: [%c (YTIBrowseRequest) browseIDForExploreTab ]];
471+ }];
472+ if (exploreIndex == NSNotFound ) {
473+ YTIPivotBarSupportedRenderers *exploreTab = [%c (YTIPivotBarRenderer) pivotSupportedRenderersWithBrowseId: [%c (YTIBrowseRequest) browseIDForExploreTab ] title: @" Explore" iconType: 292 ];
474+ [items insertObject: exploreTab atIndex: 1 ];
475+ }
476+ }
477+ }
478+ }
479+ %hook YTGuideServiceCoordinator
480+ - (void )handleResponse:(YTIGuideResponse *)response withCompletion:(id )completion {
481+ replaceTab (response);
482+ %orig (response, completion);
483+ }
484+ - (void )handleResponse:(YTIGuideResponse *)response error:(id )error completion:(id )completion {
485+ replaceTab (response);
486+ %orig (response, error, completion);
487+ }
488+ %end
489+ %end
490+
491+ // BigYTMiniPlayer: https://github.com/Galactic-Dev/BigYTMiniPlayer
492+ %group Main
493+ %hook YTWatchMiniBarView
494+ -(void )setWatchMiniPlayerLayout:(int )arg1 {
495+ %orig (1 );
496+ }
497+ -(int )watchMiniPlayerLayout {
498+ return 1 ;
499+ }
500+ -(void )layoutSubviews {
501+ %orig ;
502+ self.frame = CGRectMake (([UIScreen mainScreen ].bounds .size .width - self.frame .size .width ), self.frame .origin .y , self.frame .size .width , self.frame .size .height );
503+ }
504+ %end
505+
506+ %hook YTMainAppVideoPlayerOverlayView
507+ -(BOOL )isUserInteractionEnabled {
508+ if ([[self _viewControllerForAncestor ].parentViewController.parentViewController isKindOfClass: %c (YTWatchMiniBarViewController)]) {
509+ return NO ;
510+ }
511+ return %orig ;
512+ }
513+ %end
514+ %end
515+
435516%ctor {
436517 %init ;
437518 if (oled ()) {
438- %init (gOLED );
519+ %init (gOLED );
439520 }
440- }
521+ if (ReExplore ()) {
522+ %init (gReExplore )
523+ }
524+ if (bigYTMiniPlayer () && (UIDevice.currentDevice .userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
525+ %init (Main)
526+ }
527+ }
0 commit comments