diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/GetClientIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/GetClientIdFingerprint.kt new file mode 100644 index 000000000..861bb0dd7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/fingerprints/GetClientIdFingerprint.kt @@ -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" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/patch/ChangeOAuthClientIdPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/patch/ChangeOAuthClientIdPatch.kt new file mode 100644 index 000000000..fb25a390d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/api/patch/ChangeOAuthClientIdPatch.kt @@ -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.patch(context: BytecodeContext): PatchResult { + first().mutableMethod.addInstructions( + 0, + """ + const-string v0, "$clientId" + return-object v0 + """ + ) + + return PatchResultSuccess() + } + + companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer() +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/fingerprints/PiracyDetectionFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/fingerprints/PiracyDetectionFingerprint.kt new file mode 100644 index 000000000..dfd1d4afc --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/fingerprints/PiracyDetectionFingerprint.kt @@ -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, // (..) + Opcode.INVOKE_VIRTUAL, // run() + Opcode.RETURN_VOID + ), + customFingerprint = custom@{ _, classDef -> + classDef.type.endsWith("ProcessLifeCyleListener;") + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt new file mode 100644 index 000000000..b2935fa85 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt @@ -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() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt index 7953aef1f..367ca8f90 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt @@ -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 {