Skip to content

Commit

Permalink
for TrollStore user only: add an option to fix Google Sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
qnblackcat committed Sep 6, 2022
1 parent c04f0b7 commit 1f5ad62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
11 changes: 10 additions & 1 deletion Settings.xm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -168,7 +177,7 @@ extern BOOL hidePaidPromotionCard();
return YES;
};

NSMutableArray <YTSettingsSectionItem *> *sectionItems = [NSMutableArray arrayWithArray:@[killApp, autoFull, castConfirm, ytMiniPlayer, hideAutoplaySwitch, hideCC, hideHUD, hidePaidPromotionCard, hidePreviousAndNextButton, hideHoverCard, bigYTMiniPlayer, oledDarkMode, oledKeyBoard, reExplore]];
NSMutableArray <YTSettingsSectionItem *> *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];
}

Expand Down
24 changes: 16 additions & 8 deletions uYouPlus.xm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand All @@ -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) {
Expand All @@ -483,6 +487,7 @@ BOOL hidePaidPromotionCard() {
return %orig;
}
%end
%end

// Fix login for YouTube 17.33.2 and higher
%hook SSOKeychainCore
Expand Down Expand Up @@ -872,4 +877,7 @@ static void replaceTab(YTIGuideResponse *response) {
if (@available(iOS 16, *)) {
%init(iOS16);
}
if (!fixGoogleSigin()) {
%init(gDevice_challenge_request_hack);
}
}

0 comments on commit 1f5ad62

Please sign in to comment.