added YTMiniPlayerEnabler by level3tjg

This commit is contained in:
qnblackcat
2022-05-16 11:56:29 +07:00
parent 3c33e6fed0
commit 2c5d0545d7
2 changed files with 86 additions and 24 deletions
+11 -1
View File
@@ -18,6 +18,7 @@ extern BOOL bigYTMiniPlayer();
extern BOOL hideCC(); extern BOOL hideCC();
extern BOOL hideAutoplaySwitch(); extern BOOL hideAutoplaySwitch();
extern BOOL castConfirm(); extern BOOL castConfirm();
extern BOOL ytMiniPlayer();
// Settings // Settings
%hook YTAppSettingsPresentationData %hook YTAppSettingsPresentationData
@@ -36,6 +37,15 @@ extern BOOL castConfirm();
%new - (void)updateuYouPlusSectionWithEntry:(id)entry { %new - (void)updateuYouPlusSectionWithEntry:(id)entry {
YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"]; YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"];
YTSettingsSectionItem *ytMiniPlayer = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Enable the Miniplayer for all videos" titleDescription:@"App restart is required."];
ytMiniPlayer.hasSwitch = YES;
ytMiniPlayer.switchVisible = YES;
ytMiniPlayer.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"ytMiniPlayer_enabled"];
ytMiniPlayer.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) {
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"ytMiniPlayer_enabled"];
return YES;
};
YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."]; YTSettingsSectionItem *castConfirm = [[%c(YTSettingsSectionItem) alloc] initWithTitle:@"Confirm alert before casting (YTCastConfirm)" titleDescription:@"Show a confirm alert before casting to prevent accidentally hijacking TV."];
castConfirm.hasSwitch = YES; castConfirm.hasSwitch = YES;
castConfirm.switchVisible = YES; castConfirm.switchVisible = YES;
@@ -126,7 +136,7 @@ extern BOOL castConfirm();
return YES; return YES;
}; };
NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, hideAutoplaySwitch, hideCC, hideHUD, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]]; NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hoverCardItem, bigYTMiniPlayer, oledKeyBoard, oledDarkMode,reExplore]];
[delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO]; [delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO];
} }
+74 -22
View File
@@ -1,6 +1,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#import <fishhook.h>
#import "Header.h" #import "Header.h"
#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h" #import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h" #import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
@@ -11,7 +12,7 @@
#import "Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h" #import "Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h"
#import "Tweaks/YouTubeHeader/YTIPivotBarRenderer.h" #import "Tweaks/YouTubeHeader/YTIPivotBarRenderer.h"
#import "Tweaks/YouTubeHeader/YTIBrowseRequest.h" #import "Tweaks/YouTubeHeader/YTIBrowseRequest.h"
#import "Tweaks/YouTubeHeader/YTColorPalette.h" #import "Tweaks/YouTubeHeader/YTCommonColorPalette.h"
BOOL hideHUD() { BOOL hideHUD() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"]; return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"];
@@ -46,15 +47,31 @@ BOOL hideAutoplaySwitch() {
BOOL castConfirm() { BOOL castConfirm() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"]; return [[NSUserDefaults standardUserDefaults] boolForKey:@"castConfirm_enabled"];
} }
BOOL ytMiniPlayer() {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"ytMiniPlayer_enabled"];
}
// Tweaks
// YTMiniPlayerEnabler: https://github.com/level3tjg/YTMiniplayerEnabler/
static BOOL (*orig_class_addMethod)(Class, SEL, IMP, const char *);
static BOOL hook_class_addMethod(Class cls, SEL name, IMP imp, const char *types) {
if (ytMiniPlayer() && [cls isEqual:%c(YTIMiniplayerRenderer)] && [NSStringFromSelector(name) hasPrefix:@"has"]) {
imp = imp_implementationWithBlock(^BOOL(id self, SEL _cmd) {
return NO;
});
}
return orig_class_addMethod(cls, name, imp, types);
}
// Hide CC / Autoplay switch // Hide CC / Autoplay switch
%hook YTMainAppControlsOverlayView %hook YTMainAppControlsOverlayView
- (void)layoutSubviews { - (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC?!
%orig; if (hideCC()) { return %orig(NO); }
if (hideAutoplaySwitch()) else { return %orig; }
MSHookIvar<UIView *>(self, "_autonavSwitch").hidden = YES; }
if (hideCC()) - (void)setAutoplaySwitchButtonRenderer:(id)arg1 {
MSHookIvar<UIView *>(self, "_closedCaptionsOrSubtitlesButton").hidden = YES; if (hideAutoplaySwitch()) {}
else { return %orig; }
} }
%end %end
@@ -178,11 +195,19 @@ BOOL castConfirm() {
- (void)showSurveyWithRenderer:(id)arg1 surveyParentResponder:(id)arg2 {} - (void)showSurveyWithRenderer:(id)arg1 surveyParentResponder:(id)arg2 {}
%end %end
// Hide the download playlist button of uYou cuz it's broken
%hook YTPlaylistHeaderViewController
- (void)viewDidLoad {
%orig;
self.downloadsButton.hidden = YES;
}
%end
// OLED dark mode by BandarHL // OLED dark mode by BandarHL
UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
%group gOLED %group gOLED
%hook YTColorPalette %hook YTCommonColorPalette
- (UIColor *)brandBackgroundSolid { - (UIColor *)brandBackgroundSolid {
if (self.pageStyle == 1) { if (self.pageStyle == 1) {
return oledColor; return oledColor;
@@ -225,6 +250,15 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
} }
%end %end
%hook YTInnerTubeCollectionViewController
- (UIColor *)backgroundColor:(NSInteger)pageStyle {
if (pageStyle == 1) {
return oledColor;
}
return %orig;
}
%end
// Explore // Explore
%hook ASScrollView %hook ASScrollView
- (void)didMoveToWindow { - (void)didMoveToWindow {
@@ -290,7 +324,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]); return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]);
} }
return %orig; return %orig;
} }
%end %end
@@ -299,7 +333,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]); return %orig([UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.9]);
} }
return %orig; return %orig;
} }
%end %end
@@ -318,7 +352,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig (oledColor); return %orig (oledColor);
} }
return %orig; return %orig;
} }
%end %end
@@ -328,7 +362,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig (oledColor); return %orig (oledColor);
} }
return %orig; return %orig;
} }
%end %end
@@ -337,13 +371,22 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig (oledColor); return %orig (oledColor);
} }
return %orig; return %orig;
} }
- (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment - (void)setTextColor:(UIColor *)color { // fix black text in #Shorts video's comment
if (isDarkMode()) { if (isDarkMode()) {
return %orig ([UIColor whiteColor]); return %orig ([UIColor whiteColor]);
} }
return %orig; return %orig;
}
%end
%hook YTFormattedStringLabel // YT is werid...
- (void)setBackgroundColor:(UIColor *)color {
if (isDarkMode()) {
return %orig ([UIColor clearColor]);
}
return %orig;
} }
%end %end
@@ -352,7 +395,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig (oledColor); return %orig (oledColor);
} }
return %orig; return %orig;
} }
%end %end
@@ -361,7 +404,7 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
if (isDarkMode()) { if (isDarkMode()) {
return %orig (oledColor); return %orig (oledColor);
} }
return %orig; return %orig;
} }
%end %end
@@ -392,17 +435,25 @@ UIColor* oledColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
} }
%end %end
// this sucks :/ %hook ASWAppSwitcherCollectionViewCell
%hook UIView - (void)didMoveToWindow {
- (void)setBackgroundColor:(UIColor *)color {
if (isDarkMode()) { if (isDarkMode()) {
if ([self.nextResponder isKindOfClass:%c(YTHUDMessageView)]) { color = oledColor; }
if ([self.nextResponder isKindOfClass:%c(ASWAppSwitcherCollectionViewCell)]) { color = oledColor; } // Open link with...
%orig; %orig;
self.subviews[1].backgroundColor = oledColor;
} }
return %orig;
} }
%end %end
// this sucks :/
// %hook UIView
// - (void)setBackgroundColor:(UIColor *)color {
// if (isDarkMode()) {
// if ([self.nextResponder isKindOfClass:%c(YTHUDMessageView)]) { color = oledColor; }
// %orig;
// }
// return %orig;
// }
// %end
%end %end
%group gOLEDKB // OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e %group gOLEDKB // OLED keyboard by @ichitaso <3 - http://gist.github.com/ichitaso/935100fd53a26f18a9060f7195a1be0e
@@ -499,6 +550,7 @@ static void replaceTab(YTIGuideResponse *response) {
%end %end
%ctor { %ctor {
rebind_symbols((struct rebinding[1]){{"class_addMethod", (void *)hook_class_addMethod, (void **)&orig_class_addMethod}}, 1);
%init; %init;
if (oled()) { if (oled()) {
%init(gOLED); %init(gOLED);