Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 2c5d054

Browse files
committed
added YTMiniPlayerEnabler by level3tjg
1 parent 3c33e6f commit 2c5d054

File tree

2 files changed

+86
-24
lines changed

2 files changed

+86
-24
lines changed

Settings.xm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern BOOL bigYTMiniPlayer();
1818
extern BOOL hideCC();
1919
extern BOOL hideAutoplaySwitch();
2020
extern BOOL castConfirm();
21+
extern BOOL ytMiniPlayer();
2122

2223
// Settings
2324
%hook YTAppSettingsPresentationData
@@ -36,6 +37,15 @@ extern BOOL castConfirm();
3637
%new - (void)updateuYouPlusSectionWithEntry:(id)entry {
3738
YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
3839

40+
YTSettingsSectionItem *ytMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Enable the Miniplayer for all videos" titleDescription:@"App restart is required."];
41+
ytMiniPlayer.hasSwitch = YES;
42+
ytMiniPlayer.switchVisible = YES;
43+
ytMiniPlayer.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"ytMiniPlayer_enabled"];
44+
ytMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
45+
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"];
46+
return YES;
47+
};
48+
3949
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."];
4050
castConfirm.hasSwitch = YES;
4151
castConfirm.switchVisible = YES;
@@ -126,7 +136,7 @@ extern BOOL castConfirm();
126136
return YES;
127137
};
128138

129-
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, hideAutoplaySwitch, hideCC, hideHUD, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]];
139+
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]];
130140
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
131141
}
132142

uYouPlus.xm

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#import <UIKit/UIKit.h>
22
#import <Foundation/Foundation.h>
33
#import <objc/runtime.h>
4+
#import <fishhook.h>
45
#import "Header.h"
56
#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
67
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
@@ -11,7 +12,7 @@
1112
#import "Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h"
1213
#import "Tweaks/YouTubeHeader/YTIPivotBarRenderer.h"
1314
#import "Tweaks/YouTubeHeader/YTIBrowseRequest.h"
14-
#import "Tweaks/YouTubeHeader/YTColorPalette.h"
15+
#import "Tweaks/YouTubeHeader/YTCommonColorPalette.h"
1516

1617
BOOL hideHUD() {
1718
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"];
@@ -46,15 +47,31 @@ BOOL hideAutoplaySwitch() {
4647
BOOL castConfirm() {
4748
return [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
4849
}
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+
}
4965

5066
// Hide CC / Autoplay switch
5167
%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; }
5875
}
5976
%end
6077

@@ -178,11 +195,19 @@ BOOL castConfirm() {
178195
- (void)showSurveyWithRenderer:(id)arg1 surveyParentResponder:(id)arg2 {}
179196
%end
180197

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+
181206
// OLED dark mode by BandarHL
182207
UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
183208

184209
%group gOLED
185-
%hook YTColorPalette
210+
%hook YTCommonColorPalette
186211
- (UIColor *)brandBackgroundSolid {
187212
if (self.pageStyle == 1) {
188213
return oledColor;
@@ -225,6 +250,15 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
225250
}
226251
%end
227252

253+
%hook YTInnerTubeCollectionViewController
254+
- (UIColor *)backgroundColor:(NSInteger)pageStyle {
255+
if (pageStyle == 1) {
256+
return oledColor;
257+
}
258+
return %orig;
259+
}
260+
%end
261+
228262
// Explore
229263
%hook ASScrollView
230264
- (void)didMoveToWindow {
@@ -290,7 +324,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
290324
if (isDarkMode()) {
291325
return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]);
292326
}
293-
return %orig;
327+
return %orig;
294328
}
295329
%end
296330

@@ -299,7 +333,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
299333
if (isDarkMode()) {
300334
return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]);
301335
}
302-
return %orig;
336+
return %orig;
303337
}
304338
%end
305339

@@ -318,7 +352,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
318352
if (isDarkMode()) {
319353
return %orig (oledColor);
320354
}
321-
return %orig;
355+
return %orig;
322356
}
323357
%end
324358

@@ -328,7 +362,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
328362
if (isDarkMode()) {
329363
return %orig (oledColor);
330364
}
331-
return %orig;
365+
return %orig;
332366
}
333367
%end
334368

@@ -337,13 +371,22 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
337371
if (isDarkMode()) {
338372
return %orig (oledColor);
339373
}
340-
return %orig;
374+
return %orig;
341375
}
342376
- (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment
343377
if (isDarkMode()) {
344378
return %orig ([UIColor whiteColor]);
345379
}
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;
347390
}
348391
%end
349392

@@ -352,7 +395,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
352395
if (isDarkMode()) {
353396
return %orig (oledColor);
354397
}
355-
return %orig;
398+
return %orig;
356399
}
357400
%end
358401

@@ -361,7 +404,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
361404
if (isDarkMode()) {
362405
return %orig (oledColor);
363406
}
364-
return %orig;
407+
return %orig;
365408
}
366409
%end
367410

@@ -392,17 +435,25 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
392435
}
393436
%end
394437

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()) {
401441
%orig;
442+
self.subviews[1].backgroundColor = oledColor;
402443
}
403-
return %orig;
404444
}
405445
%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
406457
%end
407458

408459
%group gOLEDKB // OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e
@@ -499,6 +550,7 @@ static void replaceTab(YTIGuideResponse *response) {
499550
%end
500551

501552
%ctor {
553+
rebind_symbols((struct rebinding[1]){{"class_addMethod", (void *)hook_class_addMethod, (void **)&orig_class_addMethod}}, 1);
502554
%init;
503555
if (oled()) {
504556
%init(gOLED);

0 commit comments

Comments
 (0)