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): added
Undo Posts Patch
- Loading branch information
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/kotlin/crimera/patches/twitter/premium/undoposts/EnableUndoPostPatch.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,69 @@ | ||
package crimera.patches.twitter.premium.undoposts | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions | ||
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 com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
import crimera.patches.twitter.premium.undoposts.fingerprints.UndoPost1Fingerprint | ||
import crimera.patches.twitter.premium.undoposts.fingerprints.UndoPost2Fingerprint | ||
import crimera.patches.twitter.premium.undoposts.fingerprints.UndoPost3Fingerprint | ||
|
||
@Patch( | ||
name = "Enable Undo Posts", | ||
description = "Enable ability to undo posts before it gets posted", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = false | ||
) | ||
object EnableUndoPostPatch :BytecodePatch( | ||
setOf(UndoPost1Fingerprint,UndoPost2Fingerprint,UndoPost3Fingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
|
||
val result1 = UndoPost1Fingerprint.result | ||
?: throw PatchException("UndoPost1Fingerprint not found") | ||
|
||
//removes flag check | ||
val method1 = result1.mutableMethod | ||
val loc1 = method1.getInstructions().first { it.opcode == Opcode.IF_EQZ }.location.index | ||
method1.removeInstruction(loc1) | ||
|
||
|
||
|
||
val result2 = UndoPost2Fingerprint.result | ||
?: throw PatchException("UndoPost2Fingerprint not found") | ||
|
||
//removes flag check | ||
val method2 = result2.mutableMethod | ||
val loc2 = method2.getInstructions().first { it.opcode == Opcode.IF_EQZ }.location.index | ||
method2.removeInstruction(loc2) | ||
|
||
val result3 = UndoPost3Fingerprint.result | ||
?: throw PatchException("UndoPost2Fingerprint not found") | ||
|
||
|
||
|
||
//removes flag check and always return true | ||
val method3 = result3.mutableMethod | ||
|
||
val instructions = method3.getInstructions() | ||
method3.removeInstructions(0, instructions.count()) | ||
|
||
method3.addInstructions(0,""" | ||
sget-object v0, Ljava/lang/Boolean;->TRUE:Ljava/lang/Boolean; | ||
return-object v0 | ||
""".trimIndent()) | ||
|
||
|
||
|
||
//end | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...ain/kotlin/crimera/patches/twitter/premium/undoposts/fingerprints/UndoPost1Fingerprint.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,18 @@ | ||
package crimera.patches.twitter.premium.undoposts.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
object UndoPost1Fingerprint :MethodFingerprint( | ||
returnType = "Z", | ||
strings = listOf( | ||
"subscriptions_feature_1003", | ||
"allow_undo_replies", | ||
"allow_undo_tweet" | ||
), | ||
opcodes = listOf( | ||
Opcode.MOVE_RESULT_OBJECT | ||
) | ||
|
||
|
||
) |
14 changes: 14 additions & 0 deletions
14
...ain/kotlin/crimera/patches/twitter/premium/undoposts/fingerprints/UndoPost2Fingerprint.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,14 @@ | ||
package crimera.patches.twitter.premium.undoposts.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object UndoPost2Fingerprint :MethodFingerprint( | ||
returnType = "Z", | ||
strings = listOf( | ||
"userPreferences", | ||
"draftTweet", | ||
"subscriptions_feature_1003", | ||
"allow_undo_replies", | ||
"allow_undo_tweet" | ||
) | ||
) |
10 changes: 10 additions & 0 deletions
10
...ain/kotlin/crimera/patches/twitter/premium/undoposts/fingerprints/UndoPost3Fingerprint.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,10 @@ | ||
package crimera.patches.twitter.premium.undoposts.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object UndoPost3Fingerprint :MethodFingerprint( | ||
returnType = "Ljava/lang/Object;", | ||
strings = listOf( | ||
"subscriptions_feature_1003" | ||
) | ||
) |