Skip to content

Commit a331f0a

Browse files
seaqueoSumAtrIX
andauthored
feat(Messenger): Add Hide inbox subtabs patch (#3163)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent 2f54118 commit a331f0a

File tree

7 files changed

+77
-26
lines changed

7 files changed

+77
-26
lines changed

api/revanced-patches.api

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,26 @@ public final class app/revanced/patches/memegenerator/misc/pro/UnlockProVersionP
277277
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
278278
}
279279

280-
public final class app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch : app/revanced/patcher/patch/BytecodePatch {
281-
public static final field INSTANCE Lapp/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch;
280+
public final class app/revanced/patches/messenger/inbox/HideInboxAdsPatch : app/revanced/patcher/patch/BytecodePatch {
281+
public static final field INSTANCE Lapp/revanced/patches/messenger/inbox/HideInboxAdsPatch;
282282
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
283283
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
284284
}
285285

286-
public final class app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerPatch : app/revanced/patcher/patch/BytecodePatch {
287-
public static final field INSTANCE Lapp/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerPatch;
286+
public final class app/revanced/patches/messenger/inbox/HideInboxSubtabsPatch : app/revanced/patcher/patch/BytecodePatch {
287+
public static final field INSTANCE Lapp/revanced/patches/messenger/inbox/HideInboxSubtabsPatch;
288288
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
289289
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
290290
}
291291

292-
public final class app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicatorPatch : app/revanced/patcher/patch/BytecodePatch {
293-
public static final field INSTANCE Lapp/revanced/patches/messenger/inputfield/patch/DisableTypingIndicatorPatch;
292+
public final class app/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch : app/revanced/patcher/patch/BytecodePatch {
293+
public static final field INSTANCE Lapp/revanced/patches/messenger/inputfield/DisableSwitchingEmojiToStickerPatch;
294+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
295+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
296+
}
297+
298+
public final class app/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch : app/revanced/patcher/patch/BytecodePatch {
299+
public static final field INSTANCE Lapp/revanced/patches/messenger/inputfield/DisableTypingIndicatorPatch;
294300
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
295301
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
296302
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
package app.revanced.patches.messenger.ads.inbox.patch
1+
package app.revanced.patches.messenger.inbox
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
65
import app.revanced.patcher.patch.BytecodePatch
76
import app.revanced.patcher.patch.annotation.CompatiblePackage
87
import app.revanced.patcher.patch.annotation.Patch
9-
import app.revanced.patches.messenger.ads.inbox.fingerprints.LoadInboxAdsFingerprint
8+
import app.revanced.patches.messenger.inbox.fingerprints.LoadInboxAdsFingerprint
9+
import app.revanced.util.exception
1010

1111
@Patch(
1212
name = "Hide inbox ads",
1313
description = "Hides ads in inbox.",
14-
compatiblePackages = [CompatiblePackage("com.facebook.orca")]
14+
compatiblePackages = [CompatiblePackage("com.facebook.orca")],
1515
)
1616
@Suppress("unused")
1717
object HideInboxAdsPatch : BytecodePatch(
18-
setOf(LoadInboxAdsFingerprint)
18+
setOf(LoadInboxAdsFingerprint),
1919
) {
2020
override fun execute(context: BytecodeContext) {
2121
LoadInboxAdsFingerprint.result?.mutableMethod?.apply {
2222
this.replaceInstruction(0, "return-void")
2323
} ?: throw LoadInboxAdsFingerprint.exception
2424
}
2525
}
26-
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package app.revanced.patches.messenger.inbox
2+
3+
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
5+
import app.revanced.patcher.patch.BytecodePatch
6+
import app.revanced.patcher.patch.annotation.CompatiblePackage
7+
import app.revanced.patcher.patch.annotation.Patch
8+
import app.revanced.patches.messenger.inbox.fingerprints.CreateInboxSubTabsFingerprint
9+
import app.revanced.util.exception
10+
11+
@Patch(
12+
name = "Hide inbox subtabs",
13+
description = "Hides Home and Channels tabs between active now tray and chats.",
14+
compatiblePackages = [CompatiblePackage("com.facebook.orca")],
15+
)
16+
@Suppress("unused")
17+
object HideInboxSubtabsPatch : BytecodePatch(
18+
setOf(CreateInboxSubTabsFingerprint),
19+
) {
20+
// Set InboxSubtabsItemSupplierImplementation boolean attribute to false.
21+
override fun execute(context: BytecodeContext) = CreateInboxSubTabsFingerprint.result?.mutableMethod
22+
?.replaceInstruction(2, "const/4 v0, 0x0")
23+
?: throw CreateInboxSubTabsFingerprint.exception
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package app.revanced.patches.messenger.inbox.fingerprints
2+
3+
import app.revanced.patcher.extensions.or
4+
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
6+
import com.android.tools.smali.dexlib2.Opcode
7+
import com.android.tools.smali.dexlib2.iface.value.StringEncodedValue
8+
9+
internal object CreateInboxSubTabsFingerprint : MethodFingerprint(
10+
returnType = "V",
11+
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
12+
opcodes = listOf(
13+
Opcode.CONST_4,
14+
Opcode.INVOKE_VIRTUAL,
15+
Opcode.RETURN_VOID,
16+
),
17+
customFingerprint = { methodDef, classDef ->
18+
methodDef.name == "run" && classDef.fields.any any@{ field ->
19+
if (field.name != "__redex_internal_original_name") return@any false
20+
(field.initialValue as? StringEncodedValue)?.value == "InboxSubtabsItemSupplierImplementation\$onSubscribe\$1"
21+
}
22+
},
23+
)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.messenger.ads.inbox.fingerprints
1+
package app.revanced.patches.messenger.inbox.fingerprints
22

33
import app.revanced.patcher.extensions.or
44
import app.revanced.patcher.fingerprint.MethodFingerprint
@@ -8,11 +8,10 @@ internal object LoadInboxAdsFingerprint : MethodFingerprint(
88
returnType = "V",
99
strings = listOf(
1010
"ads_load_begin",
11-
"inbox_ads_fetch_start"
11+
"inbox_ads_fetch_start",
1212
),
1313
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
1414
customFingerprint = { methodDef, _ ->
1515
methodDef.definingClass == "Lcom/facebook/messaging/business/inboxads/plugins/inboxads/itemsupplier/InboxAdsItemSupplierImplementation;"
16-
}
16+
},
1717
)
18-
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
package app.revanced.patches.messenger.inputfield.patch
1+
package app.revanced.patches.messenger.inputfield
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
65
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
76
import app.revanced.patcher.patch.BytecodePatch
87
import app.revanced.patcher.patch.annotation.CompatiblePackage
98
import app.revanced.patcher.patch.annotation.Patch
109
import app.revanced.patches.messenger.inputfield.fingerprints.SwitchMessangeInputEmojiButtonFingerprint
10+
import app.revanced.util.exception
1111
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
1212

1313
@Patch(
1414
name = "Disable switching emoji to sticker",
1515
description = "Disables switching from emoji to sticker search mode in message input field.",
16-
compatiblePackages = [CompatiblePackage("com.facebook.orca")]
16+
compatiblePackages = [CompatiblePackage("com.facebook.orca")],
1717
)
1818
@Suppress("unused")
1919
object DisableSwitchingEmojiToStickerPatch : BytecodePatch(
20-
setOf(SwitchMessangeInputEmojiButtonFingerprint)
20+
setOf(SwitchMessangeInputEmojiButtonFingerprint),
2121
) {
2222
override fun execute(context: BytecodeContext) {
2323
SwitchMessangeInputEmojiButtonFingerprint.result?.let {
@@ -28,7 +28,7 @@ object DisableSwitchingEmojiToStickerPatch : BytecodePatch(
2828

2929
replaceInstruction(
3030
setStringIndex,
31-
"const-string v$targetRegister, \"expression\""
31+
"const-string v$targetRegister, \"expression\"",
3232
)
3333
}
3434
} ?: throw SwitchMessangeInputEmojiButtonFingerprint.exception
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
package app.revanced.patches.messenger.inputfield.patch
1+
package app.revanced.patches.messenger.inputfield
22

3-
import app.revanced.util.exception
43
import app.revanced.patcher.data.BytecodeContext
54
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
65
import app.revanced.patcher.patch.BytecodePatch
76
import app.revanced.patcher.patch.annotation.CompatiblePackage
87
import app.revanced.patcher.patch.annotation.Patch
98
import app.revanced.patches.messenger.inputfield.fingerprints.SendTypingIndicatorFingerprint
9+
import app.revanced.util.exception
1010

1111
@Patch(
1212
name = "Disable typing indicator",
1313
description = "Disables the indicator while typing a message.",
14-
compatiblePackages = [CompatiblePackage("com.facebook.orca")]
14+
compatiblePackages = [CompatiblePackage("com.facebook.orca")],
1515
)
1616
@Suppress("unused")
1717
object DisableTypingIndicatorPatch : BytecodePatch(
18-
setOf(SendTypingIndicatorFingerprint)
19-
){
18+
setOf(SendTypingIndicatorFingerprint),
19+
) {
2020
override fun execute(context: BytecodeContext) {
2121
SendTypingIndicatorFingerprint.result?.mutableMethod?.replaceInstruction(0, "return-void")
2222
?: throw SendTypingIndicatorFingerprint.exception

0 commit comments

Comments
 (0)