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 137cb137a..7d8ac71f7 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 @@ -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.Patch 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.LoginActivityOnCreateFingerprint @Patch( name = "Spoof client", @@ -15,7 +17,9 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints ) @Suppress("unused") object SpoofClientPatch : AbstractSpoofClientPatch( - "http://rubenmayayo.com", listOf(GetClientIdFingerprint) + "http://rubenmayayo.com", + clientIdFingerprints = listOf(GetClientIdFingerprint), + userAgentFingerprints = listOf(LoginActivityOnCreateFingerprint) ) { override fun List.patchClientId(context: BytecodeContext) { first().mutableMethod.addInstructions( @@ -26,4 +30,20 @@ object SpoofClientPatch : AbstractSpoofClientPatch( """ ) } + + override fun List.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 + """ + ) + } + } + } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt new file mode 100644 index 000000000..b7bbe1e66 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/boostforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt @@ -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;") + } +) \ No newline at end of file