From 95b5ef902e6f595093b2304e5b2a8189f273389c Mon Sep 17 00:00:00 2001 From: swakwork Date: Fri, 6 Dec 2024 23:51:45 +0530 Subject: [PATCH 1/5] feat(Twitter): Added `Remove top people in search` patch --- .../timelineEntryHook/HideTopPeopleSearch.kt | 23 +++++++++++++++++++ .../twitter/settings/values/strings.xml | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideTopPeopleSearch.kt diff --git a/src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideTopPeopleSearch.kt b/src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideTopPeopleSearch.kt new file mode 100644 index 00000000..a3975c28 --- /dev/null +++ b/src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideTopPeopleSearch.kt @@ -0,0 +1,23 @@ +package crimera.patches.twitter.ads.timelineEntryHook + +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.annotation.CompatiblePackage +import app.revanced.patcher.patch.annotation.Patch +import crimera.patches.twitter.misc.settings.SettingsPatch +import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint + +@Patch( + name = "Remove top people in search", + description = "Removes people section after search", + dependencies = [SettingsPatch::class, TimelineEntryHookPatch::class], + compatiblePackages = [CompatiblePackage("com.twitter.android")], + use = true, +) +object HideTopPeopleSearch : BytecodePatch( + setOf(SettingsStatusLoadFingerprint), +) { + override fun execute(context: BytecodeContext) { + SettingsStatusLoadFingerprint.enableSettings("hideTopPeopleSearch") + } +} diff --git a/src/main/resources/twitter/settings/values/strings.xml b/src/main/resources/twitter/settings/values/strings.xml index 8c3476df..1a5a413c 100644 --- a/src/main/resources/twitter/settings/values/strings.xml +++ b/src/main/resources/twitter/settings/values/strings.xml @@ -53,6 +53,8 @@ Deleted items premium upsell Removes premium upsell in home timeline + top people in search + Removes people section after search Misc From aaca565c650d6cf4b2cbb8abf2e206efe9983cb1 Mon Sep 17 00:00:00 2001 From: swakwork Date: Sat, 7 Dec 2024 13:55:51 +0530 Subject: [PATCH 2/5] feat(Twitter): Added `Customize search suggestions` patch --- .../CustomiseTypeAheadResponsePatch.kt | 53 +++++++++++++++++++ .../twitter/settings/values-v21/arrays.xml | 8 +++ .../twitter/settings/values/arrays.xml | 8 +++ .../twitter/settings/values/strings.xml | 5 ++ 4 files changed, 74 insertions(+) create mode 100644 src/main/kotlin/crimera/patches/twitter/misc/customize/typeAheadResponse/CustomiseTypeAheadResponsePatch.kt diff --git a/src/main/kotlin/crimera/patches/twitter/misc/customize/typeAheadResponse/CustomiseTypeAheadResponsePatch.kt b/src/main/kotlin/crimera/patches/twitter/misc/customize/typeAheadResponse/CustomiseTypeAheadResponsePatch.kt new file mode 100644 index 00000000..41f3a6b7 --- /dev/null +++ b/src/main/kotlin/crimera/patches/twitter/misc/customize/typeAheadResponse/CustomiseTypeAheadResponsePatch.kt @@ -0,0 +1,53 @@ +package crimera.patches.twitter.misc.customize.typeAheadResponse + +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 CustomiseTypeAheadResponseFingerprint : MethodFingerprint( + returnType = "Ljava/lang/Object", + customFingerprint = { methodDef, _ -> + methodDef.name == "parse" && methodDef.definingClass.endsWith("JsonTypeaheadResponse\$\$JsonObjectMapper;") + }, +) + +@Patch( + name = "Customize search suggestions", + dependencies = [SettingsPatch::class], + compatiblePackages = [CompatiblePackage("com.twitter.android")], + use = true, +) +@Suppress("unused") +object CustomiseTypeAheadResponsePatch : BytecodePatch( + setOf(CustomiseTypeAheadResponseFingerprint, SettingsStatusLoadFingerprint), +) { + override fun execute(context: BytecodeContext) { + val result = + CustomiseTypeAheadResponseFingerprint.result + ?: throw PatchException("CustomiseTypeAheadResponseFingerprint not found") + + val method = result.mutableMethod + + val instructions = method.getInstructions() + + val returnObj = instructions.last { it.opcode == Opcode.RETURN_OBJECT }.location.index + + method.addInstructions( + returnObj, + """ + invoke-static {p1}, ${SettingsPatch.CUSTOMISE_DESCRIPTOR};->typeAheadResponse(Lcom/twitter/model/json/search/JsonTypeaheadResponse;)Lcom/twitter/model/json/search/JsonTypeaheadResponse; + move-result-object p1 + """, + ) + + SettingsStatusLoadFingerprint.enableSettings("typeaheadCustomisation") + } +} diff --git a/src/main/resources/twitter/settings/values-v21/arrays.xml b/src/main/resources/twitter/settings/values-v21/arrays.xml index 5da81ad7..b910eded 100644 --- a/src/main/resources/twitter/settings/values-v21/arrays.xml +++ b/src/main/resources/twitter/settings/values-v21/arrays.xml @@ -50,4 +50,12 @@ 1 + + users + topics + events + lists + ordered_section + + \ No newline at end of file diff --git a/src/main/resources/twitter/settings/values/arrays.xml b/src/main/resources/twitter/settings/values/arrays.xml index c6903534..0ee25071 100644 --- a/src/main/resources/twitter/settings/values/arrays.xml +++ b/src/main/resources/twitter/settings/values/arrays.xml @@ -100,4 +100,12 @@ @string/piko_native_translator_google_v2 + + @string/piko_pref_search_type_ahead_users + @string/channel_topics_title + @string/piko_pref_search_type_ahead_events + @string/search_scope_lists + @string/piko_pref_search_type_ahead_ordered_section + + \ No newline at end of file diff --git a/src/main/resources/twitter/settings/values/strings.xml b/src/main/resources/twitter/settings/values/strings.xml index 1a5a413c..40ff2065 100644 --- a/src/main/resources/twitter/settings/values/strings.xml +++ b/src/main/resources/twitter/settings/values/strings.xml @@ -125,6 +125,7 @@ Default reply sorting filter Previously selected Post font size + Customize search suggestions Backup and restore @@ -157,4 +158,8 @@ Google translator Google translator V2 + Users + Events + Ordered section + From 9edc97a89e61f28a5cd9a419d167a6c51a1a9816 Mon Sep 17 00:00:00 2001 From: swakwork Date: Sun, 8 Dec 2024 14:14:44 +0530 Subject: [PATCH 3/5] feat(Twitter): Added `Customize search tab items` patch --- .../searchtabs/CustomiseSearchTabsPatch.kt | 59 +++++++++++++++++++ .../twitter/settings/values-v21/arrays.xml | 9 +++ .../twitter/settings/values/arrays.xml | 10 ++++ .../twitter/settings/values/strings.xml | 1 + 4 files changed, 79 insertions(+) create mode 100644 src/main/kotlin/crimera/patches/twitter/misc/customize/searchtabs/CustomiseSearchTabsPatch.kt diff --git a/src/main/kotlin/crimera/patches/twitter/misc/customize/searchtabs/CustomiseSearchTabsPatch.kt b/src/main/kotlin/crimera/patches/twitter/misc/customize/searchtabs/CustomiseSearchTabsPatch.kt new file mode 100644 index 00000000..9b139870 --- /dev/null +++ b/src/main/kotlin/crimera/patches/twitter/misc/customize/searchtabs/CustomiseSearchTabsPatch.kt @@ -0,0 +1,59 @@ +package crimera.patches.twitter.misc.customize.searchtabs + +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.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 com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import crimera.patches.twitter.misc.settings.SettingsPatch +import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint + +object CustomiseSearchTabsPatchFingerprint : MethodFingerprint( + returnType = "Ljava/util/List;", + strings = + listOf( + "search_features_media_tab_enabled", + "search_features_lists_search_enabled", + ), +) + +@Patch( + name = "Customize search tab items", + dependencies = [SettingsPatch::class], + compatiblePackages = [CompatiblePackage("com.twitter.android")], + requiresIntegrations = true, +) +@Suppress("unused") +object CustomiseSearchTabsPatch : BytecodePatch( + setOf(CustomiseSearchTabsPatchFingerprint, SettingsStatusLoadFingerprint), +) { + override fun execute(context: BytecodeContext) { + val results = + CustomiseSearchTabsPatchFingerprint.result + ?: throw PatchException("CustomiseSearchTabsPatchFingerprint 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(returnObj_loc).registerA + + method.addInstructions( + returnObj_loc, + """ + invoke-static {v$r0}, ${SettingsPatch.CUSTOMISE_DESCRIPTOR};->searchTabs(Ljava/util/List;)Ljava/util/List; + move-result-object v$r0 + """.trimIndent(), + ) + + SettingsStatusLoadFingerprint.enableSettings("searchTabCustomisation") + + // end + } +} diff --git a/src/main/resources/twitter/settings/values-v21/arrays.xml b/src/main/resources/twitter/settings/values-v21/arrays.xml index b910eded..e06eea39 100644 --- a/src/main/resources/twitter/settings/values-v21/arrays.xml +++ b/src/main/resources/twitter/settings/values-v21/arrays.xml @@ -58,4 +58,13 @@ ordered_section + + 0 + 1 + 2 + 5 + 3 + 7 + 13 + \ No newline at end of file diff --git a/src/main/resources/twitter/settings/values/arrays.xml b/src/main/resources/twitter/settings/values/arrays.xml index 0ee25071..ea4c50a3 100644 --- a/src/main/resources/twitter/settings/values/arrays.xml +++ b/src/main/resources/twitter/settings/values/arrays.xml @@ -108,4 +108,14 @@ @string/piko_pref_search_type_ahead_ordered_section + + @string/search_scope_top + @string/search_scope_latest + @string/subtitle_people + @string/search_filter_videos + @string/search_filter_photos + @string/search_filter_media + @string/search_scope_lists + + \ No newline at end of file diff --git a/src/main/resources/twitter/settings/values/strings.xml b/src/main/resources/twitter/settings/values/strings.xml index 40ff2065..58e994bd 100644 --- a/src/main/resources/twitter/settings/values/strings.xml +++ b/src/main/resources/twitter/settings/values/strings.xml @@ -122,6 +122,7 @@ Navigation bar items to hide Inline bar items to hide Explore tabs + Search tabs Default reply sorting filter Previously selected Post font size From a75221b80c1d3223b88890a95ca1610432defbe2 Mon Sep 17 00:00:00 2001 From: swakwork Date: Sun, 8 Dec 2024 14:35:04 +0530 Subject: [PATCH 4/5] refactor(Twitter): Strings in 'Customization' --- .../resources/twitter/settings/values/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/twitter/settings/values/strings.xml b/src/main/resources/twitter/settings/values/strings.xml index 58e994bd..52552dc4 100644 --- a/src/main/resources/twitter/settings/values/strings.xml +++ b/src/main/resources/twitter/settings/values/strings.xml @@ -113,16 +113,16 @@ Customization - Profile tabs to hide - Timeline tabs + Customize profile tabs + Customize timeline tabs Remove \"For You\" Remove \"Following\" Show both - Side bar items to hide - Navigation bar items to hide - Inline bar items to hide - Explore tabs - Search tabs + Customize side bar items + Customize navigation bar items + Customize inline bar items + Customize explore tabs + Customize search tabs Default reply sorting filter Previously selected Post font size From c52c2c01948bdea5593636a99502d8b5c6c41dca Mon Sep 17 00:00:00 2001 From: swakwork Date: Sun, 8 Dec 2024 17:06:33 +0530 Subject: [PATCH 5/5] refactor(Twitter): Strings in 'Customization' --- .../twitter/settings/values/strings.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/twitter/settings/values/strings.xml b/src/main/resources/twitter/settings/values/strings.xml index 52552dc4..6110a531 100644 --- a/src/main/resources/twitter/settings/values/strings.xml +++ b/src/main/resources/twitter/settings/values/strings.xml @@ -113,20 +113,20 @@ Customization - Customize profile tabs - Customize timeline tabs + Profile tabs to hide + Timeline tabs to hide Remove \"For You\" Remove \"Following\" Show both - Customize side bar items - Customize navigation bar items - Customize inline bar items - Customize explore tabs - Customize search tabs + Side bar items to hide + Navigation bar items to hide + Inline bar items to hide + Explore tabs to hide + Search tabs to hide Default reply sorting filter Previously selected Post font size - Customize search suggestions + Search suggestions to hide Backup and restore