refactor(reddit): HideCommentAdsPatch

This commit is contained in:
Pun Butrach
2026-01-12 15:07:36 +07:00
parent f8e912f937
commit da08df7d9e
2 changed files with 12 additions and 9 deletions

View File

@@ -1,10 +1,11 @@
package app.revanced.patches.reddit.ad.comments
import app.revanced.patcher.fingerprint
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.definingClass
import app.revanced.patcher.name
import app.revanced.patcher.patch.BytecodePatchContext
internal val hideCommentAdsFingerprint = fingerprint {
custom { method, classDef ->
method.name == "invokeSuspend" &&
classDef.contains("LoadAdsCombinedCall")
}
internal val BytecodePatchContext.hideCommentAdsMethod by gettingFirstMutableMethodDeclaratively {
name("invokeSuspend")
definingClass("LoadAdsCombinedCall"::contains)
}

View File

@@ -2,12 +2,14 @@ package app.revanced.patches.reddit.ad.comments
import app.revanced.patcher.extensions.replaceInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.creatingBytecodePatch
val hideCommentAdsPatch = bytecodePatch(
description = "Removes ads in the comments.",
@Suppress("unused", "ObjectPropertyName")
val `Hide comment ads` by creatingBytecodePatch(
description = "Removes ads in the comments."
) {
apply {
hideCommentAdsFingerprint.method.replaceInstructions(0, "return-object p1")
hideCommentAdsMethod.replaceInstructions(0, "return-object p1")
}
}