#import "Header.h" #import #import #import "../YouTubeHeader/YTHotConfig.h" #import "../YouTubeHeader/YTSettingsViewController.h" #import "../YouTubeHeader/YTSettingsSectionItem.h" #import "../YouTubeHeader/YTSettingsSectionItemManager.h" #define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil] extern BOOL UseVP9(); NSBundle *YTUHDBundle() { static NSBundle *bundle = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"YTUHD" ofType:@"bundle"]; if (tweakBundlePath) bundle = [NSBundle bundleWithPath:tweakBundlePath]; else bundle = [NSBundle bundleWithPath:ROOT_PATH_NS(@"/Library/Application Support/YTUHD.bundle")]; }); return bundle; } %hook YTSettingsSectionItemManager - (void)updateVideoQualitySectionWithEntry:(id)entry { YTHotConfig *hotConfig; @try { hotConfig = [self valueForKey:@"_hotConfig"]; } @catch (id ex) { hotConfig = [self.gimme instanceForType:%c(YTHotConfig)]; } YTIMediaQualitySettingsHotConfig *mediaQualitySettingsHotConfig = [hotConfig hotConfigGroup].mediaHotConfig.mediaQualitySettingsHotConfig; BOOL defaultValue = mediaQualitySettingsHotConfig.enablePersistentVideoQualitySettings; mediaQualitySettingsHotConfig.enablePersistentVideoQualitySettings = YES; %orig; mediaQualitySettingsHotConfig.enablePersistentVideoQualitySettings = defaultValue; } %end %hook YTSettingsViewController - (void)setSectionItems:(NSMutableArray *)sectionItems forCategory:(NSInteger)category title:(NSString *)title titleDescription:(NSString *)titleDescription headerHidden:(BOOL)headerHidden { if (category == 14) { NSBundle *tweakBundle = YTUHDBundle(); BOOL hasVP9 = VTIsHardwareDecodeSupported(kCMVideoCodecType_VP9); YTSettingsSectionItem *vp9 = [%c(YTSettingsSectionItem) switchItemWithTitle:LOC(@"USE_VP9") titleDescription:[NSString stringWithFormat:@"%@\n\n%@: %d", LOC(@"USE_VP9_DESC"), LOC(@"HW_VP9_SUPPORT"), hasVP9] accessibilityIdentifier:nil switchOn:UseVP9() switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:UseVP9Key]; return YES; } settingItemId:0]; [sectionItems addObject:vp9]; } %orig; } %end