diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractChangeOAuthClientIdPatch.kt index f0cffbea7..27bc8842a 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractChangeOAuthClientIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractChangeOAuthClientIdPatch.kt @@ -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) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/patch/ChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/patch/ChangeOAuthClientIdPatch.kt index c3b7c966f..1f8004d1d 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/patch/ChangeOAuthClientIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/patch/ChangeOAuthClientIdPatch.kt @@ -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() } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt index c8e3bd409..e7ceb004d 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/ChangeOAuthClientIdPatch.kt @@ -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() }