fix crash on iPad cz i'm suck

This commit is contained in:
qnblackcat 2022-04-19 21:36:21 +07:00
parent 32bd36c423
commit 702406f87f

View file

@ -52,7 +52,7 @@ BOOL bigYTMiniPlayer() {
return item.settingItemId == 265; return item.settingItemId == 265;
}]; }];
if (statsForNerdsIndex != NSNotFound) { if (statsForNerdsIndex != NSNotFound) {
// //
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."]; 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.hasSwitch = YES;
hoverCardItem.switchVisible = YES; hoverCardItem.switchVisible = YES;
@ -61,17 +61,37 @@ BOOL bigYTMiniPlayer() {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hover_cards_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hover_cards_enabled"];
return YES; return YES;
}; };
[sectionItems insertObject:hoverCardItem atIndex:statsForNerdsIndex + 2]; [sectionItems insertObject:hoverCardItem atIndex:statsForNerdsIndex + 1];
// //
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."]; YTSettingsSectionItem *reExplore = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Replace Shorts tab with Explore tab (YTReExplore)" titleDescription:@"App restart is required."];
Oleditem.hasSwitch = YES; reExplore.hasSwitch = YES;
Oleditem.switchVisible = YES; reExplore.switchVisible = YES;
Oleditem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"oled_enabled"]; reExplore.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"reExplore_enabled"];
Oleditem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { reExplore.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oled_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"reExplore_enabled"];
return YES; return YES;
}; };
[sectionItems insertObject:Oleditem atIndex:statsForNerdsIndex - 11]; [sectionItems insertObject:reExplore atIndex:statsForNerdsIndex + 2];
//
YTSettingsSectionItem *bigYTMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Bigger miniplayer bar (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 *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 *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen (YTAutoFullScreen)" titleDescription:@"Autoplay videos at full screen."]; YTSettingsSectionItem *autoFUll = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Auto Full Screen (YTAutoFullScreen)" titleDescription:@"Autoplay videos at full screen."];
autoFUll.hasSwitch = YES; autoFUll.hasSwitch = YES;
@ -82,36 +102,16 @@ BOOL bigYTMiniPlayer() {
return YES; return YES;
}; };
[sectionItems insertObject:autoFUll atIndex:statsForNerdsIndex + 2]; [sectionItems insertObject:autoFUll atIndex:statsForNerdsIndex + 2];
// //
YTSettingsSectionItem *hideHUD = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Hide HUD Messages" titleDescription:@"Example: CC is turned on/off, Video loop is on,... App restart is required."]; 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."];
hideHUD.hasSwitch = YES; Oleditem.hasSwitch = YES;
hideHUD.switchVisible = YES; Oleditem.switchVisible = YES;
hideHUD.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"]; Oleditem.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"oled_enabled"];
hideHUD.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { Oleditem.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideHUD_enabled"]; [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"oled_enabled"];
return YES; return YES;
}; };
[sectionItems insertObject:hideHUD atIndex:statsForNerdsIndex + 2]; [sectionItems insertObject:Oleditem atIndex:statsForNerdsIndex + 1];
//
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 + 4];
//
YTSettingsSectionItem *bigYTMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Bigger miniplayer bar (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 + 4];
} }
} }
%orig; %orig;
@ -533,9 +533,9 @@ static void replaceTab(YTIGuideResponse *response) {
%init(gOLED); %init(gOLED);
} }
if (ReExplore()) { if (ReExplore()) {
%init(gReExplore) %init(gReExplore)
} }
if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) {
%init(Main) %init(Main)
} }
} }