From a82da65f63bd559fa3f9438db7c65dfb85ea728a Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Mon, 17 Apr 2023 13:36:16 +0700 Subject: [PATCH] remove unused patch for uYou --- Settings.xm | 88 ++--------------- uYouPlus.xm | 280 ++++------------------------------------------------ 2 files changed, 26 insertions(+), 342 deletions(-) diff --git a/Settings.xm b/Settings.xm index 8edba02..82565f3 100644 --- a/Settings.xm +++ b/Settings.xm @@ -59,16 +59,6 @@ extern NSBundle *uYouPlusBundle(); # pragma mark - VideoPlayer YTSettingsSectionItem *videoPlayerGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"VIDEO_PLAYER_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { NSArray *rows = @[ - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"AUTO_FULLSCREEN") - titleDescription:LOC(@"AUTO_FULLSCREEN_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"autoFull_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"autoFull_enabled"]; - return YES; - } - settingItemId:0], - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK") titleDescription:LOC(@"DISABLE_DOUBLE_TAP_TO_SEEK_DESC") accessibilityIdentifier:nil @@ -199,15 +189,15 @@ extern NSBundle *uYouPlusBundle(); } settingItemId:0], - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RED_PROGRESS_BAR") - titleDescription:LOC(@"RED_PROGRESS_BAR_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"redProgressBar_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"redProgressBar_enabled"]; - return YES; - } - settingItemId:0], + // [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"RED_PROGRESS_BAR") + // titleDescription:LOC(@"RED_PROGRESS_BAR_DESC") + // accessibilityIdentifier:nil + // switchOn:IsEnabled(@"redProgressBar_enabled") + // switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { + // [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"redProgressBar_enabled"]; + // return YES; + // } + // settingItemId:0], [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_HOVER_CARD") titleDescription:LOC(@"HIDE_HOVER_CARD_DESC") @@ -248,56 +238,6 @@ extern NSBundle *uYouPlusBundle(); # pragma mark - Shorts Controls Overlay Options YTSettingsSectionItem *shortsControlOverlayGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"SHORTS_CONTROLS_OVERLAY_OPTIONS") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { NSArray *rows = @[ - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SHORTS_CHANNEL_AVATAR") - titleDescription:LOC(@"HIDE_SHORTS_CHANNEL_AVATAR_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideShortsChannelAvatar_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideShortsChannelAvatar_enabled"]; - return YES; - } - settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SHORTS_DISLIKE_BUTTON") - titleDescription:LOC(@"HIDE_SHORTS_DISLIKE_BUTTON_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideShortsDislikeButton_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideShortsDislikeButton_enabled"]; - return YES; - } - settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SHORTS_COMMENT_BUTTON") - titleDescription:LOC(@"HIDE_SHORTS_COMMENT_BUTTON_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideShortsCommentButton_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideShortsCommentButton_enabled"]; - return YES; - } - settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SHORTS_REMIX_BUTTON") - titleDescription:LOC(@"HIDE_SHORTS_REMIX_BUTTON_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideShortsRemixButton_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideShortsRemixButton_enabled"]; - return YES; - } - settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SHORTS_SHARE_BUTTON") - titleDescription:LOC(@"HIDE_SHORTS_SHARE_BUTTON_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideShortsShareButton_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideShortsShareButton_enabled"]; - return YES; - } - settingItemId:0], - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_SUPER_THANKS") titleDescription:LOC(@"HIDE_SUPER_THANKS_DESC") accessibilityIdentifier:nil @@ -317,16 +257,6 @@ extern NSBundle *uYouPlusBundle(); return YES; } settingItemId:0], - - [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"HIDE_UYOU_SHORTS_DOWNLOAD_BUTTON") - titleDescription:LOC(@"HIDE_UYOU_SHORTS_DOWNLOAD_BUTTON_DESC") - accessibilityIdentifier:nil - switchOn:IsEnabled(@"hideuYouShortsDownloadButton_enabled") - switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) { - [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"hideuYouShortsDownloadButton_enabled"]; - return YES; - } - settingItemId:0], [YTSettingsSectionItemClass switchItemWithTitle:LOC(@"DISABLE_RESUME_TO_SHORTS") titleDescription:LOC(@"DISABLE_RESUME_TO_SHORTS_DESC") diff --git a/uYouPlus.xm b/uYouPlus.xm index 9dc9c45..21fff4d 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -1,27 +1,4 @@ -#import -#import -#import -#import -#import -#import #import "Header.h" -#import "Tweaks/YouTubeHeader/YTVideoQualitySwitchOriginalController.h" -#import "Tweaks/YouTubeHeader/YTPlayerViewController.h" -#import "Tweaks/YouTubeHeader/YTWatchController.h" -#import "Tweaks/YouTubeHeader/YTIGuideResponse.h" -#import "Tweaks/YouTubeHeader/YTIGuideResponseSupportedRenderers.h" -#import "Tweaks/YouTubeHeader/YTIPivotBarSupportedRenderers.h" -#import "Tweaks/YouTubeHeader/YTIPivotBarRenderer.h" -#import "Tweaks/YouTubeHeader/YTIBrowseRequest.h" -#import "Tweaks/YouTubeHeader/YTCommonColorPalette.h" -#import "Tweaks/YouTubeHeader/ASCollectionView.h" -#import "Tweaks/YouTubeHeader/YTPlayerOverlay.h" -#import "Tweaks/YouTubeHeader/YTPlayerOverlayProvider.h" -#import "Tweaks/YouTubeHeader/YTReelWatchPlaybackOverlayView.h" -#import "Tweaks/YouTubeHeader/YTReelPlayerBottomButton.h" -#import "Tweaks/YouTubeHeader/YTReelPlayerViewController.h" -#import "Tweaks/YouTubeHeader/YTAlertView.h" -#import "Tweaks/YouTubeHeader/YTISectionListRenderer.h" // Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f NSBundle *uYouPlusBundle() { @@ -32,31 +9,12 @@ NSBundle *uYouPlusBundle() { if (tweakBundlePath) bundle = [NSBundle bundleWithPath:tweakBundlePath]; else - bundle = [NSBundle bundleWithPath:@"/Library/Application Support/uYouPlus.bundle"]; + bundle = [NSBundle bundleWithPath:ROOT_PATH_NS(@"/Library/Application Support/uYouPlus.bundle")]; }); return bundle; } NSBundle *tweakBundle = uYouPlusBundle(); -// Keychain patching -static NSString *accessGroupID() { - NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys: - (__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass, - @"bundleSeedID", kSecAttrAccount, - @"", kSecAttrService, - (id)kCFBooleanTrue, kSecReturnAttributes, - nil]; - CFDictionaryRef result = nil; - OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result); - if (status == errSecItemNotFound) - status = SecItemAdd((__bridge CFDictionaryRef)query, (CFTypeRef *)&result); - if (status != errSecSuccess) - return nil; - NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:(__bridge NSString *)kSecAttrAccessGroup]; - - return accessGroup; -} - // static BOOL IsEnabled(NSString *key) { return [[NSUserDefaults standardUserDefaults] boolForKey:key]; @@ -73,31 +31,15 @@ static BOOL oldDarkTheme() { // # pragma mark - uYou's patches -// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/94 -%hook UIResponder -%new -- (id)entry { - return nil; -} -%end - -// Workaround for https://github.com/MiRO92/uYou-for-YouTube/issues/140 -%hook YTLocalPlaybackController -%new -- (id)activeVideoController { - return [self activeVideo]; -} -%end - // Workaround for qnblackcat/uYouPlus#10 -%hook boolSettingsVC -- (instancetype)initWithTitle:(NSString *)title sections:(NSArray *)sections footer:(NSString *)footer { - if (@available(iOS 15, *)) - if (![self valueForKey:@"_lastNotifiedTraitCollection"]) - [self setValue:[UITraitCollection currentTraitCollection] forKey:@"_lastNotifiedTraitCollection"]; - return %orig; -} -%end +// %hook boolSettingsVC +// - (instancetype)initWithTitle:(NSString *)title sections:(NSArray *)sections footer:(NSString *)footer { +// if (@available(iOS 15, *)) +// if (![self valueForKey:@"_lastNotifiedTraitCollection"]) +// [self setValue:[UITraitCollection currentTraitCollection] forKey:@"_lastNotifiedTraitCollection"]; +// return %orig; +// } +// %end // Prevent uYou player bar from showing when not playing downloaded media %hook PlayerManager @@ -116,59 +58,6 @@ static BOOL oldDarkTheme() { } %end -// Workaround for qnblackcat/uYouPlus#253, qnblackcat/uYouPlus#170 -%hook YTReelWatchPlaybackOverlayView -- (YTQTMButton *)overflowButton { - if ([self respondsToSelector:@selector(orderedRightSideButtons)] && - [self orderedRightSideButtons].count != 0) - return [self orderedRightSideButtons][0]; - return %orig; -} -%end - -%hook YTReelContentView -- (void)didTapOverflowButton:(id)sender {} -%end - -%subclass YTReelPlayerBottomButton : YTReelPlayerButton -%end - -%hook NSLayoutConstraint -+ (instancetype)constraintWithItem:(UIView *)view1 - attribute:(NSLayoutAttribute)attr1 - relatedBy:(NSLayoutRelation)relation - toItem:(UIView *)view2 - attribute:(NSLayoutAttribute)attr2 - multiplier:(CGFloat)multiplier - constant:(CGFloat)c { - if (![view1 isKindOfClass:%c(YTReelPlayerBottomButton)] && - ![view1.accessibilityIdentifier isEqualToString:@"com.miro.uyou"]) - return %orig; - if (!view2) { - view1.hidden = YES; - return [NSLayoutConstraint alloc]; - } - YTReelPlayerBottomButton *uYouButton = (YTReelPlayerBottomButton *)view1; - YTReelPlayerBottomButton *topButton = (YTReelPlayerBottomButton *)view2; - NSString *uYouButtonTitle = - [view2.accessibilityIdentifier isEqualToString:@"com.miro.uyou"] - ? @"uYou" - : @"uYouLocal"; - uYouButton.accessibilityLabel = uYouButtonTitle; - uYouButton.uppercaseTitle = NO; - [uYouButton setTitle:uYouButtonTitle forState:UIControlStateNormal]; - [uYouButton - setTitleTypeKind:MSHookIvar(topButton, "_typeKind") - typeVariant:MSHookIvar(topButton, "_typeVariant")]; - uYouButton.applyRightSideLayoutImageSize = topButton.applyRightSideLayoutImageSize; - uYouButton.buttonImageTitlePadding = topButton.buttonImageTitlePadding; - uYouButton.buttonLayoutStyle = topButton.buttonLayoutStyle; - uYouButton.sizeWithPaddingAndInsets = topButton.sizeWithPaddingAndInsets; - uYouButton.verticalContentPadding = topButton.verticalContentPadding; - return %orig; -} -%end - // iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224 %group iOS16 %hook OBPrivacyLinkButton @@ -217,27 +106,6 @@ static BOOL didFinishLaunching; } %end -// uYou's slide settings? -%hook FRPSliderCell -- (void)didMoveToWindow { - %orig; - if (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { - MSHookIvar(self, "_lLabel").textColor = [UIColor whiteColor]; - MSHookIvar(self, "_rLabel").textColor = [UIColor whiteColor]; - MSHookIvar(self, "_cLabel").textColor = [UIColor whiteColor]; - } -} -%end - -// Remove uYou download button in playlists -// https://github.com/qnblackcat/uYouPlus/issues/798#issuecomment-1364853420 -%hook YTPlaylistHeaderViewController -- (void)viewDidLoad { - %orig; - self.downloadsButton.hidden = YES; -} -%end - # pragma mark - YouTube's patches // Workaround for MiRO92/uYou-for-YouTube#12, qnblackcat/uYouPlus#263 %hook YTDataUtils @@ -255,38 +123,6 @@ static BOOL didFinishLaunching; // - (void)decorateContext:(id)context {} // %end -// Fix login for YouTube 18.13.2 and higher -%hook SSOKeychainHelper -+ (NSString *)accessGroup { - return accessGroupID(); -} -+ (NSString *)sharedAccessGroup { - return accessGroupID(); -} -%end - -// Fix login for YouTube 17.33.2 and higher -%hook SSOKeychainCore -+ (NSString *)accessGroup { - return accessGroupID(); -} -+ (NSString *)sharedAccessGroup { - return accessGroupID(); -} -%end - -// Fix App Group Directory by move it to document directory -%hook NSFileManager -- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier { - if (groupIdentifier != nil) { - NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; - NSURL *documentsURL = [paths lastObject]; - return [documentsURL URLByAppendingPathComponent:@"AppGroup"]; - } - return %orig(groupIdentifier); -} -%end - // Hide YouTube annoying banner in Home page? - @MiRO92 - YTNoShorts: https://github.com/MiRO92/YTNoShorts %hook YTAsyncCollectionView - (id)cellForItemAtIndexPath:(NSIndexPath *)indexPath { @@ -386,20 +222,6 @@ static BOOL didFinishLaunching; } %end -// YTAutoFullScreen: https://github.com/PoomSmart/YTAutoFullScreen/ -%hook YTPlayerViewController -- (void)loadWithPlayerTransition:(id)arg1 playbackConfig:(id)arg2 { - %orig; - if (IsEnabled(@"autoFull_enabled")) - [NSTimer scheduledTimerWithTimeInterval:0.75 target:self selector:@selector(autoFullscreen) userInfo:nil repeats:NO]; -} -%new -- (void)autoFullscreen { - YTWatchController *watchController = [self valueForKey:@"_UIDelegate"]; - [watchController showFullScreen]; -} -%end - // YTNoHoverCards: https://github.com/level3tjg/YTNoHoverCards %hook YTCreatorEndscreenView - (void)setHidden:(BOOL)hidden { @@ -426,17 +248,7 @@ static BOOL didFinishLaunching; } %end -// Hide search ads by @PoomSmart - https://github.com/PoomSmart/YouTube-X -%hook YTIElementRenderer -- (NSData *)elementData { - if (self.hasCompatibilityOptions && self.compatibilityOptions.hasAdLoggingData) - return nil; - return %orig; -} -%end - %hook YTSectionListViewController - - (void)loadWithModel:(YTISectionListRenderer *)model { NSMutableArray *contentsArray = model.contentsArray; NSIndexSet *removeIndexes = [contentsArray indexesOfObjectsPassingTest:^BOOL(YTISectionListSupportedRenderers *renderers, NSUInteger idx, BOOL *stop) { @@ -447,7 +259,6 @@ static BOOL didFinishLaunching; [contentsArray removeObjectsAtIndexes:removeIndexes]; %orig; } - %end // YTClassicVideoQuality: https://github.com/PoomSmart/YTClassicVideoQuality @@ -462,7 +273,6 @@ static BOOL didFinishLaunching; %hook YTColdConfig - (BOOL)respectDeviceCaptionSetting { return NO; } // YouRememberCaption: https://poomsmart.github.io/repo/depictions/youremembercaption.html - (BOOL)isLandscapeEngagementPanelSwipeRightToDismissEnabled { return YES; } // Swipe right to dismiss the right panel in fullscreen mode -- (BOOL)mainAppCoreClientIosTransientVisualGlitchInPivotBarFix { return NO; } // Fix uYou's label glitching - qnblackcat/uYouPlus#552 %end // NOYTPremium - https://github.com/PoomSmart/NoYTPremium/ @@ -492,28 +302,6 @@ static BOOL didFinishLaunching; - (void)showSurveyWithRenderer:(id)arg1 surveyParentResponder:(id)arg2 {} %end -// YTShortsProgress - @PoomSmart - https://github.com/PoomSmart/YTShortsProgress -%hook YTReelPlayerViewController -- (BOOL)shouldEnablePlayerBar { return YES; } -- (BOOL)shouldAlwaysEnablePlayerBar { return YES; } -- (BOOL)shouldEnablePlayerBarOnlyOnPause { return NO; } -%end - -%hook YTReelPlayerViewControllerSub -- (BOOL)shouldEnablePlayerBar { return YES; } -- (BOOL)shouldAlwaysEnablePlayerBar { return YES; } -- (BOOL)shouldEnablePlayerBarOnlyOnPause { return NO; } -%end - -%hook YTColdConfig -- (BOOL)iosEnableVideoPlayerScrubber { return YES; } -- (BOOL)mobileShortsTabInlined { return YES; } -%end - -%hook YTHotConfig -- (BOOL)enablePlayerBarForVerticalVideoWhenControlsHiddenInFullscreen { return YES; } -%end - // YTNoPaidPromo: https://github.com/PoomSmart/YTNoPaidPromo %hook YTMainAppVideoPlayerOverlayViewController - (void)setPaidContentWithPlayerData:(id)data { @@ -929,12 +717,12 @@ void DEMC_centerRenderingView() { %end %end -// Bring back the red progress bar -%hook YTColdConfig -- (BOOL)segmentablePlayerBarUpdateColors { - return IsEnabled(@"redProgressBar_enabled") ? NO : %orig; -} -%end +// Bring back the red progress bar - Broken?! +// %hook YTColdConfig +// - (BOOL)segmentablePlayerBarUpdateColors { +// return IsEnabled(@"redProgressBar_enabled") ? NO : %orig; +// } +// %end // Disable the right panel in fullscreen mode %hook YTColdConfig @@ -944,35 +732,6 @@ void DEMC_centerRenderingView() { %end // Shorts Controls Overlay Options -%hook YTReelWatchPlaybackOverlayView -- (void)setNativePivotButton:(id)arg1 { - if (IsEnabled(@"hideShortsChannelAvatar_enabled")) {} - else { return %orig; } -} -- (void)setReelDislikeButton:(id)arg1 { - if (IsEnabled(@"hideShortsDislikeButton_enabled")) {} - else { return %orig; } -} -- (void)setViewCommentButton:(id)arg1 { - if (IsEnabled(@"hideShortsCommentButton_enabled")) {} - else { return %orig; } -} -- (void)setRemixButton:(id)arg1 { - if (IsEnabled(@"hideShortsRemixButton_enabled")) {} - else { return %orig; } -} -- (void)setShareButton:(id)arg1 { - if (IsEnabled(@"hideShortsShareButton_enabled")) {} - else { return %orig; } -} -%end - -%hook YTHotConfig -- (BOOL)iosEnableShortsPlayerSplitViewController { - return IsEnabled(@"hideuYouShortsDownloadButton_enabled") ? YES : NO; -} -%end - %hook _ASDisplayView - (void)didMoveToWindow { %orig; @@ -1396,20 +1155,15 @@ UIColor* raisedColor = [UIColor colorWithRed:0.035 green:0.035 blue:0.035 alpha: [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"automaticallyCheckForUpdates"]; // Disable broken options of uYou - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"]; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"disableAgeRestriction"]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"showedWelcomeVC"]; // Change the default value of some options NSArray *allKeys = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] allKeys]; if (![allKeys containsObject:@"relatedVideosAtTheEndOfYTVideos"]) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"relatedVideosAtTheEndOfYTVideos"]; } - if (![allKeys containsObject:@"uYouButtonVideoControlsOverlay"]) { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"uYouButtonVideoControlsOverlay"]; - } - if (![allKeys containsObject:@"uYouPiPButtonVideoControlsOverlay"]) { - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"uYouPiPButtonVideoControlsOverlay"]; + if (![allKeys containsObject:@"shortsProgressBar"]) { + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"shortsProgressBar"]; } if (![allKeys containsObject:@"RYD-ENABLED"]) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RYD-ENABLED"];