From 8725a49ba3a06fee0280ffcf4be62cd960cd301e Mon Sep 17 00:00:00 2001 From: Swakshan <56347042+Swakshan@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:22:36 +0530 Subject: [PATCH] feat(Instagram): Add `Hide highlights tray` patch (#6489) Co-authored-by: oSumAtrIX --- patches/api/patches.api | 4 +++ .../instagram/hide/explore/HideExploreFeed.kt | 26 ++----------------- .../hide/highlightsTray/Fingerprints.kt | 9 +++++++ .../highlightsTray/HideHighlightsTrayPatch.kt | 17 ++++++++++++ .../hide/suggestions/HideSuggestedContent.kt | 4 +-- .../patches/instagram/shared/Utils.kt | 25 ++++++++++++++++++ 6 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/Fingerprints.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatch.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/instagram/shared/Utils.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index c14ba4a53..3c7dc2f1e 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -308,6 +308,10 @@ public final class app/revanced/patches/instagram/hide/explore/HideExploreFeedKt public static final fun getHideExploreFeedPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatchKt { + public static final fun getHideHighlightsTrayPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/instagram/hide/navigation/HideNavigationButtonsKt { public static final fun getHideNavigationButtonsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/explore/HideExploreFeed.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/explore/HideExploreFeed.kt index a2c7d5ba5..f9ec6505f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/explore/HideExploreFeed.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/explore/HideExploreFeed.kt @@ -1,29 +1,7 @@ package app.revanced.patches.instagram.hide.explore -import app.revanced.patcher.Fingerprint -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction -import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.bytecodePatch -import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - -context(BytecodePatchContext) -internal fun Fingerprint.replaceJsonFieldWithBogus( - key: String, -) { - val targetStringIndex = stringMatches!!.first { match -> match.string == key }.index - val targetStringRegister = method.getInstruction(targetStringIndex).registerA - - /** - * Replacing the JSON key we want to skip with a random string that is not a valid JSON key. - * This way the feeds array will never be populated. - * Received JSON keys that are not handled are simply ignored, so there are no side effects. - */ - method.replaceInstruction( - targetStringIndex, - "const-string v$targetStringRegister, \"BOGUS\"", - ) -} +import app.revanced.patches.instagram.shared.replaceStringWithBogus @Suppress("unused") val hideExploreFeedPatch = bytecodePatch( @@ -34,6 +12,6 @@ val hideExploreFeedPatch = bytecodePatch( compatibleWith("com.instagram.android") execute { - exploreResponseJsonParserFingerprint.replaceJsonFieldWithBogus(EXPLORE_KEY_TO_BE_HIDDEN) + exploreResponseJsonParserFingerprint.replaceStringWithBogus(EXPLORE_KEY_TO_BE_HIDDEN) } } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/Fingerprints.kt new file mode 100644 index 000000000..9a0341ee6 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/Fingerprints.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.instagram.hide.highlightsTray + +import app.revanced.patcher.fingerprint + +internal const val TARGET_STRING = "highlights_tray" + +internal val highlightsUrlBuilderFingerprint = fingerprint { + strings(TARGET_STRING,"X-IG-Accept-Hint") +} diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatch.kt new file mode 100644 index 000000000..3b777d9ed --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/highlightsTray/HideHighlightsTrayPatch.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.instagram.hide.highlightsTray + +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.instagram.shared.replaceStringWithBogus + +@Suppress("unused") +val hideHighlightsTrayPatch = bytecodePatch( + name = "Hide highlights tray", + description = "Hides the highlights tray in profile section.", + use = false +) { + compatibleWith("com.instagram.android") + + execute { + highlightsUrlBuilderFingerprint.replaceStringWithBogus(TARGET_STRING) + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/suggestions/HideSuggestedContent.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/suggestions/HideSuggestedContent.kt index 0c2501411..9dc6dbf59 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/hide/suggestions/HideSuggestedContent.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/hide/suggestions/HideSuggestedContent.kt @@ -1,7 +1,7 @@ package app.revanced.patches.instagram.hide.suggestions import app.revanced.patcher.patch.bytecodePatch -import app.revanced.patches.instagram.hide.explore.replaceJsonFieldWithBogus +import app.revanced.patches.instagram.shared.replaceStringWithBogus @Suppress("unused") val hideSuggestedContent = bytecodePatch( @@ -13,7 +13,7 @@ val hideSuggestedContent = bytecodePatch( execute { FEED_ITEM_KEYS_TO_BE_HIDDEN.forEach { key -> - feedItemParseFromJsonFingerprint.replaceJsonFieldWithBogus(key) + feedItemParseFromJsonFingerprint.replaceStringWithBogus(key) } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/shared/Utils.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/shared/Utils.kt new file mode 100644 index 000000000..522257aa8 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/shared/Utils.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.instagram.shared + +import app.revanced.patcher.Fingerprint +import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatchContext +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction + +context(BytecodePatchContext) +internal fun Fingerprint.replaceStringWithBogus( + targetString: String, +) { + val targetStringIndex = stringMatches!!.first { match -> match.string == targetString }.index + val targetStringRegister = method.getInstruction(targetStringIndex).registerA + + /** + * Replaces the 'target string' with 'BOGUS'. + * This is usually done when we need to override a JSON key or url, + * to skip with a random string that is not a valid JSON key. + */ + method.replaceInstruction( + targetStringIndex, + "const-string v$targetStringRegister, \"BOGUS\"", + ) +} \ No newline at end of file