mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-29 22:24:31 +02:00
fix(Reddit - Remove subreddit dialog): Can't open post from search results
This commit is contained in:
parent
3f9edca15d
commit
15db05c636
@ -33,6 +33,10 @@ public class RemoveSubRedditDialogPatch {
|
||||
clickViewDelayed(cancelButtonView);
|
||||
}
|
||||
|
||||
public static boolean spoofHasBeenVisitedStatus(boolean hasBeenVisited) {
|
||||
return Settings.REMOVE_NSFW_DIALOG.get() || hasBeenVisited;
|
||||
}
|
||||
|
||||
public static void dismissNSFWDialog(Object customDialog) {
|
||||
if (Settings.REMOVE_NSFW_DIALOG.get() &&
|
||||
customDialog instanceof Dialog dialog) {
|
||||
|
@ -10,7 +10,6 @@ import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
|
||||
|
||||
internal val frequentUpdatesSheetScreenFingerprint = legacyFingerprint(
|
||||
name = "frequentUpdatesSheetScreenFingerprint",
|
||||
@ -54,13 +53,6 @@ fun listOfIsLoggedInInstruction(method: Method) =
|
||||
?.reversed()
|
||||
?: emptyList()
|
||||
|
||||
fun indexOfGetOverInstruction(method: Method) =
|
||||
method.indexOfFirstInstruction {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference?.name == "getOver18"
|
||||
}
|
||||
|
||||
internal val nsfwAlertEmitFingerprint = legacyFingerprint(
|
||||
name = "nsfwAlertEmitFingerprint",
|
||||
returnType = "Ljava/lang/Object;",
|
||||
@ -68,24 +60,17 @@ internal val nsfwAlertEmitFingerprint = legacyFingerprint(
|
||||
strings = listOf("reddit://reddit/r/", "nsfwAlertDelegate"),
|
||||
customFingerprint = { method, _ ->
|
||||
method.name == "emit" &&
|
||||
indexOfGetOverInstruction(method) >= 0
|
||||
indexOfHasBeenVisitedInstruction(method) >= 0
|
||||
}
|
||||
)
|
||||
|
||||
internal val nsfwAlertObserverFingerprint = legacyFingerprint(
|
||||
name = "nsfwAlertObserverFingerprint",
|
||||
returnType = "Ljava/lang/Object;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf("nsfwAlertDelegate"),
|
||||
customFingerprint = { method, _ ->
|
||||
method.name == "invokeSuspend" &&
|
||||
indexOfGetOverInstruction(method) >= 0 &&
|
||||
method.indexOfFirstInstruction {
|
||||
opcode == Opcode.NEW_INSTANCE &&
|
||||
getReference<TypeReference>()?.type?.startsWith("Lcom/reddit/frontpage/presentation/detail/DetailHolderPresenter\$showDialogIfNeverVisitedOrSubscribed\$") == true
|
||||
} >= 0
|
||||
fun indexOfHasBeenVisitedInstruction(method: Method) =
|
||||
method.indexOfFirstInstruction {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference?.name == "getHasBeenVisited" &&
|
||||
reference.returnType == "Z"
|
||||
}
|
||||
)
|
||||
|
||||
internal val nsfwAlertBuilderFingerprint = legacyFingerprint(
|
||||
name = "nsfwAlertBuilderFingerprint",
|
||||
|
@ -2,11 +2,9 @@ package app.revanced.patches.reddit.layout.subredditdialog
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
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.REMOVE_SUBREDDIT_DIALOG
|
||||
@ -17,7 +15,6 @@ import app.revanced.patches.reddit.utils.settings.is_2025_05_or_greater
|
||||
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.findFreeRegister
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
import app.revanced.util.fingerprint.mutableClassOrThrow
|
||||
import app.revanced.util.getReference
|
||||
@ -80,26 +77,17 @@ val subRedditDialogPatch = bytecodePatch(
|
||||
}
|
||||
|
||||
if (is_2025_01_or_greater) {
|
||||
arrayOf(
|
||||
nsfwAlertEmitFingerprint,
|
||||
nsfwAlertObserverFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.methodOrThrow().apply {
|
||||
val getOverIndex = indexOfGetOverInstruction(this)
|
||||
val getOverRegister = getInstruction<FiveRegisterInstruction>(getOverIndex).registerC
|
||||
val freeRegister = findFreeRegister(getOverIndex, getOverRegister)
|
||||
nsfwAlertEmitFingerprint.methodOrThrow().apply {
|
||||
val hasBeenVisitedIndex = indexOfHasBeenVisitedInstruction(this)
|
||||
val hasBeenVisitedRegister =
|
||||
getInstruction<OneRegisterInstruction>(hasBeenVisitedIndex + 1).registerA
|
||||
|
||||
val returnIndex = indexOfFirstInstructionOrThrow(getOverIndex, Opcode.RETURN_OBJECT)
|
||||
val jumpIndex = indexOfFirstInstructionReversedOrThrow(returnIndex, Opcode.SGET_OBJECT)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
getOverIndex, """
|
||||
invoke-static {}, $EXTENSION_CLASS_DESCRIPTOR->removeNSFWDialog()Z
|
||||
move-result v$freeRegister
|
||||
if-nez v$freeRegister, :jump
|
||||
""", ExternalLabel("jump", getInstruction(jumpIndex))
|
||||
)
|
||||
}
|
||||
addInstructions(
|
||||
hasBeenVisitedIndex + 2, """
|
||||
invoke-static {v$hasBeenVisitedRegister}, $EXTENSION_CLASS_DESCRIPTOR->spoofHasBeenVisitedStatus(Z)Z
|
||||
move-result v$hasBeenVisitedRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
var hookCount = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user