-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tweak.x
77 lines (62 loc) · 2.75 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
#import <YouTubeHeader/YTSearchableSettingsViewController.h>
#import <YouTubeHeader/YTSettingsPickerViewController.h>
#import <YouTubeHeader/YTSettingsViewController.h>
#import <YouTubeHeader/YTSettingsSectionItem.h>
#import <YouTubeHeader/YTSettingsSectionItemManager.h>
#import <rootless.h>
#define TweakName @"YTIcons"
static const NSInteger YTIconsSection = 'ytic';
@interface YTSettingsSectionItemManager (Tweak)
- (void)updateYTIconsSectionWithEntry:(id)entry;
@end
%hook YTSettingsViewController
- (void)loadWithModel:(id)model fromView:(UIView *)view {
%orig;
if ([[self valueForKey:@"_detailsCategoryID"] integerValue] == YTIconsSection)
[self setValue:@(YES) forKey:@"_shouldShowSearchBar"];
}
%end
%hook YTAppSettingsPresentationData
+ (NSArray *)settingsCategoryOrder {
NSArray *order = %orig;
NSMutableArray *mutableOrder = [order mutableCopy];
[mutableOrder insertObject:@(YTIconsSection) atIndex:0];
return mutableOrder;
}
%end
%hook YTSettingsSectionItemManager
%new(v@:@)
- (void)updateYTIconsSectionWithEntry:(id)entry {
NSMutableArray *sectionItems = [NSMutableArray array];
Class YTSettingsSectionItemClass = %c(YTSettingsSectionItem);
YTSettingsViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
for (NSInteger i = 0; i < 1500; ++i) {
@try {
YTIIcon *icon = [%c(YTIIcon) new];
icon.iconType = i;
NSString *iconDescription = [icon description];
NSRange range = [iconDescription rangeOfString:@"icon_type: "];
if (range.location != NSNotFound)
iconDescription = [iconDescription substringFromIndex:range.location + range.length];
NSString *title = [NSString stringWithFormat:@"Option %ld - %@", (long)i, iconDescription];
YTSettingsSectionItem *option = [YTSettingsSectionItemClass itemWithTitle:title
accessibilityIdentifier:nil
detailTextBlock:NULL
selectBlock:NULL];
option.settingIcon = icon;
[sectionItems addObject:option];
} @catch (id ex) {}
}
if ([settingsViewController respondsToSelector:@selector(setSectionItems:forCategory:title:icon:titleDescription:headerHidden:)])
[settingsViewController setSectionItems:sectionItems forCategory:YTIconsSection title:TweakName icon:nil titleDescription:nil headerHidden:NO];
else
[settingsViewController setSectionItems:sectionItems forCategory:YTIconsSection title:TweakName titleDescription:nil headerHidden:NO];
}
- (void)updateSectionForCategory:(NSUInteger)category withEntry:(id)entry {
if (category == YTIconsSection) {
[self updateYTIconsSectionWithEntry:entry];
return;
}
%orig;
}
%end