From 1c4cc58be994037e619bd0fd9f75a69130069a8d Mon Sep 17 00:00:00 2001 From: arichorn <78001398+arichorn@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:26:21 -0500 Subject: [PATCH 1/2] Update LowContrastMode.xm --- Source/LowContrastMode.xm | 61 +++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/Source/LowContrastMode.xm b/Source/LowContrastMode.xm index 0fce450..5858ede 100644 --- a/Source/LowContrastMode.xm +++ b/Source/LowContrastMode.xm @@ -38,7 +38,7 @@ static BOOL pinkContrastMode() { return IsEnabled(@"lowContrastMode_enabled") && colorContrastMode() == 8; } -%group gLowContrastMode // Low Contrast Mode v1.3.0 (Compatible with only v15.02.1-present) +%group gLowContrastMode // Low Contrast Mode v1.3.1 (Compatible with only YouTube v16.05.7-v17.38.10) %hook UIColor + (UIColor *)whiteColor { // Dark Theme Color return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00]; @@ -47,7 +47,6 @@ static BOOL pinkContrastMode() { return [UIColor colorWithRed: 0.56 green: 0.56 blue: 0.56 alpha: 1.00]; } %end - %hook UILabel + (void)load { @autoreleasepool { @@ -55,7 +54,6 @@ static BOOL pinkContrastMode() { } } %end - %hook YTCommonColorPalette - (UIColor *)textPrimary { if (self.pageStyle == 1) { @@ -70,49 +68,40 @@ static BOOL pinkContrastMode() { return [UIColor colorWithRed: 0.38 green: 0.38 blue: 0.38 alpha: 1.00]; // Light Theme } %end - %hook YTCollectionView - (void)setTintColor:(UIColor *)color { return isDarkMode() ? %orig([UIColor whiteColor]) : %orig; } %end - %hook LOTAnimationView - (void) setTintColor:(UIColor *)tintColor { tintColor = [UIColor whiteColor]; %orig(tintColor); } %end - %hook ASTextNode - (NSAttributedString *)attributedString { NSAttributedString *originalAttributedString = %orig; - NSMutableAttributedString *newAttributedString = [originalAttributedString mutableCopy]; [newAttributedString addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, newAttributedString.length)]; - return newAttributedString; } %end - %hook ASTextFieldNode - (void)setTextColor:(UIColor *)textColor { %orig([UIColor whiteColor]); } %end - %hook ASTextView - (void)setTextColor:(UIColor *)textColor { %orig([UIColor whiteColor]); } %end - %hook ASButtonNode - (void)setTextColor:(UIColor *)textColor { %orig([UIColor whiteColor]); } %end - %hook UIButton - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state { %log; @@ -120,7 +109,13 @@ static BOOL pinkContrastMode() { %orig(color, state); } %end - +%hook UIBarButtonItem +- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { + NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; + [modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; + %orig(modifiedAttributes, state); +} +%end %hook UILabel - (void)setTextColor:(UIColor *)textColor { %log; @@ -128,7 +123,6 @@ static BOOL pinkContrastMode() { %orig(textColor); } %end - %hook UITextField - (void)setTextColor:(UIColor *)textColor { %log; @@ -136,7 +130,6 @@ static BOOL pinkContrastMode() { %orig(textColor); } %end - %hook UITextView - (void)setTextColor:(UIColor *)textColor { %log; @@ -144,17 +137,47 @@ static BOOL pinkContrastMode() { %orig(textColor); } %end - +%hook UISearchBar +- (void)setTextColor:(UIColor *)textColor { + textColor = [UIColor whiteColor]; + %orig(textColor); +} +%end +%hook UISegmentedControl +- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { + NSMutableDictionary *modifiedAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; + [modifiedAttributes setObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; + %orig(modifiedAttributes, state); +} +%end %hook VideoTitleLabel - (void)setTextColor:(UIColor *)textColor { textColor = [UIColor whiteColor]; %orig(textColor); } %end - %hook _ASDisplayView -- (UIColor *)textColor { - return [UIColor whiteColor]; +- (void)didMoveToWindow { + %orig; + UILabel *label = [self findLabelInSubviews:self.subviews]; + if (label) { + [self customizeLabel:label]; + } +} +- (UILabel *)findLabelInSubviews:(NSArray *)subviews { + for (UIView *subview in subviews) { + if ([subview isKindOfClass:[UILabel class]]) { + return (UILabel *)subview; + } + UILabel *label = [self findLabelInSubviews:subview.subviews]; + if (label) { + return label; + } + } + return nil; +} +- (void)customizeLabel:(UILabel *)label { + label.textColor = [UIColor whiteColor]; } %end %end From 549ff802e88bdff1e532c609852be266c79ed536 Mon Sep 17 00:00:00 2001 From: arichorn <78001398+arichorn@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:29:07 -0500 Subject: [PATCH 2/2] Update Header.h --- Header.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Header.h b/Header.h index 01826e4..5c7fc2e 100644 --- a/Header.h +++ b/Header.h @@ -129,6 +129,8 @@ @end @interface _ASDisplayView : UIView +- (UILabel *)findLabelInSubviews:(NSArray *)subviews; +- (void)customizeLabel:(UILabel *)label; @end @interface YTCommentDetailHeaderCell : UIView