From 21c3fb429b82acfb3a6b497c06c2a4e2ad596a9f Mon Sep 17 00:00:00 2001 From: crimera Date: Thu, 8 Feb 2024 23:26:18 +0800 Subject: [PATCH] feat(twitter): Add Show sensitive media patch --- .../ShowSensitiveMediaPatch.kt | 38 +++++++++++++++++++ .../ShowSensitiveMediaPatchFingerprint.kt | 19 ++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/ShowSensitiveMediaPatch.kt create mode 100644 src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/fingerprints/ShowSensitiveMediaPatchFingerprint.kt diff --git a/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/ShowSensitiveMediaPatch.kt b/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/ShowSensitiveMediaPatch.kt new file mode 100644 index 00000000..3cb7fa51 --- /dev/null +++ b/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/ShowSensitiveMediaPatch.kt @@ -0,0 +1,38 @@ +package crimera.patches.twitter.sensitivemediasettings + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.getInstructions +import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchException +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import com.android.tools.smali.dexlib2.Opcode +import crimera.patches.twitter.sensitivemediasettings.fingerprints.SensitiveMediaSettingsPatchFingerprint + +// Credits to @Cradlesofashes +@Patch( + name = "Show sensitive media", + description = "Shows sensitive media", + compatiblePackages = [CompatiblePackage("com.twitter.android")] +) +@Suppress("unused") +object SensitiveMediaPatch: BytecodePatch( + setOf(SensitiveMediaSettingsPatchFingerprint) +) { + override fun execute(context: BytecodeContext) { + val result = SensitiveMediaSettingsPatchFingerprint.result + ?: throw PatchException("Fingerprint not found") + + val method = result.mutableMethod + val instructions = method.getInstructions() + + instructions.filter{ it.opcode == Opcode.IPUT_BOOLEAN }.forEach { + method.removeInstruction(it.location.index) + } + + instructions.forEach { + println(it.opcode) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/fingerprints/ShowSensitiveMediaPatchFingerprint.kt b/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/fingerprints/ShowSensitiveMediaPatchFingerprint.kt new file mode 100644 index 00000000..d119040f --- /dev/null +++ b/src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/fingerprints/ShowSensitiveMediaPatchFingerprint.kt @@ -0,0 +1,19 @@ +package crimera.patches.twitter.sensitivemediasettings.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.Opcode + +object SensitiveMediaSettingsPatchFingerprint: MethodFingerprint( + returnType = "V", + strings = listOf( + "adult_content", + "graphic_violence", + "other" + ), + opcodes = listOf( + Opcode.IPUT_BOOLEAN, + ), + customFingerprint = { it, _ -> + it.definingClass == "Lcom/twitter/model/json/core/JsonSensitiveMediaWarning\$\$JsonObjectMapper;" + } +) \ No newline at end of file