From ebea7110a06831ceb84decbef7f0c18bf2aabb45 Mon Sep 17 00:00:00 2001 From: BandarHelal <31299470+BandarHL@users.noreply.github.com> Date: Mon, 29 Jun 2026 09:53:59 +0300 Subject: [PATCH] feat: support Instagram 435.0.0 - Add settings chooser on profile side tray button (IG vs SCInsta settings) - Fall back to _mediaPassthrough ivar for reel video download when video is unavailable Co-Authored-By: Claude Opus 4.8 --- src/Features/General/SCSettingsMenuEntry.x | 50 ++++++++++++++++++++++ src/Features/Media/MediaDownload.xm | 12 +++++- src/InstagramHeaders.h | 3 ++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/Features/General/SCSettingsMenuEntry.x b/src/Features/General/SCSettingsMenuEntry.x index 460315a7..72859325 100644 --- a/src/Features/General/SCSettingsMenuEntry.x +++ b/src/Features/General/SCSettingsMenuEntry.x @@ -55,4 +55,54 @@ [SCIUtils showSettingsVC:[self window]]; } +%end + +// Tapping the side tray (hamburger) button on the profile lets the user choose +// between the normal Instagram settings and the SCInsta tweak settings +@protocol SCSideTrayController +- (void)onSideTrayButton; +@end + +static BOOL sciBypassSideTray = NO; + +%hook _TtC19IGProfileNavigation34IGProfileNavigationItemsController +- (void)onSideTrayButton { + // Re-entrant call from the "Instagram Settings" option: run the original + if (sciBypassSideTray) { + sciBypassSideTray = NO; + %orig; + return; + } + + UIWindow *window = [[UIApplication sharedApplication] keyWindow]; + UIViewController *presenter = [window rootViewController]; + while (presenter.presentedViewController) presenter = presenter.presentedViewController; + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Settings" + message:@"Which settings would you like to open?" + preferredStyle:UIAlertControllerStyleActionSheet]; + + [alert addAction:[UIAlertAction actionWithTitle:@"Instagram Settings" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + sciBypassSideTray = YES; + [(id)self onSideTrayButton]; + }]]; + + [alert addAction:[UIAlertAction actionWithTitle:@"SCInsta Settings" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [SCIUtils showSettingsVC:window]; + }]]; + + [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; + + // Required for iPad to avoid a crash when presenting an action sheet + if (alert.popoverPresentationController) { + alert.popoverPresentationController.sourceView = presenter.view; + alert.popoverPresentationController.sourceRect = CGRectMake(presenter.view.bounds.size.width / 2.0, presenter.view.bounds.size.height / 2.0, 1.0, 1.0); + } + + [presenter presentViewController:alert animated:YES completion:nil]; +} %end \ No newline at end of file diff --git a/src/Features/Media/MediaDownload.xm b/src/Features/Media/MediaDownload.xm index 88a92158..0651bfb2 100644 --- a/src/Features/Media/MediaDownload.xm +++ b/src/Features/Media/MediaDownload.xm @@ -172,8 +172,16 @@ static void initDownloaders () { } %new - (void)handleLongPress:(UILongPressGestureRecognizer *)sender { if (sender.state != UIGestureRecognizerStateBegan) return; - - NSURL *videoUrl = [SCIUtils getVideoUrlForMedia:self.video]; + + // Older versions expose the media via `video`; newer ones store it in the + // `_mediaPassthrough` ivar, so fall back to KVC when `video` is unavailable. + IGMedia *media = [self respondsToSelector:@selector(video)] ? self.video : nil; + if (!media) { + @try { media = [self valueForKey:@"mediaPassthrough"]; } + @catch (NSException *e) { media = nil; } + } + + NSURL *videoUrl = [SCIUtils getVideoUrlForMedia:media]; if (!videoUrl) { [SCIUtils showErrorHUDWithDescription:@"Could not extract video url from reel"]; diff --git a/src/InstagramHeaders.h b/src/InstagramHeaders.h index d66f1fd0..88adb43c 100644 --- a/src/InstagramHeaders.h +++ b/src/InstagramHeaders.h @@ -151,6 +151,9 @@ @end @interface IGSundialViewerVideoCell : UIView +{ + IGMedia *_mediaPassthrough; +} @property(readonly, nonatomic) IGMedia *video; - (void)addLongPressGestureRecognizer; // new