fix: Revert previous release
The previous release depends on a version of ReVanced Patcher which prevents usage of resource patches on lower Android versions. To solve this issue temporarily, until a fix is present, the previous release is reverted.
This commit is contained in:
@@ -3,12 +3,14 @@ package app.revanced.patches.reddit.ad.banner.patch
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
|
||||
@Name("Hide subreddit banner")
|
||||
@Description("Hides banner ads from comments on subreddits.")
|
||||
class HideBannerPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext) {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
context.xmlEditor[RESOURCE_FILE_PATH].use {
|
||||
it.file.getElementsByTagName("merge").item(0).childNodes.apply {
|
||||
val attributes = arrayOf("height", "width")
|
||||
@@ -28,6 +30,8 @@ class HideBannerPatch : ResourcePatch {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
+4
-1
@@ -5,6 +5,8 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint
|
||||
|
||||
@Name("Hide comment ads")
|
||||
@@ -12,7 +14,7 @@ import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFinger
|
||||
class HideCommentAdsPatch : BytecodePatch(
|
||||
listOf(HideCommentAdsFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val method = HideCommentAdsFingerprint.result!!.mutableMethod
|
||||
// Returns a blank object instead of the comment ad.
|
||||
method.addInstructions(
|
||||
@@ -23,5 +25,6 @@ class HideCommentAdsPatch : BytecodePatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.reddit.ad.general.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object NewAdPostFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(Opcode.INVOKE_VIRTUAL),
|
||||
|
||||
@@ -6,6 +6,8 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
||||
@@ -14,11 +16,11 @@ import app.revanced.patches.reddit.ad.comments.patch.HideCommentAdsPatch
|
||||
import app.revanced.patches.reddit.ad.general.annotations.HideAdsCompatibility
|
||||
import app.revanced.patches.reddit.ad.general.fingerprints.AdPostFingerprint
|
||||
import app.revanced.patches.reddit.ad.general.fingerprints.NewAdPostFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@Name("Hide ads")
|
||||
@@ -29,7 +31,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
class HideAdsPatch : BytecodePatch(
|
||||
listOf(AdPostFingerprint, NewAdPostFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// region Filter promoted ads (does not work in popular or latest feed)
|
||||
|
||||
AdPostFingerprint.result?.mutableMethod?.apply {
|
||||
@@ -76,6 +78,8 @@ class HideAdsPatch : BytecodePatch(
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
+17
-13
@@ -1,14 +1,11 @@
|
||||
package app.revanced.patches.reddit.customclients
|
||||
|
||||
import android.os.Environment
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.OptionsContainer
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.PatchOption
|
||||
import app.revanced.patcher.patch.*
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractSpoofClientPatch(
|
||||
@@ -20,13 +17,13 @@ abstract class AbstractSpoofClientPatch(
|
||||
addAll(clientIdFingerprints)
|
||||
userAgentFingerprints?.let(::addAll)
|
||||
}) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
if (options.clientId == null) {
|
||||
// Ensure device runs Android.
|
||||
try {
|
||||
Class.forName("android.os.Environment")
|
||||
} catch (e: ClassNotFoundException) {
|
||||
throw PatchException("No client ID provided")
|
||||
return PatchResultError("No client ID provided")
|
||||
}
|
||||
|
||||
File(Environment.getExternalStorageDirectory(), "reddit_client_id_revanced.txt").also {
|
||||
@@ -34,23 +31,29 @@ abstract class AbstractSpoofClientPatch(
|
||||
|
||||
val error = """
|
||||
In order to use this patch, you need to provide a client ID.
|
||||
You can do that by creating a file at ${it.absolutePath} with the client ID as its content.
|
||||
You can do this by creating a file at ${it.absolutePath} with the client ID as its content.
|
||||
Alternatively, you can provide the client ID using patch options.
|
||||
|
||||
You can get your client ID from https://www.reddit.com/prefs/apps.
|
||||
The application type has to be "Installed app" and the redirect URI has to be set to "$redirectUri".
|
||||
""".trimIndent()
|
||||
|
||||
throw PatchException(error)
|
||||
return PatchResultError(error)
|
||||
}.let { options.clientId = it.readText().trim() }
|
||||
}
|
||||
|
||||
fun List<MethodFingerprint>?.executePatch(
|
||||
patch: List<MethodFingerprintResult>.(BytecodeContext) -> Unit
|
||||
) = this?.map { it.result ?: throw it.exception }?.patch(context)
|
||||
patch: List<MethodFingerprintResult>.(BytecodeContext) -> PatchResult
|
||||
) {
|
||||
when (val result = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context)) {
|
||||
is PatchResultError -> throw result
|
||||
}
|
||||
}
|
||||
|
||||
clientIdFingerprints.executePatch { patchClientId(context) }
|
||||
userAgentFingerprints.executePatch { patchUserAgent(context) }
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +62,7 @@ abstract class AbstractSpoofClientPatch(
|
||||
* @param context The current [BytecodeContext].
|
||||
*
|
||||
*/
|
||||
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext)
|
||||
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult
|
||||
|
||||
/**
|
||||
* Patch the user agent. The fingerprints are guaranteed to be in the same order as in [userAgentFingerprints].
|
||||
@@ -67,7 +70,8 @@ abstract class AbstractSpoofClientPatch(
|
||||
* @param context The current [BytecodeContext].
|
||||
*/
|
||||
// Not every client needs to patch the user agent.
|
||||
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {}
|
||||
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult =
|
||||
PatchResultSuccess()
|
||||
|
||||
companion object Options {
|
||||
open class SpoofClientOptionsContainer : OptionsContainer() {
|
||||
|
||||
+6
-2
@@ -7,11 +7,13 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
|
||||
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
|
||||
@SpoofClientAnnotation
|
||||
@@ -28,7 +30,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
"http://baconreader.com/auth", Options, listOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint)
|
||||
) {
|
||||
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
fun MethodFingerprintResult.patch(replacementString: String) {
|
||||
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index
|
||||
|
||||
@@ -46,6 +48,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
|
||||
// Patch client id for access token request.
|
||||
last().patch(clientId!!)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+5
-1
@@ -6,6 +6,8 @@ import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
||||
@@ -18,7 +20,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
|
||||
class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
"http://rubenmayayo.com", Options, listOf(GetClientIdFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
first().mutableMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
@@ -26,6 +28,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+6
-2
@@ -7,11 +7,13 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint
|
||||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@SpoofClientAnnotation
|
||||
@Description("Spoofs the client in order to allow logging in. " +
|
||||
@@ -23,7 +25,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
Options,
|
||||
listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
forEach {
|
||||
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||
it.mutableMethod.apply {
|
||||
@@ -35,6 +37,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.ads.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object IsAdFreeUserFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
|
||||
+7
-3
@@ -1,12 +1,14 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.ads.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.customclients.joeyforreddit.ads.fingerprints.IsAdFreeUserFingerprint
|
||||
@@ -17,13 +19,15 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.
|
||||
@DependsOn([DisablePiracyDetectionPatch::class])
|
||||
@Compatibility([Package("o.o.joey")])
|
||||
class DisableAdsPatch : BytecodePatch(listOf(IsAdFreeUserFingerprint)) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
IsAdFreeUserFingerprint.result?.mutableMethod?.addInstructions(
|
||||
0,
|
||||
"""
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
"""
|
||||
) ?: throw IsAdFreeUserFingerprint.exception
|
||||
) ?: return IsAdFreeUserFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object GetClientIdFingerprint : MethodFingerprint(
|
||||
|
||||
+5
-1
@@ -6,6 +6,8 @@ import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
@@ -29,7 +31,7 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.
|
||||
class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
"https://127.0.0.1:65023/authorize_callback", Options, listOf(GetClientIdFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
first().mutableMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
@@ -37,6 +39,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object PiracyDetectionFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
|
||||
+7
-3
@@ -1,18 +1,22 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
|
||||
|
||||
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
PiracyDetectionFingerprint.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
"""
|
||||
return-void
|
||||
"""
|
||||
) ?: throw PiracyDetectionFingerprint.exception
|
||||
) ?: return PiracyDetectionFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object GetUserAgentFingerprint : MethodFingerprint(
|
||||
"Ljava/lang/String;",
|
||||
|
||||
+14
-9
@@ -9,12 +9,14 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BasicAuthorizationFingerprint
|
||||
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint
|
||||
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.GetUserAgentFingerprint
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@SpoofClientAnnotation
|
||||
@Description("Spoofs the client in order to allow logging in. " +
|
||||
@@ -27,7 +29,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
listOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint),
|
||||
listOf(GetUserAgentFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
/**
|
||||
* Replaces a one register instruction with a const-string instruction
|
||||
* at the index returned by [getReplacementIndex].
|
||||
@@ -51,20 +53,23 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
|
||||
// Path basic authorization.
|
||||
last().replaceWith("$clientId:") { last().index + 7 }
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||
// Use a random user agent.
|
||||
val randomName = (0..100000).random()
|
||||
val userAgent = "android:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
|
||||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult {
|
||||
// Use a random number as the user agent string.
|
||||
val randomUserAgent = (0..100000).random()
|
||||
|
||||
first().mutableMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
const-string v0, "$userAgent"
|
||||
return-object v0
|
||||
"""
|
||||
const-string v0, "$randomUserAgent"
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+6
-2
@@ -7,13 +7,15 @@ import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedInBearerTokenFingerprint
|
||||
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedOutBearerTokenFingerprint
|
||||
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetRefreshTokenFingerprint
|
||||
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.LoginActivityClientIdFingerprint
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@SpoofClientAnnotation
|
||||
@Description("Spoofs the client in order to allow logging in. " +
|
||||
@@ -30,7 +32,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
GetRefreshTokenFingerprint
|
||||
)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
forEach {
|
||||
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||
it.mutableMethod.apply {
|
||||
@@ -42,6 +44,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+5
-1
@@ -6,6 +6,8 @@ import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
||||
@@ -18,7 +20,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
|
||||
class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
"http://www.ccrama.me", Options, listOf(GetClientIdFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
first().mutableMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
@@ -26,6 +28,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object IsAdsEnabledFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
|
||||
+7
-3
@@ -1,10 +1,12 @@
|
||||
package app.revanced.patches.reddit.customclients.syncforreddit.ads.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.*
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints.IsAdsEnabledFingerprint
|
||||
@@ -15,7 +17,7 @@ import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.
|
||||
@DependsOn([DisablePiracyDetectionPatch::class])
|
||||
@Compatibility([Package("com.laurencedawson.reddit_sync")])
|
||||
class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
IsAdsEnabledFingerprint.result?.mutableMethod?.apply {
|
||||
addInstructions(
|
||||
0,
|
||||
@@ -24,7 +26,9 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: throw IsAdsEnabledFingerprint.exception
|
||||
} ?: return IsAdsEnabledFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
+5
-1
@@ -7,6 +7,8 @@ import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startup.fingerprints.MainActivityOnCreate
|
||||
|
||||
@@ -21,11 +23,13 @@ import app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startu
|
||||
]
|
||||
)
|
||||
class DisableSyncForLemmyBottomSheetPatch : BytecodePatch(listOf(MainActivityOnCreate)) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
MainActivityOnCreate.result?.mutableMethod?.apply {
|
||||
val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1
|
||||
|
||||
removeInstruction(showBottomSheetIndex)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
+10
-6
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.reddit.customclients.syncforreddit.api.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Package
|
||||
@@ -10,15 +10,17 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetAuthorizationStringFingerprint
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetBearerTokenFingerprint
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.patch.DisablePiracyDetectionPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import java.util.*
|
||||
|
||||
@SpoofClientAnnotation
|
||||
@@ -36,7 +38,7 @@ import java.util.*
|
||||
class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
"http://redditsync/auth", Options, listOf(GetAuthorizationStringFingerprint)
|
||||
) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
|
||||
forEach { fingerprintResult ->
|
||||
fingerprintResult.also { result ->
|
||||
GetBearerTokenFingerprint.also { it.resolve(context, result.classDef) }.result?.mutableMethod?.apply {
|
||||
@@ -48,7 +50,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
} ?: throw GetBearerTokenFingerprint.exception
|
||||
} ?: return GetBearerTokenFingerprint.toErrorResult()
|
||||
}.let {
|
||||
val occurrenceIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||
|
||||
@@ -69,6 +71,8 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@ package app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
object PiracyDetectionFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
|
||||
+5
-1
@@ -4,11 +4,13 @@ import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
|
||||
|
||||
@Description("Disables detection of modified versions.")
|
||||
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// Do not return an error if the fingerprint is not resolved.
|
||||
// This is fine because new versions of the target app do not need this patch.
|
||||
PiracyDetectionFingerprint.result?.mutableMethod?.apply {
|
||||
@@ -19,5 +21,7 @@ class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerpr
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -1,11 +1,13 @@
|
||||
package app.revanced.patches.reddit.layout.disablescreenshotpopup.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.layout.disablescreenshotpopup.annotations.DisableScreenshotPopupCompatibility
|
||||
import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.DisableScreenshotPopupFingerprint
|
||||
@@ -17,8 +19,10 @@ import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.Di
|
||||
class DisableScreenshotPopupPatch : BytecodePatch(
|
||||
listOf(DisableScreenshotPopupFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
|
||||
?: throw DisableScreenshotPopupFingerprint.exception
|
||||
?: return DisableScreenshotPopupFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -5,6 +5,8 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility
|
||||
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint
|
||||
@@ -18,7 +20,7 @@ class PremiumIconPatch : BytecodePatch(
|
||||
PremiumIconFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val method = PremiumIconFingerprint.result!!.mutableMethod
|
||||
method.addInstructions(
|
||||
0,
|
||||
@@ -27,5 +29,6 @@ class PremiumIconPatch : BytecodePatch(
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -1,11 +1,13 @@
|
||||
package app.revanced.patches.reddit.misc.tracking.url.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.reddit.misc.tracking.url.annotations.SanitizeUrlQueryCompatibility
|
||||
import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkFormatterFingerprint
|
||||
@@ -17,12 +19,14 @@ import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkForma
|
||||
class SanitizeUrlQueryPatch : BytecodePatch(
|
||||
listOf(ShareLinkFormatterFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
ShareLinkFormatterFingerprint.result?.mutableMethod?.addInstructions(
|
||||
0,
|
||||
"return-object p0"
|
||||
) ?: throw ShareLinkFormatterFingerprint.exception
|
||||
) ?: return ShareLinkFormatterFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user