diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 356a6d2d7e..d6540eac87 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -576,6 +576,7 @@ public final class app/revanced/patches/reddit/customclients/joeyforreddit/detec public final class app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V + public fun patchMiscellaneous (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V public fun patchUserAgent (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt index ab110821ec..5663a0223e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/SpoofClientPatch.kt @@ -10,8 +10,10 @@ import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch 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 app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction - +import com.android.tools.smali.dexlib2.iface.reference.StringReference @Suppress("unused") object SpoofClientPatch : BaseSpoofClientPatch( @@ -20,8 +22,8 @@ object SpoofClientPatch : BaseSpoofClientPatch( userAgentFingerprints = setOf(GetUserAgentFingerprint), compatiblePackages = setOf( CompatiblePackage("com.andrewshu.android.reddit"), - CompatiblePackage("com.andrewshu.android.redditdonation") - ) + CompatiblePackage("com.andrewshu.android.redditdonation"), + ), ) { override fun Set.patchClientId(context: BytecodeContext) { /** @@ -59,7 +61,23 @@ object SpoofClientPatch : BaseSpoofClientPatch( """ const-string v0, "$userAgent" return-object v0 - """ + """, ) } -} \ No newline at end of file + + override fun Set.patchMiscellaneous(context: BytecodeContext) { + // Reddit messed up and does not append a redirect uri to the authorization url to old.reddit.com/login. + // Replace old.reddit.com with ssl.reddit.com to fix this. + BuildAuthorizationStringFingerprint.result!!.mutableMethod.apply { + val index = indexOfFirstInstruction { + getReference()?.contains("old.reddit.com") == true + } + + val targetRegister = getInstruction(index).registerA + replaceInstruction( + index, + "const-string v$targetRegister, \"https://ssl.reddit.com/api/v1/authorize.compact\"", + ) + } + } +}