From 68253c0df5cda73345be60baf9ee5f0db940caf8 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 31 May 2024 02:10:47 +0200 Subject: [PATCH] refactor: Use parameter instead of local register --- .../customclients/boostforreddit/api/SpoofClientPatch.kt | 9 +++++---- .../{JRAWUserAgent.kt => BuildUserAgentFingerprint.kt} | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) rename src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/{JRAWUserAgent.kt => BuildUserAgentFingerprint.kt} (53%) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt index b5d4f7f75..5c34ff3ce 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/SpoofClientPatch.kt @@ -4,14 +4,14 @@ import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.fingerprint.MethodFingerprintResult 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.JRAWUserAgent @Suppress("unused") object SpoofClientPatch : BaseSpoofClientPatch( redirectUri = "http://rubenmayayo.com", clientIdFingerprints = setOf(GetClientIdFingerprint), - userAgentFingerprints = setOf(JRAWUserAgent), + userAgentFingerprints = setOf(BuildUserAgentFingerprint), compatiblePackages = setOf(CompatiblePackage("com.rubenmayayo.reddit")), ) { override fun Set.patchClientId(context: BytecodeContext) { @@ -27,10 +27,11 @@ object SpoofClientPatch : BaseSpoofClientPatch( override fun Set.patchUserAgent(context: BytecodeContext) { // Use a random number as the platform in the user agent string. val platformName = (0..100000).random() + val platformParameter = 0 first().mutableMethod.addInstructions( - 1, - "const-string v3, \"$platformName\"", + 0, + "const-string p$platformParameter, \"$platformName\"", ) } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/BuildUserAgentFingerprint.kt similarity index 53% rename from src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt rename to src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/BuildUserAgentFingerprint.kt index feff63586..220b5a263 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/JRAWUserAgent.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/BuildUserAgentFingerprint.kt @@ -2,6 +2,6 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprint import app.revanced.patcher.fingerprint.MethodFingerprint -internal object JRAWUserAgent : MethodFingerprint( - strings = listOf("platform", "appId", "version", "redditUsername"), -) \ No newline at end of file +internal object BuildUserAgentFingerprint : MethodFingerprint( + strings = listOf("%s:%s:%s (by /u/%s)"), +)