From b6c1ec7d18785666d3b6c8cb51d7be16cdf29add Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 12 Jan 2026 16:03:25 +0700 Subject: [PATCH] refactor(joeyforreddit): SpoofClientPatch --- .../joeyforreddit/api/Fingerprints.kt | 43 ++++++++++--------- .../joeyforreddit/api/SpoofClientPatch.kt | 6 ++- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt index e6c591748..0c2240404 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/Fingerprints.kt @@ -1,28 +1,31 @@ -package app.revanced.patches.reddit.customclients.joeyforreddit.api +package app.revanced.patches.reddit.customclients.infinity.api -import com.android.tools.smali.dexlib2.Opcode +import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively +import app.revanced.patcher.accessFlags +import app.revanced.patcher.classDef +import app.revanced.patcher.custom +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke +import app.revanced.patcher.patch.BytecodePatchContext +import app.revanced.patcher.returnType import com.android.tools.smali.dexlib2.AccessFlags -import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.Opcode -internal val authUtilityUserAgentFingerprint = fingerprint { +internal val BytecodePatchContext.authUtilityUserAgentMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("Ljava/lang/String;") - opcodes(Opcode.APUT_OBJECT) - custom { method, classDef -> - classDef.sourceFile == "AuthUtility.java" - } + returnType("Ljava/lang/String;") + instructions(Opcode.APUT_OBJECT()) + custom { classDef.sourceFile == "AuthUtility.java" } } -internal val getClientIdFingerprint = fingerprint { +internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) - returns("L") - opcodes( - Opcode.CONST, // R.string.valuable_cid - Opcode.INVOKE_STATIC, // StringMaster.decrypt - Opcode.MOVE_RESULT_OBJECT, - Opcode.RETURN_OBJECT + returnType("L") + instructions( + Opcode.CONST(), + Opcode.INVOKE_STATIC(), + Opcode.MOVE_RESULT_OBJECT(), + Opcode.RETURN_OBJECT(), ) - custom { _, classDef -> - classDef.sourceFile == "AuthUtility.java" - } -} \ No newline at end of file + custom { classDef.sourceFile == "AuthUtility.java" } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt index 1de143ee7..323499f69 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/SpoofClientPatch.kt @@ -1,5 +1,7 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.api +import app.revanced.patches.reddit.customclients.infinity.api.authUtilityUserAgentMethod +import app.revanced.patches.reddit.customclients.infinity.api.getClientIdMethod import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.disablePiracyDetectionPatch import app.revanced.patches.reddit.customclients.spoofClientPatch import app.revanced.util.returnEarly @@ -18,7 +20,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a apply { // region Patch client id. - getClientIdFingerprint.method.returnEarly(clientId!!) + getClientIdMethod.returnEarly(clientId!!) // endregion @@ -28,7 +30,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "https://127.0.0.1:65023/a val randomName = (0..100000).random() val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)" - authUtilityUserAgentFingerprint.method.returnEarly(userAgent) + authUtilityUserAgentMethod.returnEarly(userAgent) // endregion }