mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-30 06:34:28 +02:00
fix(Boost for reddit - Client spoof): Use a different user agent to combat Reddit's API issues
This commit is contained in:
parent
1ed6933224
commit
5d3c8175b3
@ -1,7 +1,10 @@
|
|||||||
package app.revanced.patches.reddit.customclients.boostforreddit.api
|
package app.revanced.patches.reddit.customclients.boostforreddit.api
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patches.reddit.customclients.spoofClientPatch
|
import app.revanced.patches.reddit.customclients.spoofClientPatch
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption ->
|
val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption ->
|
||||||
compatibleWith("com.rubenmayayo.reddit")
|
compatibleWith("com.rubenmayayo.reddit")
|
||||||
@ -23,14 +26,15 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com")
|
|||||||
|
|
||||||
// region Patch user agent.
|
// region Patch user agent.
|
||||||
|
|
||||||
// Use a random number as the platform in the user agent string.
|
// Use a random user agent.
|
||||||
val platformName = (0..100000).random()
|
val randomName = (0..100000).random()
|
||||||
val platformParameter = 0
|
val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
|
||||||
|
buildUserAgentFingerprint.let {
|
||||||
|
val userAgentTemplateIndex = it.stringMatches!!.first().index
|
||||||
|
val register = it.method.getInstruction<OneRegisterInstruction>(userAgentTemplateIndex).registerA
|
||||||
|
|
||||||
buildUserAgentFingerprint.method.addInstructions(
|
it.method.replaceInstruction(userAgentTemplateIndex, "const-string v$register, \"$userAgent\"")
|
||||||
0,
|
}
|
||||||
"const-string p$platformParameter, \"$platformName\"",
|
|
||||||
)
|
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user