diff --git a/patches/src/integrationTest/kotlin/app/twitter/patches/MorphePatchIntegrationTest.kt b/patches/src/integrationTest/kotlin/app/twitter/patches/MorphePatchIntegrationTest.kt index 5e4e6ad..db02ddb 100644 --- a/patches/src/integrationTest/kotlin/app/twitter/patches/MorphePatchIntegrationTest.kt +++ b/patches/src/integrationTest/kotlin/app/twitter/patches/MorphePatchIntegrationTest.kt @@ -49,6 +49,7 @@ class MorphePatchIntegrationTest { "--exclusive", "--enable=$OUTDATED_PATCH_NAME", "--enable=$UPGRADE_PATCH_NAME", + "--enable=$POST_AGE_VERIFICATION_PATCH_NAME", "--unsigned", "--out=${patchedApk.absolutePathString()}", "--result-file=${resultFile.absolutePathString()}", @@ -93,7 +94,9 @@ class MorphePatchIntegrationTest { val appliedPatchNames = result.getAsJsonArray("appliedPatches") .map { it.asJsonObject.get("name").asString } assertTrue( - appliedPatchNames.containsAll(listOf(OUTDATED_PATCH_NAME, UPGRADE_PATCH_NAME)), + appliedPatchNames.containsAll( + listOf(OUTDATED_PATCH_NAME, UPGRADE_PATCH_NAME, POST_AGE_VERIFICATION_PATCH_NAME) + ), "Expected patches were not applied: $appliedPatchNames" ) assertTrue(result.getAsJsonArray("failedPatches").isEmpty, "Morphe reported failed patches") @@ -148,6 +151,7 @@ class MorphePatchIntegrationTest { private companion object { const val OUTDATED_PATCH_NAME = "Disable outdated version screen" const val UPGRADE_PATCH_NAME = "Remove timeline Upgrade button" + const val POST_AGE_VERIFICATION_PATCH_NAME = "Remove post age verification" const val MORPHE_VERSION = "1.13.1" const val MORPHE_SHA256 = "a212531f68d3ada4b504bf9dac3e02460589f3bf8868ee66e1b4780152d3466b" const val MORPHE_URL = diff --git a/patches/src/main/kotlin/app/twitter/patches/RemovePostAgeVerificationPatch.kt b/patches/src/main/kotlin/app/twitter/patches/RemovePostAgeVerificationPatch.kt new file mode 100644 index 0000000..fed44c2 --- /dev/null +++ b/patches/src/main/kotlin/app/twitter/patches/RemovePostAgeVerificationPatch.kt @@ -0,0 +1,32 @@ +package app.twitter.patches + +import app.morphe.patcher.Fingerprint +import app.morphe.patcher.extensions.InstructionExtensions.addInstructions +import app.morphe.patcher.patch.bytecodePatch +import app.twitter.patches.shared.Constants.COMPATIBILITY_X + +private val postAgeVerificationActionFingerprint = Fingerprint( + definingClass = "Lcom/twitter/model/mediavisibility/c${'$'}b;", + name = "a", + returnType = "Lcom/twitter/model/mediavisibility/c;", + parameters = listOf("Ljava/lang/String;") +) + +@Suppress("unused") +val removePostAgeVerificationPatch = bytecodePatch( + name = "Remove post age verification", + description = "Allows age-gated posts to be viewed without completing age verification.", + default = true +) { + compatibleWith(COMPATIBILITY_X) + + execute { + postAgeVerificationActionFingerprint.method.addInstructions( + 0, + """ + const/4 v0, 0x0 + return-object v0 + """ + ) + } +}