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 #494 from swakwork/dev
feat(Twitter): Explore search features
- Loading branch information
Showing
6 changed files
with
180 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/crimera/patches/twitter/ads/timelineEntryHook/HideTopPeopleSearch.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,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") | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...main/kotlin/crimera/patches/twitter/misc/customize/searchtabs/CustomiseSearchTabsPatch.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,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<OneRegisterInstruction>(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 | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...imera/patches/twitter/misc/customize/typeAheadResponse/CustomiseTypeAheadResponsePatch.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.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") | ||
} | ||
} |
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