generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Customize explore tabs
patch
- Loading branch information
swakwork
committed
Nov 27, 2024
1 parent
0792795
commit 4be6a7f
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...in/kotlin/crimera/patches/twitter/misc/customize/exploretabs/CustomiseExploreTabsPatch.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,53 @@ | ||
package crimera.patches.twitter.misc.customize.timelinetabs | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
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.misc.settings.SettingsPatch | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
|
||
object CustomiseExploreTabsFingerprint : MethodFingerprint( | ||
opcodes = listOf(Opcode.NEW_INSTANCE), | ||
customFingerprint = { it, _ -> | ||
it.definingClass.endsWith("JsonPageTabs;") | ||
}, | ||
) | ||
|
||
@Patch( | ||
name = "Customize explore tabs", | ||
dependencies = [SettingsPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = true, | ||
) | ||
@Suppress("unused") | ||
object CustomiseExploreTabsPatch : BytecodePatch( | ||
setOf(CustomiseExploreTabsFingerprint, SettingsStatusLoadFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result = | ||
CustomiseExploreTabsFingerprint.result | ||
?: throw PatchException("CustomiseExploreTabsFingerprint not found") | ||
|
||
val method = result.mutableMethod | ||
|
||
val instructions = method.getInstructions() | ||
|
||
val index = instructions.first { it.opcode == Opcode.IGET_OBJECT }.location.index | ||
|
||
method.addInstructions( | ||
index + 1, | ||
""" | ||
invoke-static {v1}, ${SettingsPatch.CUSTOMISE_DESCRIPTOR};->exploretabs(Ljava/util/ArrayList;)Ljava/util/ArrayList; | ||
move-result-object v1 | ||
""".trimIndent(), | ||
) | ||
|
||
SettingsStatusLoadFingerprint.enableSettings("exploreTabCustomisation") | ||
} | ||
} |
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
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