mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-01 12:05:35 +02:00
fix(boostforreddit): use correct options
This commit is contained in:
parent
edd67b8748
commit
ec39732a05
@ -4,16 +4,15 @@ import android.os.Environment
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patches.reddit.customclients.boostforreddit.api.patch.ChangeOAuthClientIdPatch
|
||||
import app.revanced.patches.reddit.customclients.syncforreddit.api.patch.ChangeOAuthClientIdPatch.Companion.clientId
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractChangeOAuthClientIdPatch(
|
||||
private val redirectUri: String,
|
||||
private val options: ChangeOAuthClientIdOptionsContainer,
|
||||
private val fingerprint: MethodFingerprint,
|
||||
) : BytecodePatch(listOf(fingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
if (ChangeOAuthClientIdPatch.clientId == null) {
|
||||
if (options.clientId == null) {
|
||||
// Test if on Android
|
||||
try {
|
||||
Class.forName("android.os.Environment")
|
||||
@ -30,11 +29,11 @@ abstract class AbstractChangeOAuthClientIdPatch(
|
||||
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"
|
||||
The application type has to be "Installed app" and the redirect URI has to be set to "$redirectUri".
|
||||
""".trimIndent()
|
||||
|
||||
return PatchResultError(error)
|
||||
}.let { clientId = it.readText().trim() }
|
||||
}.let { options.clientId = it.readText().trim() }
|
||||
}
|
||||
|
||||
return fingerprint.patch(context)
|
||||
|
@ -18,6 +18,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
|
||||
@Version("0.0.1")
|
||||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
"http://rubenmayayo.com",
|
||||
Options,
|
||||
GetClientIdFingerprint
|
||||
) {
|
||||
override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult {
|
||||
@ -32,5 +33,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : Options.ChangeOAuthClientIdOptionsContainer()
|
||||
companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Patch
|
||||
@Name("change-oauth-client-id")
|
||||
@Description("Changes the OAuth client ID.")
|
||||
@ -27,6 +26,7 @@ import java.util.*
|
||||
@Version("0.0.1")
|
||||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
"http://redditsync/auth",
|
||||
Options,
|
||||
GetAuthorizationStringFingerprint,
|
||||
) {
|
||||
override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult {
|
||||
@ -51,7 +51,7 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
|
||||
val newAuthorizationUrl = reference.string.replace(
|
||||
"client_id=.*?&".toRegex(),
|
||||
"client_id=${clientId!!}&"
|
||||
"client_id=$clientId&"
|
||||
)
|
||||
|
||||
replaceInstruction(
|
||||
@ -64,5 +64,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : Options.ChangeOAuthClientIdOptionsContainer()
|
||||
companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user