fix(Reddit - Hide ads): Hide comment ads does not work https://github.com/inotia00/ReVanced_Extended/issues/2884

This commit is contained in:
inotia00 2025-03-29 16:56:21 +09:00
parent 4feff6b150
commit 4330b7f6df
2 changed files with 25 additions and 9 deletions

View File

@ -27,14 +27,6 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"$PATCHES_PATH/GeneralAdsPatch;"
private val isCommentAdsMethod: Method.() -> Boolean = {
parameterTypes.size == 1 &&
parameterTypes.first().startsWith("Lcom/reddit/ads/conversation/") &&
accessFlags == AccessFlags.PUBLIC or AccessFlags.FINAL &&
returnType == "V" &&
indexOfFirstStringInstruction("ad") >= 0
}
@Suppress("unused")
val adsPatch = bytecodePatch(
HIDE_ADS.title,
@ -94,11 +86,20 @@ val adsPatch = bytecodePatch(
if (is_2025_06_or_greater) {
listOf(
commentAdCommentScreenAdViewFingerprint,
commentAdDetailListHeaderViewFingerprint
commentAdDetailListHeaderViewFingerprint,
commentsViewModelFingerprint
).forEach { fingerprint ->
fingerprint.methodOrThrow().hook()
}
} else {
val isCommentAdsMethod: Method.() -> Boolean = {
parameterTypes.size == 1 &&
parameterTypes.first().startsWith("Lcom/reddit/ads/conversation/") &&
accessFlags == AccessFlags.PUBLIC or AccessFlags.FINAL &&
returnType == "V" &&
indexOfFirstStringInstruction("ad") >= 0
}
classes.forEach { classDef ->
classDef.methods.forEach { method ->
if (method.isCommentAdsMethod()) {

View File

@ -8,6 +8,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
internal val adPostFingerprint = legacyFingerprint(
name = "adPostFingerprint",
@ -49,6 +50,20 @@ internal val commentAdDetailListHeaderViewFingerprint = legacyFingerprint(
},
)
internal val commentsViewModelFingerprint = legacyFingerprint(
name = "commentsViewModelFingerprint",
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L", "Z", "L", "I"),
customFingerprint = { method, classDef ->
classDef.superclass == "Lcom/reddit/screen/presentation/CompositionViewModel;" &&
method.indexOfFirstInstruction {
opcode == Opcode.NEW_INSTANCE &&
getReference<TypeReference>()?.type?.startsWith("Lcom/reddit/postdetail/comment/refactor/CommentsViewModel\$LoadAdsSeparately\$") == true
} >= 0
},
)
internal val newAdPostFingerprint = legacyFingerprint(
name = "newAdPostFingerprint",
returnType = "L",