Skip to content

Commit

Permalink
feat(slideforreddit): add change-oauth-client-id patch (#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlemazza committed Jul 5, 2023
1 parent ca1065f commit 8cd60ee
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
)
Original file line number Diff line number Diff line change
@@ -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<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
first().mutableMethod.addInstructions(
0,
"""
const-string v0, "$clientId"
return-object v0
"""
)

return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
}

0 comments on commit 8cd60ee

Please sign in to comment.