forked from crimera/piko
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Profile tabs customisation
- Loading branch information
Showing
6 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...in/kotlin/crimera/patches/twitter/misc/customize/profiletabs/CustomiseProfileTabsPatch.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,86 @@ | ||
package crimera.patches.twitter.misc.customize.profiletabs | ||
|
||
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.addInstructionsWithLabels | ||
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.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 app.revanced.patcher.util.smali.ExternalLabel | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
|
||
object CustomiseProfileTabsFingerprint:MethodFingerprint( | ||
returnType = "Ljava/util/ArrayList;", | ||
strings = listOf( | ||
"fragment_page_number", | ||
"arg_is_unlimited_timeline", | ||
"statuses_count", | ||
"tweets", | ||
"blue_business_affiliates_list_consumption_ui_enabled", | ||
) | ||
) | ||
|
||
@Patch( | ||
name = "Customize profile tabs", | ||
dependencies = [SettingsPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
use = false, | ||
requiresIntegrations = true | ||
) | ||
@Suppress("unused") | ||
object CustomiseProfileTabsPatch:BytecodePatch( | ||
setOf(CustomiseProfileTabsFingerprint,SettingsStatusLoadFingerprint) | ||
){ | ||
override fun execute(context: BytecodeContext) { | ||
val results = CustomiseProfileTabsFingerprint.result | ||
?:throw PatchException("CustomiseProfileTabsFingerprint not found") | ||
|
||
val method = results.mutableMethod | ||
val instructions = method.getInstructions() | ||
|
||
val returnObj_loc = instructions.last { it.opcode == Opcode.RETURN_OBJECT }.location.index | ||
val r0 = method.getInstruction<OneRegisterInstruction>(returnObj_loc).registerA | ||
|
||
val METHOD = """ | ||
invoke-static {v$r0}, ${SettingsPatch.CUSTOMISE_DESCRIPTOR}/ProfileTabs;->a(Ljava/util/ArrayList;)Ljava/util/ArrayList; | ||
move-result-object v$r0 | ||
""".trimIndent() | ||
|
||
method.addInstructions(returnObj_loc,METHOD) | ||
|
||
val last_if_eqz = instructions.last { it.opcode == Opcode.IF_EQZ }.location.index | ||
val r1 = method.getInstruction<OneRegisterInstruction>(last_if_eqz).registerA | ||
|
||
val last_if_nez_loc = instructions.last { it.opcode == Opcode.IF_NEZ }.location.index | ||
val r2 = method.getInstruction<OneRegisterInstruction>(last_if_nez_loc).registerA | ||
|
||
//it works dont ask me how | ||
method.removeInstruction(last_if_eqz) | ||
method.removeInstruction(last_if_eqz) | ||
method.removeInstruction(last_if_eqz) | ||
|
||
method.addInstructionsWithLabels(last_if_eqz, | ||
""" | ||
if-eqz v$r1, :check2 | ||
const/4 v$r2, 0x1 | ||
:check2 | ||
if-nez v$r2, :check1 | ||
""".trimIndent(), ExternalLabel("check1",instructions.last { it.opcode == Opcode.INVOKE_STATIC }) | ||
) | ||
|
||
SettingsStatusLoadFingerprint.result!!.mutableMethod.addInstruction( | ||
0, | ||
"${SettingsPatch.SSTS_DESCRIPTOR}->profileTabCustomisation()V" | ||
) | ||
//end | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- Translation Exception --> | ||
<string name="piko_title_settings">Piko Mod Settings</string> | ||
<!-- Dont translate these --> | ||
<string name="piko_title_settings">Piko mod Settings</string> | ||
<string name="piko_title_feature_flags">Feature flags</string> | ||
</resources> |
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<resources> | ||
<!-- Dont translate these --> | ||
<string-array name="piko_array_profiletabs"> | ||
<item>@string/profile_tab_title_timeline</item> | ||
<item>@string/profile_tab_title_timeline_tweets_and_replies_sentence_case</item> | ||
<item>@string/profile_tab_title_affiliates</item> | ||
<item>@string/profile_tab_title_timeline_super_follow_tweets</item> | ||
<item>@string/profile_tab_title_highlights</item> | ||
<item>@string/profile_tab_title_articles</item> | ||
<item>@string/profile_tab_title_media</item> | ||
<item>@string/profile_tab_title_likes</item> | ||
</string-array> | ||
</resources> |
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