generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from crimera/dev
chore: Merge branch `dev` to `main`
- Loading branch information
Showing
13 changed files
with
308 additions
and
21 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
org.gradle.parallel = true | ||
org.gradle.caching = true | ||
kotlin.code.style = official | ||
version = 1.10.0 | ||
version = 1.11.0-dev.3 |
46 changes: 46 additions & 0 deletions
46
src/main/kotlin/crimera/patches/twitter/ads/trends/HidePromotedTrendPatch.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,46 @@ | ||
package crimera.patches.twitter.ads.trends | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
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 app.revanced.patcher.util.smali.ExternalLabel | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction | ||
import crimera.patches.twitter.ads.trends.fingerprints.HidePromotedTrendFingerprint | ||
|
||
@Patch( | ||
name = "Hide Promoted Trends", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = false | ||
) | ||
@Suppress("unused") | ||
class HidePromotedTrendPatch : BytecodePatch( | ||
setOf(HidePromotedTrendFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result = HidePromotedTrendFingerprint.result | ||
?: throw PatchException("Fingerprint not found") | ||
|
||
val method = result.mutableMethod | ||
val instructions = method.getInstructions() | ||
|
||
val return_obj = instructions.last { it.opcode == Opcode.RETURN_OBJECT } | ||
val return_loc = return_obj.location.index | ||
val return_reg = method.getInstruction<OneRegisterInstruction>(return_loc).registerA | ||
val loc = return_loc-7 | ||
val reg = method.getInstruction<TwoRegisterInstruction>(loc).registerA | ||
|
||
method.addInstructionsWithLabels(return_loc,""" | ||
if-eqz v$reg, :cond_1212 | ||
const v$return_reg, 0x0 | ||
""".trimIndent(), | ||
ExternalLabel("cond_1212", return_obj) | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...in/kotlin/crimera/patches/twitter/ads/trends/fingerprints/HidePromotedTrendFingerprint.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.ads.trends.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object HidePromotedTrendFingerprint : MethodFingerprint( | ||
returnType = "Ljava/lang/Object;", | ||
customFingerprint = {it,_-> | ||
it.definingClass == "Lcom/twitter/model/json/timeline/urt/JsonTimelineTrend;" | ||
} | ||
) |
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
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
16 changes: 16 additions & 0 deletions
16
...ches/twitter/interaction/downloads/unlockdownloads/fingerprints/MediaEntityFingerprint.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,16 @@ | ||
package crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
|
||
object MediaEntityFingerprint:MethodFingerprint( | ||
opcodes = listOf( | ||
Opcode.IGET_BOOLEAN, | ||
), | ||
|
||
customFingerprint = { it, _ -> | ||
it.definingClass == "Lcom/twitter/model/json/core/JsonMediaEntity;" | ||
} | ||
|
||
) |
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/crimera/patches/twitter/link/unshorten/NoShortenedUrlPatch.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,54 @@ | ||
package crimera.patches.twitter.link.unshorten | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
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.fingerprint.MethodFingerprint | ||
import app.revanced.patcher.fingerprint.MethodFingerprintResult | ||
import app.revanced.patcher.patch.BytecodePatch | ||
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.link.unshorten.fingerprints.JsonObjectMapperFingerprint | ||
|
||
@Patch( | ||
name = "No shortened URL", | ||
description = "Get rid of t.co short urls.", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")] | ||
) | ||
@Suppress("unused") | ||
object NoShortenedUrlPatch : BytecodePatch( | ||
setOf(JsonObjectMapperFingerprint) | ||
) { | ||
private const val METHOD_REFERENCE = | ||
"Lapp/revanced/integrations/twitter/patches/links/UnshortenUrlsPatch;->" + | ||
"unshort(Ljava/lang/Object;)V" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
|
||
val result = JsonObjectMapperFingerprint.result | ||
?: throw Exception("Fingerprint not found") | ||
|
||
val method = result.mutableMethod | ||
val instructions = method.getInstructions() | ||
|
||
// somehow targetIndex2 is above :cond_2, inject again before branching | ||
var targetIndex = -1 | ||
val targetIndex2 = instructions.size - 1 | ||
for (i in 0..targetIndex2) { | ||
if (instructions[i].opcode == Opcode.IF_EQ) { | ||
targetIndex = i; | ||
} | ||
} | ||
|
||
val inject = """ | ||
invoke-static { v0 }, $METHOD_REFERENCE | ||
""".trimIndent() | ||
|
||
result.mutableMethod.addInstructions(targetIndex, inject) | ||
result.mutableMethod.addInstructions(targetIndex2, inject) | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...kotlin/crimera/patches/twitter/link/unshorten/fingerprints/JsonObjectMapperFingerprint.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,11 @@ | ||
package crimera.patches.twitter.link.unshorten.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
|
||
|
||
internal object JsonObjectMapperFingerprint : MethodFingerprint( | ||
// Lcom/twitter/model/json/core/JsonUrlEntity$$JsonObjectMapper; | ||
customFingerprint = { methodDef, _ -> methodDef.name.contains("parse") && methodDef.definingClass == "Lcom/twitter/model/json/core/JsonUrlEntity\$\$JsonObjectMapper;" } | ||
) |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/crimera/patches/twitter/misc/FAB/HideFABMenuButtonsPatch.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,39 @@ | ||
package crimera.patches.twitter.misc.FAB | ||
|
||
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.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.misc.FAB.fingerprints.HideFABFingerprint | ||
|
||
@Patch( | ||
name = "Hide FAB Menu Buttons", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = false | ||
) | ||
@Suppress("unused") | ||
class HideFABMenuButtonsPatch : BytecodePatch( | ||
setOf(HideFABFingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
val result = HideFABFingerprint.result | ||
?: throw PatchException("Fingerprint not found") | ||
|
||
val method = result.mutableMethod | ||
val instructions = method.getInstructions() | ||
val loc = instructions.last { it.opcode == Opcode.CONST_STRING }.location.index+2 | ||
val reg = method.getInstruction<OneRegisterInstruction>(loc).registerA | ||
|
||
method.addInstructions(loc+1,""" | ||
const v$reg, false | ||
""".trimIndent(), | ||
) | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/crimera/patches/twitter/misc/FAB/HideFABPatch.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.misc.FAB | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
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 app.revanced.patcher.util.smali.ExternalLabel | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import crimera.patches.twitter.misc.FAB.fingerprints.HideFABFingerprint | ||
|
||
@Patch( | ||
name = "Hide FAB", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")] , | ||
use = false | ||
) | ||
@Suppress("unused") | ||
class HideFABPatch :BytecodePatch( | ||
setOf(HideFABFingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
val result = HideFABFingerprint.result | ||
?: throw PatchException("Fingerprint not found") | ||
|
||
val method = result.mutableMethod | ||
val instructions = method.getInstructions() | ||
val const_obj = instructions.last { it.opcode == Opcode.CONST_4 } | ||
|
||
method.addInstructionsWithLabels(0,""" | ||
goto :cond_1212 | ||
""".trimIndent(), | ||
ExternalLabel("cond_1212",const_obj) | ||
) | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/crimera/patches/twitter/misc/FAB/fingerprints/HideFABFingerprint.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,9 @@ | ||
package crimera.patches.twitter.misc.FAB.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
object HideFABFingerprint: MethodFingerprint( | ||
strings = listOf( | ||
"android_compose_fab_menu_enabled" | ||
) | ||
) |
Oops, something went wrong.