Skip to content

Commit

Permalink
feat(twitter): Add Show sensitive media patch
Browse files Browse the repository at this point in the history
  • Loading branch information
crimera committed Feb 8, 2024
1 parent a200a08 commit 21c3fb4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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;"
}
)

0 comments on commit 21c3fb4

Please sign in to comment.