Skip to content

Commit 1dbc2d4

Browse files
PainfulPaladinsLisoUseInAIKyriosoSumAtrIX
authored
feat(Instagram): Add Hide navigation buttons patch (#5678)
Co-authored-by: LisoUseInAIKyrios <[email protected]> Co-authored-by: oSumAtrIX <[email protected]>
1 parent f6917dc commit 1dbc2d4

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

patches/api/patches.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ public final class app/revanced/patches/instagram/ads/HideAdsPatchKt {
264264
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
265265
}
266266

267+
public final class app/revanced/patches/instagram/hide/navigation/HideNavigationButtonsKt {
268+
public static final fun getHideNavigationButtonsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
269+
}
270+
267271
public final class app/revanced/patches/instagram/misc/signature/SignatureCheckPatchKt {
268272
public static final fun getSignatureCheckPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
269273
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package app.revanced.patches.instagram.hide.navigation
3+
4+
import app.revanced.patcher.fingerprint
5+
import com.android.tools.smali.dexlib2.Opcode
6+
7+
internal val tabCreateButtonsLoopStartFingerprint = fingerprint {
8+
returns("V")
9+
strings("InstagramMainActivity.createTabButtons")
10+
opcodes(
11+
//Loop Start
12+
Opcode.IF_GE, // Check if index is finished (index, size)
13+
//Injection
14+
Opcode.INVOKE_INTERFACE,
15+
Opcode.MOVE_RESULT_OBJECT
16+
)
17+
}
18+
19+
internal val tabCreateButtonsLoopEndFingerprint = fingerprint {
20+
returns("V")
21+
strings("InstagramMainActivity.createTabButtons")
22+
opcodes(
23+
Opcode.IPUT_OBJECT,
24+
// Injection Jump
25+
Opcode.ADD_INT_LIT8, //Increase Index
26+
Opcode.GOTO_16 // Jump to loopStart
27+
// LoopEnd
28+
)
29+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package app.revanced.patches.instagram.hide.navigation
2+
3+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
4+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
5+
import app.revanced.patcher.patch.booleanOption
6+
import app.revanced.patcher.patch.bytecodePatch
7+
import app.revanced.patcher.util.smali.ExternalLabel
8+
import app.revanced.util.findFreeRegister
9+
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
10+
import java.util.logging.Logger
11+
12+
@Suppress("unused")
13+
val hideNavigationButtonsPatch = bytecodePatch(
14+
name = "Hide navigation buttons",
15+
description = "Hides navigation bar buttons, such as the Reels and Create button.",
16+
use = false
17+
) {
18+
compatibleWith("com.instagram.android")
19+
20+
val hideReels by booleanOption(
21+
key = "hideReels",
22+
default = true,
23+
title = "Hide Reels"
24+
)
25+
26+
val hideCreate by booleanOption(
27+
key = "hideCreate",
28+
default = true,
29+
title = "Hide Create"
30+
)
31+
32+
execute {
33+
if (!hideReels!! && !hideCreate!!) {
34+
return@execute Logger.getLogger(this::class.java.name).warning(
35+
"No hide navigation buttons options are enabled. No changes made."
36+
)
37+
}
38+
39+
tabCreateButtonsLoopStartFingerprint.method.apply {
40+
// Check the current loop index, and skip over adding the
41+
// navigation button view if the index matches a given button.
42+
43+
val startIndex = tabCreateButtonsLoopStartFingerprint.patternMatch!!.startIndex
44+
val endIndex = tabCreateButtonsLoopEndFingerprint.patternMatch!!.endIndex
45+
val insertIndex = startIndex + 1
46+
val loopIndexRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
47+
val freeRegister = findFreeRegister(insertIndex, loopIndexRegister)
48+
val instruction = getInstruction(endIndex - 1)
49+
50+
var instructions = buildString {
51+
if (hideCreate!!) {
52+
appendLine(
53+
"""
54+
const v$freeRegister, 0x2
55+
if-eq v$freeRegister, v$loopIndexRegister, :skipAddView
56+
"""
57+
)
58+
}
59+
60+
if (hideReels!!) {
61+
appendLine(
62+
"""
63+
const v$freeRegister, 0x3
64+
if-eq v$freeRegister, v$loopIndexRegister, :skipAddView
65+
"""
66+
)
67+
}
68+
}
69+
70+
addInstructionsWithLabels(
71+
insertIndex,
72+
instructions,
73+
ExternalLabel("skipAddView", instruction)
74+
)
75+
}
76+
}
77+
}
78+

0 commit comments

Comments
 (0)