feat(kakaotalk): add patch and fingerprint to remove More tab ad

This commit is contained in:
2025-05-21 02:45:44 +09:00
parent dd45ddde80
commit 3f868cd995
3 changed files with 95 additions and 0 deletions

View File

@ -252,6 +252,10 @@ public final class app/revanced/patches/kakaotalk/ads/RemoveFocusAdPatchKt {
public static final fun getRemoveFocusAdPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/kakaotalk/ads/RemoveMoreTabAdPatchKt {
public static final fun getRemoveMoreTabAdPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/kakaotalk/ads/RemoveOlkChatRoomListAdPatchKt {
public static final fun getRemoveOlkChatRoomListAdPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

View File

@ -0,0 +1,45 @@
package app.revanced.patches.kakaotalk.ads
import app.revanced.patcher.extensions.InstructionExtensions.instructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.kakaotalk.ads.fingerprints.adBigUIModelFingerprint
import app.revanced.patches.kakaotalk.ads.fingerprints.addSectionToMoreTabUIFingerprint
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
val removeMoreTabAdPatch = bytecodePatch(
name = "Remove More tab ad",
description = "Removes the ad from the More tab.",
) {
compatibleWith("com.kakao.talk"("25.4.2"))
execute {
val addSectionToMoreTabUIMethod = addSectionToMoreTabUIFingerprint.method
val addSectionToMoreTabUIInsns = addSectionToMoreTabUIMethod.instructions
val adBigUIModelClass = adBigUIModelFingerprint.method.definingClass
val matches = addSectionToMoreTabUIInsns.mapIndexedNotNull { idx, inst ->
if (inst is BuilderInstruction35c
&& inst.opcode == Opcode.INVOKE_VIRTUAL
&& (inst.getReference<MethodReference>()?.name == "add")
) {
val prev = addSectionToMoreTabUIInsns.getOrNull(idx - 1) as? BuilderInstruction35c
val ref = (prev?.getReference<MethodReference>())
if (ref?.definingClass == adBigUIModelClass) {
Pair(idx - 1, idx)
} else null
} else null
}
matches
.sortedByDescending { it.second }
.forEach { (loadIdx, invokeIdx) ->
addSectionToMoreTabUIMethod.removeInstruction(invokeIdx)
addSectionToMoreTabUIMethod.removeInstruction(loadIdx)
}
}
}

View File

@ -0,0 +1,46 @@
package app.revanced.patches.kakaotalk.ads.fingerprints
import app.revanced.patcher.fingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
internal val addSectionToMoreTabUIFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters("Ljava/lang/Object;")
returns("Ljava/lang/Object;")
strings(
"call to \'resume\' before \'invoke\' with coroutine",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.KakaoPayUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.WalletUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.WeatherUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.KakaoNowUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.TalkManualUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.ServiceGroupUiModel",
"null cannot be cast to non-null type com.kakao.talk.moretab.ui.model.WalletBannerUiModel",
"null cannot be cast to non-null type kotlin.Boolean",
)
opcodes(
Opcode.SGET_OBJECT,
Opcode.IGET,
Opcode.CONST_4,
Opcode.IF_EQZ,
)
}
internal val adBigUIModelFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters()
returns("Ljava/lang/String;")
strings(
"AdBig(uiModel=",
)
opcodes(
Opcode.NEW_INSTANCE,
Opcode.CONST_STRING,
Opcode.INVOKE_DIRECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.CONST_STRING,
)
custom { method, classDef -> method.name == "toString" }
}