diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt new file mode 100644 index 000000000..fe166b91d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/AbstractClientIdFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +abstract class AbstractClientIdFingerprint(string: String) : MethodFingerprint( + strings = listOfNotNull("yyOCBp.RHJhDKd", string), +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt new file mode 100644 index 000000000..9e4b3530a --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/redditisfun/api/fingerprints/BasicAuthorizationFingerprint.kt @@ -0,0 +1,5 @@ +package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints + +object BasicAuthorizationFingerprint : AbstractClientIdFingerprint( + string = "fJOxVwBUyo*=f:.patch(context: BytecodeContext): PatchResult { + /** + * Replaces a one register instruction with a const-string instruction + * at the index returned by [getReplacementIndex]. + * + * @param string The string to replace the instruction with. + * @param getReplacementIndex A function that returns the index of the instruction to replace + * using the [StringMatch] list from the [MethodFingerprintResult]. + */ + fun MethodFingerprintResult.replaceWith( + string: String, + getReplacementIndex: List.() -> Int, + ) = mutableMethod.apply { + val replacementIndex = scanResult.stringsScanResult!!.matches.getReplacementIndex() + val clientIdRegister = getInstruction(replacementIndex).registerA + + replaceInstruction(replacementIndex, "const-string v$clientIdRegister, \"$string\"") + } + + // Patch OAuth authorization. + first().replaceWith(clientId!!) { first().index + 4 } + + // Path basic authorization. + last().replaceWith("$clientId:") { last().index + 7 } + + return PatchResultSuccess() + } + + companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer() +} \ No newline at end of file