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 search suggestions
patch
- Loading branch information
swakwork
committed
Dec 7, 2024
1 parent
95b5ef9
commit aaca565
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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