refactor: Use parameter instead of local register

This commit is contained in:
oSumAtrIX 2024-05-31 02:10:47 +02:00
parent 45b6a08980
commit 68253c0df5
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 8 additions and 7 deletions

View file

@ -4,14 +4,14 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.fingerprint.MethodFingerprintResult
import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch import app.revanced.patches.reddit.customclients.BaseSpoofClientPatch
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.BuildUserAgentFingerprint
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.JRAWUserAgent
@Suppress("unused") @Suppress("unused")
object SpoofClientPatch : BaseSpoofClientPatch( object SpoofClientPatch : BaseSpoofClientPatch(
redirectUri = "http://rubenmayayo.com", redirectUri = "http://rubenmayayo.com",
clientIdFingerprints = setOf(GetClientIdFingerprint), clientIdFingerprints = setOf(GetClientIdFingerprint),
userAgentFingerprints = setOf(JRAWUserAgent), userAgentFingerprints = setOf(BuildUserAgentFingerprint),
compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit")), compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit")),
) { ) {
override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) { override fun Set<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
@ -27,10 +27,11 @@ object SpoofClientPatch : BaseSpoofClientPatch(
override fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) { override fun Set<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
// Use a random number as the platform in the user agent string. // Use a random number as the platform in the user agent string.
val platformName = (0..100000).random() val platformName = (0..100000).random()
val platformParameter = 0
first().mutableMethod.addInstructions( first().mutableMethod.addInstructions(
1, 0,
"const-string v3, \"$platformName\"", "const-string p$platformParameter, \"$platformName\"",
) )
} }
} }

View file

@ -2,6 +2,6 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprint
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint
internal object JRAWUserAgent : MethodFingerprint( internal object BuildUserAgentFingerprint : MethodFingerprint(
strings = listOf("platform", "appId", "version", "redditUsername"), strings = listOf("%s:%s:%s (by /u/%s)"),
) )