generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(twitter): Add Show sensitive media patch
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/crimera/patches/twitter/sensitivemediasettings/ShowSensitiveMediaPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...patches/twitter/sensitivemediasettings/fingerprints/ShowSensitiveMediaPatchFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;" | ||
} | ||
) |