fix(Reddit - Hide ads): Update patch for new versions of Reddit (#6342)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
g9q
2025-12-17 20:01:25 -06:00
committed by GitHub
parent c825ebda37
commit f8bd1239cc
4 changed files with 9 additions and 27 deletions

View File

@@ -3,12 +3,8 @@ package app.revanced.patches.reddit.ad.comments
import app.revanced.patcher.fingerprint
internal val hideCommentAdsFingerprint = fingerprint {
strings(
"link",
// CommentPageRepository is not returning a link object
"is not returning a link object"
)
custom { _, classDef ->
classDef.sourceFile == "PostDetailPresenter.kt"
custom { method, classDef ->
method.name == "invokeSuspend" &&
classDef.contains("LoadAdsCombinedCall")
}
}
}

View File

@@ -1,6 +1,6 @@
package app.revanced.patches.reddit.ad.comments
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
import app.revanced.patcher.patch.bytecodePatch
val hideCommentAdsPatch = bytecodePatch(
@@ -8,13 +8,6 @@ val hideCommentAdsPatch = bytecodePatch(
) {
execute {
hideCommentAdsFingerprint.method.addInstructions(
0,
"""
new-instance v0, Ljava/lang/Object;
invoke-direct {v0}, Ljava/lang/Object;-><init>()V
return-object v0
""",
)
hideCommentAdsFingerprint.method.replaceInstructions(0, "return-object p1")
}
}

View File

@@ -12,6 +12,5 @@ internal val adPostFingerprint = fingerprint {
internal val newAdPostFingerprint = fingerprint {
opcodes(Opcode.INVOKE_VIRTUAL)
strings("chain", "feedElement")
custom { _, classDef -> classDef.sourceFile == "AdElementConverter.kt" }
strings("feedElement", "com.reddit.cookie")
}

View File

@@ -3,7 +3,6 @@ package app.revanced.patches.reddit.ad.general
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.reddit.ad.banner.hideBannerPatch
import app.revanced.patches.reddit.ad.comments.hideCommentAdsPatch
import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch
import com.android.tools.smali.dexlib2.Opcode
@@ -16,14 +15,9 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
val hideAdsPatch = bytecodePatch(
name = "Hide ads",
) {
dependsOn(hideBannerPatch, hideCommentAdsPatch, sharedExtensionPatch)
dependsOn(hideCommentAdsPatch, sharedExtensionPatch)
// Note that for now, this patch and anything using it will only work on
// Reddit 2024.17.0 or older. Newer versions will crash during patching.
// See https://github.com/ReVanced/revanced-patches/issues/3099
// and https://github.com/iBotPeaches/Apktool/issues/3534.
// This constraint is necessary due to dependency on hideBannerPatch.
compatibleWith("com.reddit.frontpage"("2024.17.0"))
compatibleWith("com.reddit.frontpage")
execute {
// region Filter promoted ads (does not work in popular or latest feed)