1
1
#import < UIKit/UIKit.h>
2
2
#import < Foundation/Foundation.h>
3
3
#import < objc/runtime.h>
4
+ #import < fishhook.h>
4
5
#import " Header.h"
5
6
#import " Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
6
7
#import " Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
11
12
#import " Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h"
12
13
#import " Tweaks/YouTubeHeader/YTIPivotBarRenderer.h"
13
14
#import " Tweaks/YouTubeHeader/YTIBrowseRequest.h"
14
- #import " Tweaks/YouTubeHeader/YTColorPalette .h"
15
+ #import " Tweaks/YouTubeHeader/YTCommonColorPalette .h"
15
16
16
17
BOOL hideHUD () {
17
18
return [[NSUserDefaults standardUserDefaults ] boolForKey: @" hideHUD_enabled" ];
@@ -46,15 +47,31 @@ BOOL hideAutoplaySwitch() {
46
47
BOOL castConfirm () {
47
48
return [[NSUserDefaults standardUserDefaults ] boolForKey: @" castConfirm_enabled" ];
48
49
}
50
+ BOOL ytMiniPlayer () {
51
+ return [[NSUserDefaults standardUserDefaults ] boolForKey: @" ytMiniPlayer_enabled" ];
52
+ }
53
+
54
+ // Tweaks
55
+ // YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
56
+ static BOOL (*orig_class_addMethod)(Class , SEL , IMP , const char *);
57
+ static BOOL hook_class_addMethod (Class cls, SEL name, IMP imp, const char *types) {
58
+ if (ytMiniPlayer () && [cls isEqual: %c (YTIMiniplayerRenderer)] && [NSStringFromSelector (name) hasPrefix: @" has" ]) {
59
+ imp = imp_implementationWithBlock (^BOOL (id self, SEL _cmd) {
60
+ return NO ;
61
+ });
62
+ }
63
+ return orig_class_addMethod (cls, name, imp, types);
64
+ }
49
65
50
66
// Hide CC / Autoplay switch
51
67
%hook YTMainAppControlsOverlayView
52
- - (void )layoutSubviews {
53
- %orig ;
54
- if (hideAutoplaySwitch ())
55
- MSHookIvar<UIView *>(self, " _autonavSwitch" ).hidden = YES ;
56
- if (hideCC ())
57
- MSHookIvar<UIView *>(self, " _closedCaptionsOrSubtitlesButton" ).hidden = YES ;
68
+ - (void )setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL )arg1 { // hide CC?!
69
+ if (hideCC ()) { return %orig (NO ); }
70
+ else { return %orig ; }
71
+ }
72
+ - (void )setAutoplaySwitchButtonRenderer:(id )arg1 {
73
+ if (hideAutoplaySwitch ()) {}
74
+ else { return %orig ; }
58
75
}
59
76
%end
60
77
@@ -178,11 +195,19 @@ BOOL castConfirm() {
178
195
- (void )showSurveyWithRenderer:(id )arg1 surveyParentResponder:(id )arg2 {}
179
196
%end
180
197
198
+ // Hide the download playlist button of uYou cuz it's broken
199
+ %hook YTPlaylistHeaderViewController
200
+ - (void )viewDidLoad {
201
+ %orig ;
202
+ self.downloadsButton .hidden = YES ;
203
+ }
204
+ %end
205
+
181
206
// OLED dark mode by BandarHL
182
207
UIColor* oledColor = [UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 1.0 ];
183
208
184
209
%group gOLED
185
- %hook YTColorPalette
210
+ %hook YTCommonColorPalette
186
211
- (UIColor *)brandBackgroundSolid {
187
212
if (self.pageStyle == 1 ) {
188
213
return oledColor;
@@ -225,6 +250,15 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
225
250
}
226
251
%end
227
252
253
+ %hook YTInnerTubeCollectionViewController
254
+ - (UIColor *)backgroundColor:(NSInteger )pageStyle {
255
+ if (pageStyle == 1 ) {
256
+ return oledColor;
257
+ }
258
+ return %orig ;
259
+ }
260
+ %end
261
+
228
262
// Explore
229
263
%hook ASScrollView
230
264
- (void )didMoveToWindow {
@@ -290,7 +324,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
290
324
if (isDarkMode ()) {
291
325
return %orig ([UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0.9 ]);
292
326
}
293
- return %orig ;
327
+ return %orig ;
294
328
}
295
329
%end
296
330
@@ -299,7 +333,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
299
333
if (isDarkMode ()) {
300
334
return %orig ([UIColor colorWithRed: 0.0 green: 0.0 blue: 0.0 alpha: 0.9 ]);
301
335
}
302
- return %orig ;
336
+ return %orig ;
303
337
}
304
338
%end
305
339
@@ -318,7 +352,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
318
352
if (isDarkMode ()) {
319
353
return %orig (oledColor);
320
354
}
321
- return %orig ;
355
+ return %orig ;
322
356
}
323
357
%end
324
358
@@ -328,7 +362,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
328
362
if (isDarkMode ()) {
329
363
return %orig (oledColor);
330
364
}
331
- return %orig ;
365
+ return %orig ;
332
366
}
333
367
%end
334
368
@@ -337,13 +371,22 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
337
371
if (isDarkMode ()) {
338
372
return %orig (oledColor);
339
373
}
340
- return %orig ;
374
+ return %orig ;
341
375
}
342
376
- (void )setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment
343
377
if (isDarkMode ()) {
344
378
return %orig ([UIColor whiteColor ]);
345
379
}
346
- return %orig ;
380
+ return %orig ;
381
+ }
382
+ %end
383
+
384
+ %hook YTFormattedStringLabel // YT is werid...
385
+ - (void )setBackgroundColor:(UIColor *)color {
386
+ if (isDarkMode ()) {
387
+ return %orig ([UIColor clearColor ]);
388
+ }
389
+ return %orig ;
347
390
}
348
391
%end
349
392
@@ -352,7 +395,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
352
395
if (isDarkMode ()) {
353
396
return %orig (oledColor);
354
397
}
355
- return %orig ;
398
+ return %orig ;
356
399
}
357
400
%end
358
401
@@ -361,7 +404,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
361
404
if (isDarkMode ()) {
362
405
return %orig (oledColor);
363
406
}
364
- return %orig ;
407
+ return %orig ;
365
408
}
366
409
%end
367
410
@@ -392,17 +435,25 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
392
435
}
393
436
%end
394
437
395
- // this sucks :/
396
- %hook UIView
397
- - (void )setBackgroundColor:(UIColor *)color {
398
- if (isDarkMode ()) {
399
- if ([self .nextResponder isKindOfClass: %c (YTHUDMessageView)]) { color = oledColor; }
400
- if ([self .nextResponder isKindOfClass: %c (ASWAppSwitcherCollectionViewCell)]) { color = oledColor; } // Open link with...
438
+ %hook ASWAppSwitcherCollectionViewCell
439
+ - (void )didMoveToWindow {
440
+ if (isDarkMode ()) {
401
441
%orig ;
442
+ self.subviews [1 ].backgroundColor = oledColor;
402
443
}
403
- return %orig ;
404
444
}
405
445
%end
446
+
447
+ // this sucks :/
448
+ // %hook UIView
449
+ // - (void)setBackgroundColor:(UIColor *)color {
450
+ // if (isDarkMode()) {
451
+ // if ([self.nextResponder isKindOfClass:%c(YTHUDMessageView)]) { color = oledColor; }
452
+ // %orig;
453
+ // }
454
+ // return %orig;
455
+ // }
456
+ // %end
406
457
%end
407
458
408
459
%group gOLEDKB // OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e
@@ -499,6 +550,7 @@ static void replaceTab(YTIGuideResponse *response) {
499
550
%end
500
551
501
552
%ctor {
553
+ rebind_symbols ((struct rebinding[1 ]){{" class_addMethod" , (void *)hook_class_addMethod, (void **)&orig_class_addMethod}}, 1 );
502
554
%init ;
503
555
if (oled ()) {
504
556
%init (gOLED );
0 commit comments