fix(Instagram): Update share link fingerprints and navigation patches for 421.x.x

- Fix `Sanitize sharing links` patch: replace deprecated `permalink` string
  with `create_highlight_permalink_share_url` in permalinkResponseJsonParserMethodMatch
- Add error handling in EditShareLinksPatch to gracefully handle fingerprint mismatches
- Fix `Hide navigation buttons` patch: use mutable ArrayList and setAccessible(true)
  to avoid UnsupportedOperationException on newer builds
- Update compatibleWith version to 421.0.0.51.66
This commit is contained in:
Gaurav Yadav 2026-03-21 23:53:55 +05:45
parent b632d0f042
commit 480fd00b4c
4 changed files with 21 additions and 17 deletions

View file

@ -19,15 +19,18 @@ public class HideNavigationButtonsPatch {
String enumNameField
)
throws IllegalAccessException, NoSuchFieldException {
for (Object button : navigationButtonsList) {
List<Object> mutableList = new java.util.ArrayList<>(navigationButtonsList);
for (int i = 0; i < mutableList.size(); i++) {
Object button = mutableList.get(i);
Field f = button.getClass().getDeclaredField(enumNameField);
f.setAccessible(true);
String currentButtonEnumName = (String) f.get(button);
if (buttonNameToRemove.equals(currentButtonEnumName)) {
navigationButtonsList.remove(button);
mutableList.remove(i);
break;
}
}
return navigationButtonsList;
return mutableList;
}
}

View file

@ -26,7 +26,7 @@ val hideNavigationButtonsPatch = bytecodePatch(
description = "Hides navigation bar buttons, such as the Reels and Create button.",
use = false,
) {
compatibleWith("com.instagram.android"("401.0.0.48.79"))
compatibleWith("com.instagram.android"("421.0.0.51.66"))
dependsOn(sharedExtensionPatch)

View file

@ -16,13 +16,19 @@ internal fun BytecodePatchContext.editShareLinksPatch(block: MutableMethod.(inde
)
methodsToPatch.forEach { match ->
match.method.apply {
val putSharingUrlIndex = indexOfFirstInstruction(
match[0],
Opcode.IPUT_OBJECT
)
val sharingUrlRegister = getInstruction<TwoRegisterInstruction>(putSharingUrlIndex).registerA
block(putSharingUrlIndex, sharingUrlRegister)
try {
match.method.apply {
val putSharingUrlIndex = indexOfFirstInstruction(
match[0],
Opcode.IPUT_OBJECT
)
val sharingUrlRegister = getInstruction<TwoRegisterInstruction>(putSharingUrlIndex).registerA
block(putSharingUrlIndex, sharingUrlRegister)
}
} catch (e: java.lang.IllegalArgumentException) {
java.util.logging.Logger.getLogger("EditShareLinksPatch").warning("Failed to find IPUT_OBJECT in share link method: ${e.message}")
} catch (e: java.lang.Exception) {
java.util.logging.Logger.getLogger("EditShareLinksPatch").warning("Error patching share link method: ${e.message}")
}
}
}

View file

@ -10,12 +10,7 @@ import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.permalinkResponseJsonParserMethodMatch by composingFirstMethod {
name("unsafeParseFromJson")
instructions("permalink"())
opcodes(
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL
)
instructions("create_highlight_permalink_share_url"())
}
internal val BytecodePatchContext.storyUrlResponseJsonParserMethodMatch by composingFirstMethod {