fix app crash upon launching on some devices

This commit is contained in:
qnblackcat 2022-05-17 09:44:54 +07:00
parent f63cfa8b43
commit 5e9d719882

View file

@ -1,7 +1,6 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <fishhook.h>
#import "Header.h"
#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h"
#import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h"
@ -53,15 +52,12 @@ BOOL ytMiniPlayer() {
// 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);
%hook YTWatchMiniBarViewController
- (void)updateMiniBarPlayerStateFromRenderer {
if (ytMiniPlayer()) {}
else { return %orig; }
}
%end
// Hide CC / Autoplay switch
%hook YTMainAppControlsOverlayView
@ -550,7 +546,6 @@ static void replaceTab(YTIGuideResponse *response) {
%end
%ctor {
rebind_symbols((struct rebinding[1]){{"class_addMethod", (void *)hook_class_addMethod, (void **)&orig_class_addMethod}}, 1);
%init;
if (oled()) {
%init(gOLED);