fix(boostforreddit): use correct options

This commit is contained in:
oSumAtrIX 2023-06-20 04:04:04 +02:00
parent edd67b8748
commit ec39732a05
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 9 additions and 9 deletions

View File

@ -4,16 +4,15 @@ import android.os.Environment
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.* 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 import java.io.File
abstract class AbstractChangeOAuthClientIdPatch( abstract class AbstractChangeOAuthClientIdPatch(
private val redirectUri: String, private val redirectUri: String,
private val options: ChangeOAuthClientIdOptionsContainer,
private val fingerprint: MethodFingerprint, private val fingerprint: MethodFingerprint,
) : BytecodePatch(listOf(fingerprint)) { ) : BytecodePatch(listOf(fingerprint)) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
if (ChangeOAuthClientIdPatch.clientId == null) { if (options.clientId == null) {
// Test if on Android // Test if on Android
try { try {
Class.forName("android.os.Environment") Class.forName("android.os.Environment")
@ -30,11 +29,11 @@ abstract class AbstractChangeOAuthClientIdPatch(
Alternatively, you can provide the client ID using patch options. Alternatively, you can provide the client ID using patch options.
You can get your client ID from https://www.reddit.com/prefs/apps. 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() """.trimIndent()
return PatchResultError(error) return PatchResultError(error)
}.let { clientId = it.readText().trim() } }.let { options.clientId = it.readText().trim() }
} }
return fingerprint.patch(context) return fingerprint.patch(context)

View File

@ -18,6 +18,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
@Version("0.0.1") @Version("0.0.1")
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch( class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
"http://rubenmayayo.com", "http://rubenmayayo.com",
Options,
GetClientIdFingerprint GetClientIdFingerprint
) { ) {
override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult { override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult {
@ -32,5 +33,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess() return PatchResultSuccess()
} }
companion object : Options.ChangeOAuthClientIdOptionsContainer() companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
} }

View File

@ -19,7 +19,6 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.StringReference import org.jf.dexlib2.iface.reference.StringReference
import java.util.* import java.util.*
@Patch @Patch
@Name("change-oauth-client-id") @Name("change-oauth-client-id")
@Description("Changes the OAuth client ID.") @Description("Changes the OAuth client ID.")
@ -27,6 +26,7 @@ import java.util.*
@Version("0.0.1") @Version("0.0.1")
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch( class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
"http://redditsync/auth", "http://redditsync/auth",
Options,
GetAuthorizationStringFingerprint, GetAuthorizationStringFingerprint,
) { ) {
override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult { override fun MethodFingerprint.patch(context: BytecodeContext): PatchResult {
@ -51,7 +51,7 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
val newAuthorizationUrl = reference.string.replace( val newAuthorizationUrl = reference.string.replace(
"client_id=.*?&".toRegex(), "client_id=.*?&".toRegex(),
"client_id=${clientId!!}&" "client_id=$clientId&"
) )
replaceInstruction( replaceInstruction(
@ -64,5 +64,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess() return PatchResultSuccess()
} }
companion object : Options.ChangeOAuthClientIdOptionsContainer() companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
} }