fix(Infinity for Reddit - Spoof client): Set user-agent for OAuth requests to fix login
This commit is contained in:
parent
2223951fa1
commit
a710f05bb4
|
@ -1,14 +1,17 @@
|
||||||
package app.revanced.patches.reddit.customclients.infinityforreddit.api
|
package app.revanced.patches.reddit.customclients.infinityforreddit.api
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
|
||||||
|
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT
|
||||||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint
|
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint
|
||||||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint
|
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint
|
||||||
|
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.SetWebViewSettingsFingerprint
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
|
@ -32,7 +35,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"infinity://localhost",
|
"infinity://localhost",
|
||||||
listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint)
|
clientIdFingerprints = listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint),
|
||||||
|
userAgentFingerprints = listOf(SetWebViewSettingsFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
forEach {
|
forEach {
|
||||||
|
@ -48,4 +52,18 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||||
|
first().let { result ->
|
||||||
|
val insertIndex = result.scanResult.stringsScanResult!!.matches.first().index
|
||||||
|
|
||||||
|
result.mutableMethod.addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
const-string v0, "$OAUTH_USER_AGENT"
|
||||||
|
invoke-virtual {p1, v0}, Landroid/webkit/WebSettings;->setUserAgentString(Ljava/lang/String;)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object SetWebViewSettingsFingerprint : MethodFingerprint(
|
||||||
|
strings= listOf("https://www.reddit.com/api/v1/authorize.compact")
|
||||||
|
)
|
Loading…
Reference in a new issue