-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTweak.x
86 lines (71 loc) · 2.63 KB
/
Tweak.x
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
#import <YouTubeHeader/YTIIcon.h>
#import <YouTubeHeader/YTSettingsGroupData.h>
#import <PSHeader/Misc.h>
#define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil]
@interface YTSettingsGroupData (YouGroupSettings)
+ (NSMutableArray <NSNumber *> *)tweaks;
@end
static const NSInteger TweakGroup = 'psyt';
static const NSInteger YTIcons = 'ytic';
static const NSInteger YouChooseQuality = 'ycql';
NSBundle *TweakBundle() {
static NSBundle *bundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"YouGroupSettings" ofType:@"bundle"];
bundle = [NSBundle bundleWithPath:tweakBundlePath ?: PS_ROOT_PATH_NS(@"/Library/Application Support/YouGroupSettings.bundle")];
});
return bundle;
}
%hook YTAppSettingsGroupPresentationData
+ (NSArray <YTSettingsGroupData *> *)orderedGroups {
NSArray <YTSettingsGroupData *> *groups = %orig;
NSMutableArray <YTSettingsGroupData *> *mutableGroups = [groups mutableCopy];
YTSettingsGroupData *tweakGroup = [[%c(YTSettingsGroupData) alloc] initWithGroupType:TweakGroup];
[mutableGroups insertObject:tweakGroup atIndex:0];
return mutableGroups;
}
%end
%hook YTSettingsGroupData
%new(@@:)
+ (NSMutableArray <NSNumber *> *)tweaks {
static NSMutableArray <NSNumber *> *tweaks = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
tweaks = [NSMutableArray new];
[tweaks addObjectsFromArray:@[
@(404), // YTABConfig
@(YTIcons), // YTIcons
@(500), // uYou+,
@(517), // DontEatMyContent
@(1080), // Return YouTube Dislike
@(YouChooseQuality),
@(200), // YouPiP
@(2168), // YTHoldForSpeed
@(1222), // YTVideoOverlay
]];
});
return tweaks;
}
- (NSString *)titleForSettingGroupType:(NSUInteger)type {
if (type == TweakGroup) {
NSBundle *tweakBundle = TweakBundle();
return LOC(@"TWEAKS");
}
return %orig;
}
- (NSArray <NSNumber *> *)orderedCategoriesForGroupType:(NSUInteger)type {
if (type == TweakGroup)
return [[self class] tweaks];
return %orig;
}
%end
%hook YTSettingsViewController
- (void)setSectionItems:(NSMutableArray *)sectionItems forCategory:(NSInteger)category title:(NSString *)title icon:(YTIIcon *)icon titleDescription:(NSString *)titleDescription headerHidden:(BOOL)headerHidden {
if (icon == nil && [[%c(YTSettingsGroupData) tweaks] containsObject:@(category)]) {
icon = [%c(YTIIcon) new];
icon.iconType = YT_SETTINGS;
}
%orig;
}
%end