From 1f5ad62544cb0ebb1f99980e8f278826869f4472 Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Tue, 6 Sep 2022 08:44:11 +0700 Subject: [PATCH] for TrollStore user only: add an option to fix Google Sign in --- Settings.xm | 11 ++++++++++- uYouPlus.xm | 24 ++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Settings.xm b/Settings.xm index b1ac918..ef3abc5 100644 --- a/Settings.xm +++ b/Settings.xm @@ -51,6 +51,15 @@ extern BOOL hidePaidPromotionCard(); exit(0); }]; + YTSettingsSectionItem *fixGoogleSigin = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"FIX_GOOGLE_SIGNIN") titleDescription:LOC(@"FIX_GOOGLE_SIGNIN_DESC")]; + fixGoogleSigin.hasSwitch = YES; + fixGoogleSigin.switchVisible = YES; + fixGoogleSigin.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"fixGoogleSigin_enabled"]; + fixGoogleSigin.switchBlock = ^BOOL (YTSettingsCell *cell, BOOL enabled) { + [[NSUserDefaults standardUserDefaults] setBool:enabled forKey:@"fixGoogleSigin_enabled"]; + return YES; + }; + YTSettingsSectionItem *hidePaidPromotionCard = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"HIDE_PAID_PROMOTION_CARDS") titleDescription:LOC(@"HIDE_PAID_PROMOTION_CARDS_DESC")]; hidePaidPromotionCard.hasSwitch = YES; hidePaidPromotionCard.switchVisible = YES; @@ -168,7 +177,7 @@ extern BOOL hidePaidPromotionCard(); return YES; }; - NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]]; + NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, fixGoogleSigin, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]]; [delegate setSectionItems:sectionItems forCategory:uYouPlusSection title:@"uYouPlus" titleDescription:nil headerHidden:NO]; } diff --git a/uYouPlus.xm b/uYouPlus.xm index 189bd16..a986a94 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -90,6 +90,9 @@ BOOL ytMiniPlayer() { BOOL hidePaidPromotionCard() { return [[NSUserDefaults standardUserDefaults] boolForKey:@"hidePaidPromotionCard_enabled"]; } +BOOL fixGoogleSigin() { + return [[NSUserDefaults standardUserDefaults] boolForKey:@"fixGoogleSigin_enabled"]; +} # pragma mark - Tweaks // Enable Reorder videos from playlist while on the Watch page - @PoomSmart @@ -430,6 +433,14 @@ BOOL hidePaidPromotionCard() { - (NSString *)bundleId { return YT_BUNDLE_ID; } %end +%hook APMAEU ++ (BOOL)isFAS { return YES; } +%end + +%hook GULAppEnvironmentUtil ++ (BOOL)isFromAppStore { return YES; } +%end + %hook SSOConfiguration - (id)initWithClientID:(id)clientID supportedAccountServices:(id)supportedAccountServices { self = %orig; @@ -439,14 +450,6 @@ BOOL hidePaidPromotionCard() { } %end -%hook APMAEU -+ (BOOL)isFAS { return YES; } -%end - -%hook GULAppEnvironmentUtil -+ (BOOL)isFromAppStore { return YES; } -%end - %hook NSBundle - (NSString *)bundleIdentifier { NSArray *address = [NSThread callStackReturnAddresses]; @@ -470,6 +473,7 @@ BOOL hidePaidPromotionCard() { // Fix "You can't sign in to this app because Google can't confirm that it's safe" warning when signing in. by julioverne & PoomSmart // https://gist.github.com/PoomSmart/ef5b172fd4c5371764e027bea2613f93 // https://github.com/qnblackcat/uYouPlus/pull/398 +%group gDevice_challenge_request_hack %hook SSOService + (id)fetcherWithRequest:(NSMutableURLRequest *)request configuration:(id)configuration { if ([request isKindOfClass:[NSMutableURLRequest class]] && request.HTTPBody) { @@ -483,6 +487,7 @@ BOOL hidePaidPromotionCard() { return %orig; } %end +%end // Fix login for YouTube 17.33.2 and higher %hook SSOKeychainCore @@ -872,4 +877,7 @@ static void replaceTab(YTIGuideResponse *response) { if (@available(iOS 16, *)) { %init(iOS16); } + if (!fixGoogleSigin()) { + %init(gDevice_challenge_request_hack); + } }