mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 11:04:36 +02:00
fix(Reddit - Hide ads): Hide ads
patch fails on 2024.17.0
https://github.com/inotia00/ReVanced_Extended/issues/2592
This commit is contained in:
parent
0157537615
commit
1e13c4e83e
@ -17,12 +17,10 @@ import app.revanced.util.fingerprint.methodOrThrow
|
|||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.getWalkerMethod
|
import app.revanced.util.getWalkerMethod
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
import app.revanced.util.indexOfFirstStringInstruction
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
private const val RESOURCE_FILE_PATH = "res/layout/merge_listheader_link_detail.xml"
|
private const val RESOURCE_FILE_PATH = "res/layout/merge_listheader_link_detail.xml"
|
||||||
|
|
||||||
@ -113,13 +111,13 @@ val adsPatch = bytecodePatch(
|
|||||||
// The new feeds work by inserting posts into lists.
|
// The new feeds work by inserting posts into lists.
|
||||||
// AdElementConverter is conveniently responsible for inserting all feed ads.
|
// AdElementConverter is conveniently responsible for inserting all feed ads.
|
||||||
// By removing the appending instruction no ad posts gets appended to the feed.
|
// By removing the appending instruction no ad posts gets appended to the feed.
|
||||||
newAdPostFingerprint.methodOrThrow().apply {
|
val newAdPostMethod = newAdPostFingerprint.second.methodOrNull
|
||||||
val stringIndex =
|
?: newAdPostLegacyFingerprint.methodOrThrow()
|
||||||
indexOfFirstStringInstructionOrThrow("android_feed_freeform_render_variant")
|
|
||||||
val targetIndex = indexOfFirstInstructionOrThrow(stringIndex) {
|
newAdPostMethod.apply {
|
||||||
opcode == Opcode.INVOKE_VIRTUAL
|
val startIndex =
|
||||||
&& getReference<MethodReference>()?.toString() == "Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z"
|
0.coerceAtLeast(indexOfFirstStringInstruction("android_feed_freeform_render_variant"))
|
||||||
}
|
val targetIndex = indexOfAddArrayListInstruction(this, startIndex)
|
||||||
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
|
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
|
||||||
|
|
||||||
replaceInstruction(
|
replaceInstruction(
|
||||||
|
@ -6,6 +6,7 @@ import app.revanced.util.indexOfFirstInstruction
|
|||||||
import app.revanced.util.or
|
import app.revanced.util.or
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
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.MethodReference
|
||||||
|
|
||||||
internal val commentAdsFingerprint = legacyFingerprint(
|
internal val commentAdsFingerprint = legacyFingerprint(
|
||||||
@ -37,7 +38,7 @@ internal val adPostFingerprint = legacyFingerprint(
|
|||||||
"children",
|
"children",
|
||||||
"uxExperiences"
|
"uxExperiences"
|
||||||
),
|
),
|
||||||
customFingerprint = { method, classDef ->
|
customFingerprint = { _, classDef ->
|
||||||
classDef.type.endsWith("/Listing;")
|
classDef.type.endsWith("/Listing;")
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -51,9 +52,27 @@ internal val newAdPostFingerprint = legacyFingerprint(
|
|||||||
"android_feed_freeform_render_variant",
|
"android_feed_freeform_render_variant",
|
||||||
),
|
),
|
||||||
customFingerprint = { method, _ ->
|
customFingerprint = { method, _ ->
|
||||||
method.indexOfFirstInstruction {
|
indexOfAddArrayListInstruction(method) >= 0
|
||||||
getReference<MethodReference>()?.toString() == "Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z"
|
|
||||||
} >= 0
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
internal val newAdPostLegacyFingerprint = legacyFingerprint(
|
||||||
|
name = "newAdPostLegacyFingerprint",
|
||||||
|
returnType = "L",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
opcodes = listOf(Opcode.INVOKE_VIRTUAL),
|
||||||
|
strings = listOf(
|
||||||
|
"chain",
|
||||||
|
"feedElement"
|
||||||
|
),
|
||||||
|
customFingerprint = { method, classDef ->
|
||||||
|
classDef.sourceFile == "AdElementConverter.kt" &&
|
||||||
|
indexOfAddArrayListInstruction(method) >= 0
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
internal fun indexOfAddArrayListInstruction(method: Method, index: Int = 0) =
|
||||||
|
method.indexOfFirstInstruction(index) {
|
||||||
|
getReference<MethodReference>()?.toString() == "Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z"
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user