From 2154d89242fd8d7f7460145d5d35a4f1986944a3 Mon Sep 17 00:00:00 2001 From: brosssh <44944126+brosssh@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:37:20 +0200 Subject: [PATCH] feat(Instagram): Add `Enable developer menu` patch (#6043) --- patches/api/patches.api | 4 ++ .../misc/devmenu/EnableDeveloperMenuPatch.kt | 37 +++++++++++++++++++ .../instagram/misc/devmenu/Fingerprints.kt | 12 ++++++ 3 files changed, 53 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatch.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/Fingerprints.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index c12b7a9bd..79abfd5ab 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -280,6 +280,10 @@ public final class app/revanced/patches/instagram/hide/stories/HideStoriesKt { public static final fun getHideStoriesPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatchKt { + public static final fun getEnableDeveloperMenuPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/instagram/misc/extension/SharedExtensionPatchKt { public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatch.kt new file mode 100644 index 000000000..4f594478d --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/EnableDeveloperMenuPatch.kt @@ -0,0 +1,37 @@ +package app.revanced.patches.instagram.misc.devmenu + +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.Utils.trimIndentMultiline +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionReversedOrThrow +import app.revanced.util.returnEarly +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +@Suppress("unused") +val enableDeveloperMenuPatch = bytecodePatch( + name = "Enable developer menu", + description = """ + Enables the developer menu, which can be found at the bottom of settings menu with name 'Internal Settings'. + + It is recommended to use this patch with an alpha/beta Instagram release. Patching a stable release works, but the developer menu shows the developer flags as numbers and does not show a human readable description. + """.trimIndentMultiline(), + use = false +) { + compatibleWith("com.instagram.android") + + execute { + with(clearNotificationReceiverFingerprint.method) { + indexOfFirstInstructionReversedOrThrow(clearNotificationReceiverFingerprint.stringMatches!!.first().index) { + val reference = getReference() + Opcode.INVOKE_STATIC == opcode && + reference?.parameterTypes?.size == 1 && + reference.parameterTypes.first() == "Lcom/instagram/common/session/UserSession;" && + reference.returnType == "Z" + }.let { index -> + navigate(this).to(index).stop().returnEarly(true) + } + } + } +} + diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/Fingerprints.kt new file mode 100644 index 000000000..8b84606f0 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/devmenu/Fingerprints.kt @@ -0,0 +1,12 @@ + +package app.revanced.patches.instagram.misc.devmenu + +import app.revanced.patcher.fingerprint + +internal val clearNotificationReceiverFingerprint = fingerprint { + custom { method, classDef -> + method.name == "onReceive" && + classDef.type == "Lcom/instagram/notifications/push/ClearNotificationReceiver;" + } + strings("NOTIFICATION_DISMISSED") +}