From 647756008ea35a64c0928d104b19eeb00ed90a5c Mon Sep 17 00:00:00 2001 From: naijun0403 Date: Sun, 4 May 2025 03:14:33 +0900 Subject: [PATCH] feat(kakaotalk): Add patch to remove shop tab from the bottom navigation bar --- patches/api/patches.api | 4 ++ .../kakaotalk/misc/RemoveShopTabPatch.kt | 45 +++++++++++++++++++ .../fingerprints/RemoveShopTabFingerprint.kt | 35 +++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/RemoveShopTabPatch.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/RemoveShopTabFingerprint.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index 5d785ffd1..c22dfd05d 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -257,6 +257,10 @@ public final class app/revanced/patches/kakaotalk/chatroom/Remove300PlusLimitPat public static final fun getRemove300PlusLimitOpenChatRoomPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/kakaotalk/misc/RemoveShopTabPatchKt { + public static final fun getRemoveShopTabPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/kakaotalk/signature/VerifyingSignaturePatchKt { public static final fun getVerifyingSignaturePatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/RemoveShopTabPatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/RemoveShopTabPatch.kt new file mode 100644 index 000000000..34f168edd --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/RemoveShopTabPatch.kt @@ -0,0 +1,45 @@ +package app.revanced.patches.kakaotalk.misc + +import app.revanced.patcher.extensions.InstructionExtensions.instructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.patch.Package +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.kakaotalk.misc.fingerprints.removeShopTabFingerprint +import app.revanced.util.getReference +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c +import com.android.tools.smali.dexlib2.iface.reference.FieldReference +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +val removeShopTabPatch = bytecodePatch( + name = "Remove shop tab", + description = "Removes the shop tab from the bottom navigation bar.", +) { + compatibleWith(Package("com.kakao.talk", setOf("25.3.5"))) + + execute { + val method = removeShopTabFingerprint.method + val insns = method.instructions + + val matches = insns.mapIndexedNotNull { idx, inst -> + if (inst is BuilderInstruction35c + && inst.opcode == Opcode.INVOKE_VIRTUAL + && (inst.getReference()?.name == "add") + ) { + val prev = insns.getOrNull(idx - 1) as? BuilderInstruction21c + val fldName = (prev?.reference as? FieldReference)?.name + if (fldName == "SHOPPING_TAB" || fldName == "CALL_TAB") { + Pair(idx - 1, idx) + } else null + } else null + } + + matches + .sortedByDescending { it.second } + .forEach { (loadIdx, invokeIdx) -> + method.removeInstruction(invokeIdx) + method.removeInstruction(loadIdx) + } + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/RemoveShopTabFingerprint.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/RemoveShopTabFingerprint.kt new file mode 100644 index 000000000..6418a054d --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/misc/fingerprints/RemoveShopTabFingerprint.kt @@ -0,0 +1,35 @@ +package app.revanced.patches.kakaotalk.misc.fingerprints + +import app.revanced.patcher.extensions.InstructionExtensions.instructions +import app.revanced.patcher.fingerprint +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable +import app.revanced.util.getReference +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.reference.StringReference + +internal val removeShopTabFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("V") + parameters() + strings("webtoon") +// custom { method, classDef -> +// !method.toMutable().instructions.any { +// it.opcode == Opcode.CONST_STRING && !it.getReference()!!.string.contains("webtoon") +// } +// } + opcodes( + Opcode.IGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.SGET_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT, + Opcode.CONST_4, + Opcode.IF_EQZ, + Opcode.SGET_OBJECT, + Opcode.GOTO, + ) +} \ No newline at end of file