diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/AdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/AdsPatch.kt index 8c4c9cdbf..51c8c7e54 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/AdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/AdsPatch.kt @@ -5,9 +5,11 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH import app.revanced.patches.reddit.utils.patch.PatchList.HIDE_ADS +import app.revanced.patches.reddit.utils.settings.is_2025_06_or_greater import app.revanced.patches.reddit.utils.settings.settingsPatch import app.revanced.patches.reddit.utils.settings.updatePatchStatus import app.revanced.util.findMutableMethodOf @@ -78,22 +80,33 @@ val adsPatch = bytecodePatch( } // region Filter comment ads - classes.forEach { classDef -> - classDef.methods.forEach { method -> - if (method.isCommentAdsMethod()) { - proxy(classDef) - .mutableClass - .findMutableMethodOf(method) - .addInstructionsWithLabels( - 0, """ - invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->hideCommentAds()Z - move-result v0 - if-eqz v0, :show - return-void - :show - nop - """ - ) + fun MutableMethod.hook() = + addInstructionsWithLabels( + 0, """ + invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->hideCommentAds()Z + move-result v0 + if-eqz v0, :show + return-void + :show + nop + """ + ) + if (is_2025_06_or_greater) { + listOf( + commentAdCommentScreenAdViewFingerprint, + commentAdDetailListHeaderViewFingerprint + ).forEach { fingerprint -> + fingerprint.methodOrThrow().hook() + } + } else { + classes.forEach { classDef -> + classDef.methods.forEach { method -> + if (method.isCommentAdsMethod()) { + proxy(classDef) + .mutableClass + .findMutableMethodOf(method) + .hook() + } } } } diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/Fingerprints.kt index fb5f5d21b..70df18225 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/ad/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/ad/Fingerprints.kt @@ -27,6 +27,28 @@ internal val adPostFingerprint = legacyFingerprint( }, ) +internal val commentAdCommentScreenAdViewFingerprint = legacyFingerprint( + name = "commentAdCommentScreenAdViewFingerprint", + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + strings = listOf("ad"), + customFingerprint = { _, classDef -> + classDef.type.endsWith("/CommentScreenAdView;") + }, +) + +internal val commentAdDetailListHeaderViewFingerprint = legacyFingerprint( + name = "commentAdDetailListHeaderViewFingerprint", + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf("L"), + strings = listOf("ad"), + customFingerprint = { _, classDef -> + classDef.type.endsWith("/DetailListHeaderView;") + }, +) + internal val newAdPostFingerprint = legacyFingerprint( name = "newAdPostFingerprint", returnType = "L",