forked from qnblackcat/uYouPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuYouPlus.xm
160 lines (149 loc) · 6.89 KB
/
uYouPlus.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
#import "Tweaks/YouTubeHeader/YTPlayerViewController.h"
#import "Tweaks/YouTubeHeader/YTWatchController.h"
@interface ABCSwitch : UISwitch
@end
@interface YTMainAppControlsOverlayView : UIView
@property(readonly, nonatomic) ABCSwitch *autonavSwitch;
@end
@interface YTPlayerViewController (YTAFS)
- (void)autoFullscreen;
@end
BOOL hideHUD() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"];
}
BOOL hideAutoplayswtich() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideautoplayswitch_enabled"];
}
BOOL autoFullScreen() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"autofull_enabled"];
}
BOOL noHoverCard() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hover_cards_enabled"];
}
//Settings
%hook YTSettingsViewController
- (void)setSectionItems:(NSMutableArray <YTSettingsSectionItem *>*)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 *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];
//
YTSettingsSectionItem *Oleditem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"OLED Dark mode (Experimental)" titleDescription:@"WARNING: You must enable YouTube's Dark theme before enabling OLED dark mode! 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 - 5];
//
YTSettingsSectionItem *hideAutoplaynext = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide Autoplay switch in the video player." titleDescription:@"App restart is required."];
hideAutoplaynext.hasSwitch = YES;
hideAutoplaynext.switchVisible = YES;
hideAutoplaynext.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideautoplayswitch_enabled"];
hideAutoplaynext.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideautoplayswitch_enabled"];
return YES;
};
[sectionItems insertObject:hideAutoplaynext atIndex:statsForNerdsIndex + 1];
//
YTSettingsSectionItem *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen" 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 + 1];
//
YTSettingsSectionItem *hoverCardItem = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Show End screens hover cards" 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 + 4];
}
}
%orig;
}
%end
// Hide HUD Messages. Credit: @LillieH001 - YouTube-Reborn: https://github.com/LillieH001/YouTube-Reborn/blob/b710e8598b797374995a46089b008b6e903a1ea4/Tweak.xm#L778
%hook YTHUDMessageView
- (id)initWithMessage:(id)arg1 dismissHandler:(id)arg2 {
if (hideHUD()) {
return NULL;
} else { return %orig; }
}
%end
// Hide Autoplay switch. Credit: @LillieH001 - YouTube-Reborn: https://github.com/LillieH001/YouTube-Reborn/blob/b710e8598b797374995a46089b008b6e903a1ea4/Tweak.xm#L1007
%hook YTMainAppControlsOverlayView
- (void)layoutSubviews {
if (hideAutoplayswtich()) {
%orig();
if(![[self autonavSwitch] isHidden]) [[self autonavSwitch] setHidden:YES];
} else { return %orig; }
}
%end
// YTAutoFullScreen: https://github.com/PoomSmart/YTAutoFullScreen/
%hook YTPlayerViewController
- (void)loadWithPlayerTransition:(id)arg1 playbackConfig:(id)arg2 {
if (autoFullScreen()) {
%orig;
[NSTimer scheduledTimerWithTimeInterval:0.75 target:self selector:@selector(autoFullscreen) userInfo:nil repeats:NO];
} else { return %orig; }
}
%new
- (void)autoFullscreen {
YTWatchController *watchController = [self valueForKey:@"_UIDelegate"];
[watchController showFullScreen];
}
%end
// YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards
%hook YTCreatorEndscreenView
- (void)setHidden:(BOOL)hidden {
if (!noHoverCard())
hidden = YES;
%orig;
}
%end
// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/12
%hook YTAdsInnerTubeContextDecorator
- (void)decorateContext:(id)arg1 { %orig(nil); }
%end
// YTClassicVideoQuality: https://github.com/PoomSmart/YTClassicVideoQuality
%hook YTVideoQualitySwitchControllerFactory
- (id)videoQualitySwitchControllerWithParentResponder:(id)responder {
Class originalClass = %c(YTVideoQualitySwitchOriginalController);
return originalClass ? [[originalClass alloc] initWithParentResponder:responder] : %orig;
}
%end
// YTNoCheckLocalNetwork: https://poomsmart.github.io/repo/depictions/ytnochecklocalnetwork.html
%hook YTHotConfig
- (BOOL)isPromptForLocalNetworkPermissionsEnabled { return NO; }
%end
// YTSystemAppearance: https://poomsmart.github.io/repo/depictions/ytsystemappearance.html
// YouRememberCaption: https://www.ios-repo-updates.com/repository/poomsmart/package/com.ps.youremembercaption/
%hook YTColdConfig
- (BOOL)shouldUseAppThemeSetting { return YES; }
- (BOOL)respectDeviceCaptionSetting { return NO; }
%end