fix(Boost for Reddit - Spoof client): Set user-agent for OAuth requests to fix login
This commit is contained in:
parent
a48c4a7cc1
commit
2223951fa1
|
@ -6,7 +6,9 @@ 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.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
|
||||||
|
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.LoginActivityOnCreateFingerprint
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Spoof client",
|
name = "Spoof client",
|
||||||
|
@ -15,7 +17,9 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
|
||||||
)
|
)
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object SpoofClientPatch : AbstractSpoofClientPatch(
|
object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"http://rubenmayayo.com", listOf(GetClientIdFingerprint)
|
"http://rubenmayayo.com",
|
||||||
|
clientIdFingerprints = listOf(GetClientIdFingerprint),
|
||||||
|
userAgentFingerprints = listOf(LoginActivityOnCreateFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
|
||||||
first().mutableMethod.addInstructions(
|
first().mutableMethod.addInstructions(
|
||||||
|
@ -26,4 +30,20 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
|
||||||
|
first().let { result ->
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
const-string v7, "$OAUTH_USER_AGENT"
|
||||||
|
invoke-virtual {v4, v7}, Landroid/webkit/WebSettings;->setUserAgentString(Ljava/lang/String;)V
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
object LoginActivityOnCreateFingerprint : MethodFingerprint(
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.CONST_4
|
||||||
|
),
|
||||||
|
customFingerprint = { method, classDef ->
|
||||||
|
method.name == "onCreate" && classDef.type.endsWith("LoginActivity;")
|
||||||
|
}
|
||||||
|
)
|
Loading…
Reference in a new issue