diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/fingerprints/GetClientIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/fingerprints/GetClientIdFingerprint.kt new file mode 100644 index 00000000..9caed985 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/fingerprints/GetClientIdFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.reddit.customclients.slide.api.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object GetClientIdFingerprint : MethodFingerprint( + customFingerprint = custom@{ methodDef, classDef -> + if (!classDef.type.endsWith("Credentials;")) return@custom false + + methodDef.name == "getClientId" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/patch/ChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/patch/ChangeOAuthClientIdPatch.kt new file mode 100644 index 00000000..90a9372f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/slide/api/patch/ChangeOAuthClientIdPatch.kt @@ -0,0 +1,36 @@ +package app.revanced.patches.reddit.customclients.slide.api.patch + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Package +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch +import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation +import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint + +@ChangeOAuthClientIdPatchAnnotation +@Description("Changes the OAuth client ID. " + + "The OAuth application type has to be \"Installed app\" " + + "and the redirect URI has to be set to \"http://www.ccrama.me\".") +@Compatibility([Package("me.ccrama.redditslide")]) +class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch( + "http://www.ccrama.me", Options, listOf(GetClientIdFingerprint) +) { + override fun List.patch(context: BytecodeContext): PatchResult { + first().mutableMethod.addInstructions( + 0, + """ + const-string v0, "$clientId" + return-object v0 + """ + ) + + return PatchResultSuccess() + } + + companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer() +}