mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-24 04:35:49 +01:00
feat(baconreader): add change-oauth-client-id
patch (#2535)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
cade228a6c
commit
6f5e007a78
@ -0,0 +1,7 @@
|
||||
package app.revanced.patches.reddit.customclients.baconreader.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object GetAuthorizationUrlFingerprint: MethodFingerprint(
|
||||
strings = listOf("client_id=zACVn0dSFGdWqQ"),
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.reddit.customclients.baconreader.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object GetClientIdFingerprint : MethodFingerprint(
|
||||
strings = listOf("client_id=zACVn0dSFGdWqQ"),
|
||||
customFingerprint = custom@{ methodDef, classDef ->
|
||||
if (!classDef.type.endsWith("RedditOAuth;")) return@custom false
|
||||
|
||||
methodDef.name == "getAuthorizeUrl"
|
||||
}
|
||||
)
|
@ -0,0 +1,7 @@
|
||||
package app.revanced.patches.reddit.customclients.baconreader.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object RequestTokenFingerprint : MethodFingerprint(
|
||||
strings = listOf("zACVn0dSFGdWqQ", "kDm2tYpu9DqyWFFyPlNcXGEni4k"), // App ID and secret.
|
||||
)
|
@ -0,0 +1,47 @@
|
||||
package app.revanced.patches.reddit.customclients.baconreader.api.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
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.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
|
||||
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
|
||||
@ChangeOAuthClientIdPatchAnnotation
|
||||
@Compatibility([Package("com.onelouder.baconreader")])
|
||||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
"http://baconreader.com/auth", Options, listOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint)
|
||||
) {
|
||||
|
||||
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
|
||||
fun MethodFingerprintResult.patch(replacementString: String) {
|
||||
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index
|
||||
|
||||
mutableMethod.apply {
|
||||
val clientIdRegister = getInstruction<OneRegisterInstruction>(clientIdIndex).registerA
|
||||
replaceInstruction(
|
||||
clientIdIndex,
|
||||
"const-string v$clientIdRegister, \"$replacementString\""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Patch client id in authorization url.
|
||||
first().patch("client_id=$clientId")
|
||||
|
||||
// Patch client id for access token request.
|
||||
last().patch(clientId!!)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
|
||||
}
|
Loading…
Reference in New Issue
Block a user