mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-26 12:11:02 +00:00
refactor(reddit): HideCommentAdsPatch
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user