diff --git a/src/Features/Feed/DisableFeedAutoplay.x b/src/Features/Feed/DisableFeedAutoplay.x index 1edf42f..9d539a3 100644 --- a/src/Features/Feed/DisableFeedAutoplay.x +++ b/src/Features/Feed/DisableFeedAutoplay.x @@ -1,10 +1,32 @@ #import "../../Utils.h" +#import +#import -// Demangled name: IGFeedPlayback.IGFeedPlaybackStrategy -%hook _TtC14IGFeedPlayback22IGFeedPlaybackStrategy -- (id)initWithShouldDisableAutoplay:(_Bool)autoplay { - if ([SCIUtils getBoolPref:@"disable_feed_autoplay"]) return %orig(true); +// IGFeedPlayback.IGFeedPlaybackStrategy gained new init parameters in IG 423+. +// Both the 2-arg and 3-arg variants are hooked to force shouldDisableAutoplay=YES. +// Hooked via MSHookMessageEx in %ctor since the class has a Swift-mangled name. - return %orig(autoplay); +static id (*orig_initStrategy2)(id, SEL, BOOL, BOOL); +static id new_initStrategy2(id self, SEL _cmd, BOOL shouldDisable, BOOL shouldClearStale) { + if ([SCIUtils getBoolPref:@"disable_feed_autoplay"]) shouldDisable = YES; + return orig_initStrategy2(self, _cmd, shouldDisable, shouldClearStale); +} + +static id (*orig_initStrategy3)(id, SEL, BOOL, BOOL, BOOL); +static id new_initStrategy3(id self, SEL _cmd, BOOL shouldDisable, BOOL shouldClearStale, BOOL bypassForVoiceover) { + if ([SCIUtils getBoolPref:@"disable_feed_autoplay"]) shouldDisable = YES; + return orig_initStrategy3(self, _cmd, shouldDisable, shouldClearStale, bypassForVoiceover); +} + +%ctor { + Class cls = objc_getClass("IGFeedPlayback.IGFeedPlaybackStrategy"); + if (!cls) return; + + SEL sel2 = @selector(initWithShouldDisableAutoplay:shouldClearStaleReservation:); + if ([cls instancesRespondToSelector:sel2]) + MSHookMessageEx(cls, sel2, (IMP)new_initStrategy2, (IMP *)&orig_initStrategy2); + + SEL sel3 = @selector(initWithShouldDisableAutoplay:shouldClearStaleReservation:shouldBypassDisabledAutoplayForVoiceover:); + if ([cls instancesRespondToSelector:sel3]) + MSHookMessageEx(cls, sel3, (IMP)new_initStrategy3, (IMP *)&orig_initStrategy3); } -%end \ No newline at end of file diff --git a/src/Settings/TweakSettings.m b/src/Settings/TweakSettings.m index bdb6e43..6bcf520 100644 --- a/src/Settings/TweakSettings.m +++ b/src/Settings/TweakSettings.m @@ -71,7 +71,7 @@ [SCISetting switchCellWithTitle:@"No suggested for you" subtitle:@"Hides suggested accounts for you to follow" defaultsKey:@"no_suggested_account"], [SCISetting switchCellWithTitle:@"No suggested reels" subtitle:@"Hides suggested reels to watch" defaultsKey:@"no_suggested_reels"], [SCISetting switchCellWithTitle:@"No suggested threads posts" subtitle:@"Hides suggested threads posts" defaultsKey:@"no_suggested_threads"], - [SCISetting switchCellWithTitle:@"Disable video autoplay" subtitle:@"Prevents videos on your feed from playing automatically" defaultsKey:@"disable_feed_autoplay"] + [SCISetting switchCellWithTitle:@"Disable video autoplay" subtitle:@"Prevents videos on your feed from playing automatically" defaultsKey:@"disable_feed_autoplay" requiresRestart:YES] ] }] ], diff --git a/src/Tweak.x b/src/Tweak.x index d1e3406..ad327ec 100644 --- a/src/Tweak.x +++ b/src/Tweak.x @@ -28,7 +28,7 @@ BOOL dmVisualMsgsViewedButtonEnabled = false; @"detailed_color_picker": @(YES), @"remove_screenshot_alert": @(YES), @"call_confirm": @(YES), - @"keep_deleted_message": @(YES), + @"keep_deleted_message": @(NO), @"dw_feed_posts": @(YES), @"dw_reels": @(YES), @"dw_story": @(YES), @@ -50,7 +50,7 @@ BOOL dmVisualMsgsViewedButtonEnabled = false; @"download_audio_message": @(NO), @"unlock_password_reels": @(YES), @"seen_mode": @"button", - @"seen_auto_on_interact": @(YES), + @"seen_auto_on_interact": @(NO), @"indicate_unsent_messages": @(NO), @"unsent_message_toast": @(NO) };