mirror of
https://github.com/revanced/revanced-patches
synced 2024-08-27 17:51:15 +02:00
feat(Joey for Reddit): Add Change OAuth client id
patch
This commit is contained in:
parent
2ef62e5363
commit
1bac47df88
@ -0,0 +1,20 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object GetClientIdFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
opcodes = listOf(
|
||||
Opcode.CONST, // R.string.valuable_cid
|
||||
Opcode.INVOKE_STATIC, // StringMaster.decrypt
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.RETURN_OBJECT
|
||||
),
|
||||
customFingerprint = custom@{ _, classDef ->
|
||||
classDef.sourceFile == "AuthUtility.java"
|
||||
}
|
||||
)
|
@ -0,0 +1,47 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.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.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
|
||||
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
|
||||
import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint
|
||||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch.DisablePiracyDetectionPatch
|
||||
|
||||
@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 \"https://127.0.0.1:65023/authorize_callback\"."
|
||||
)
|
||||
@Compatibility(
|
||||
[
|
||||
Package("o.o.joey"),
|
||||
Package("o.o.joey.pro"),
|
||||
Package("o.o.joey.dev")
|
||||
]
|
||||
)
|
||||
@DependsOn([DisablePiracyDetectionPatch::class])
|
||||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
|
||||
"https://127.0.0.1:65023/authorize_callback", 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,0 +1,22 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object PiracyDetectionFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||
opcodes = listOf(
|
||||
Opcode.NEW_INSTANCE, // new PiracyDetectionRunnable()
|
||||
Opcode.CONST_16,
|
||||
Opcode.CONST_WIDE_16,
|
||||
Opcode.INVOKE_DIRECT, // <init>(..)
|
||||
Opcode.INVOKE_VIRTUAL, // run()
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = custom@{ _, classDef ->
|
||||
classDef.type.endsWith("ProcessLifeCyleListener;")
|
||||
}
|
||||
)
|
@ -0,0 +1,22 @@
|
||||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
|
||||
|
||||
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
PiracyDetectionFingerprint.result?.mutableMethod?.addInstruction(
|
||||
0,
|
||||
"""
|
||||
return-void
|
||||
"""
|
||||
) ?: return PiracyDetectionFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.
|
||||
@Patch
|
||||
@Name("Disable ads")
|
||||
@DependsOn([DisablePiracyDetectionPatch::class])
|
||||
@Description("Disables ads.")
|
||||
@Compatibility([Package("com.laurencedawson.reddit_sync")])
|
||||
class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
Loading…
Reference in New Issue
Block a user