mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-23 18:37:14 +02:00
fix(reddit/hide-comment-ads): patch is broken in certain versions
This commit is contained in:
parent
d261e2cb6b
commit
6f3f00993d
@ -3,9 +3,19 @@ package app.revanced.patches.reddit.ad.comments.fingerprints
|
|||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object HideCommentAdsFingerprint : MethodFingerprint(
|
object HideCommentAdsFingerprint : MethodFingerprint(
|
||||||
returnType = "Ljava/lang/Object;",
|
returnType = "L",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("RedditCommentsPageAdRepository;") },
|
parameters = listOf("L"),
|
||||||
)
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.RETURN_OBJECT
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass.endsWith("/PostDetailPresenter\$loadAd\$1;")
|
||||||
|
&& methodDef.name == "invokeSuspend"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@ -5,11 +5,13 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.data.toMethodWalker
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint
|
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint
|
||||||
|
|
||||||
@Name("hide-comment-ads")
|
@Name("hide-comment-ads")
|
||||||
@ -21,10 +23,15 @@ class HideCommentAdsPatch : BytecodePatch(
|
|||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
HideCommentAdsFingerprint.result?.let {
|
HideCommentAdsFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
with(
|
||||||
|
context
|
||||||
|
.toMethodWalker(it.method)
|
||||||
|
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
|
||||||
|
.getMethod() as MutableMethod
|
||||||
|
) {
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
0,
|
0, """
|
||||||
"""
|
|
||||||
new-instance v0, Ljava/lang/Object;
|
new-instance v0, Ljava/lang/Object;
|
||||||
invoke-direct {v0}, Ljava/lang/Object;-><init>()V
|
invoke-direct {v0}, Ljava/lang/Object;-><init>()V
|
||||||
return-object v0
|
return-object v0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user