mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 09:07:46 +01:00
fix: partial ad blockage in tiktok-ads
patch (#420)
This commit is contained in:
parent
0da4998c13
commit
a3b549b09e
2 changed files with 47 additions and 17 deletions
|
@ -0,0 +1,21 @@
|
||||||
|
package app.revanced.patches.tiktok.ad.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility
|
||||||
|
|
||||||
|
@Name("convert-help-v2-feeditemlist-fingerprint")
|
||||||
|
@MatchingMethod(
|
||||||
|
"Lbeancopy/ConvertHelp;",
|
||||||
|
"com${'$'}ss${'$'}ugc${'$'}aweme${'$'}proto${'$'}aweme_v2_feed_response${'$'}${'$'}com${'$'}ss${'$'}android${'$'}ugc${'$'}aweme${'$'}feed${'$'}model${'$'}FeedItemList",
|
||||||
|
)
|
||||||
|
@TiktokAdsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
object ConvertHelpFeedItemListFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.definingClass.endsWith("/ConvertHelp;") &&
|
||||||
|
methodDef.name.endsWith("${'$'}FeedItemList")
|
||||||
|
}
|
||||||
|
)
|
|
@ -11,6 +11,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||||
import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility
|
import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility
|
||||||
|
import app.revanced.patches.tiktok.ad.fingerprints.ConvertHelpFeedItemListFingerprint
|
||||||
import app.revanced.patches.tiktok.ad.fingerprints.FeedItemListCloneFingerprint
|
import app.revanced.patches.tiktok.ad.fingerprints.FeedItemListCloneFingerprint
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
@ -23,26 +24,34 @@ import org.jf.dexlib2.iface.reference.FieldReference
|
||||||
@TiktokAdsCompatibility
|
@TiktokAdsCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class TiktokAdsPatch : BytecodePatch(
|
class TiktokAdsPatch : BytecodePatch(
|
||||||
listOf(FeedItemListCloneFingerprint)
|
listOf(
|
||||||
|
FeedItemListCloneFingerprint,
|
||||||
|
ConvertHelpFeedItemListFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(data: BytecodeData): PatchResult {
|
override fun execute(data: BytecodeData): PatchResult {
|
||||||
val method = FeedItemListCloneFingerprint.result!!.mutableMethod
|
listOf(
|
||||||
// iterate all instructions in the clone method
|
FeedItemListCloneFingerprint,
|
||||||
for ((index, instruction) in method.implementation!!.instructions.withIndex()) {
|
ConvertHelpFeedItemListFingerprint
|
||||||
// conditions for the instruction we need
|
).forEach { fingerprint ->
|
||||||
if (instruction.opcode.ordinal != Opcode.IPUT_OBJECT.ordinal) continue
|
val method = fingerprint.result!!.mutableMethod
|
||||||
val clonePreloadAdsFieldInstruction = (instruction as? ReferenceInstruction)
|
// iterate all instructions in the clone method
|
||||||
if ((clonePreloadAdsFieldInstruction?.reference as? FieldReference)?.name != "preloadAds") continue
|
for ((index, instruction) in method.implementation!!.instructions.withIndex()) {
|
||||||
|
// conditions for the instruction we need
|
||||||
|
if (instruction.opcode.ordinal != Opcode.IPUT_OBJECT.ordinal) continue
|
||||||
|
val preloadAdsFieldInstruction = (instruction as? ReferenceInstruction)
|
||||||
|
if ((preloadAdsFieldInstruction?.reference as? FieldReference)?.name != "preloadAds") continue
|
||||||
|
|
||||||
// set null instead of the field "preloadAds"
|
// set null instead of the field "preloadAds"
|
||||||
val overrideRegister = (clonePreloadAdsFieldInstruction as TwoRegisterInstruction).registerA
|
val overrideRegister = (preloadAdsFieldInstruction as TwoRegisterInstruction).registerA
|
||||||
method.addInstruction(
|
method.addInstruction(
|
||||||
index,
|
index,
|
||||||
"const/4 v$overrideRegister, 0x0"
|
"const/4 v$overrideRegister, 0x0"
|
||||||
)
|
)
|
||||||
return PatchResultSuccess()
|
return@forEach
|
||||||
|
}
|
||||||
|
return PatchResultError("Can not find required instruction.")
|
||||||
}
|
}
|
||||||
|
return PatchResultSuccess()
|
||||||
return PatchResultError("Could not find required instruction.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue