mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
add hide-search-terms
patch https://github.com/inotia00/ReVanced_Extended/issues/657
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.youtube.layout.general.searchterms.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object SearchEndpointFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.CONST_16,
|
||||
Opcode.CONST_4
|
||||
)
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.layout.general.searchterms.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object SearchEndpointParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf(),
|
||||
strings = listOf("voz-target-id")
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.youtube.layout.general.searchterms.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
object SearchSuggestionEntryFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.searchSuggestionEntryLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -0,0 +1,91 @@
|
||||
package app.revanced.patches.youtube.layout.general.searchterms.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.layout.general.searchterms.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
@Patch
|
||||
@Name("hide-search-terms")
|
||||
@Description("Hide trending searches and search history in the search bar.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class SearchTermsPatch : BytecodePatch(
|
||||
listOf(
|
||||
SearchEndpointParentFingerprint,
|
||||
SearchSuggestionEntryFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
SearchEndpointParentFingerprint.result?.let { parentResult ->
|
||||
SearchEndpointFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"sput-boolean v$targetRegister, $GENERAL->isSearchWordEmpty:Z"
|
||||
)
|
||||
}
|
||||
} ?: return SearchEndpointFingerprint.toErrorResult()
|
||||
} ?: return SearchEndpointParentFingerprint.toErrorResult()
|
||||
|
||||
SearchSuggestionEntryFingerprint.result?.mutableMethod?.let { method ->
|
||||
with (method.implementation!!.instructions) {
|
||||
val targetIndex = this.indexOfFirst {
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.searchSuggestionEntryLabelId
|
||||
} + 2
|
||||
|
||||
val targetRegister = (elementAt(targetIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
method.addInstruction(
|
||||
targetIndex + 4,
|
||||
"invoke-static {v$targetRegister}, $GENERAL->hideSearchTerms(Landroid/view/View;)V"
|
||||
)
|
||||
|
||||
method.addInstruction(
|
||||
targetIndex + 2,
|
||||
"invoke-static {v$targetRegister}, $GENERAL->hideSearchTerms(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
} ?: return SearchSuggestionEntryFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: GENERAL_SETTINGS",
|
||||
"SETTINGS: HIDE_SEARCH_TERMS"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-search-terms")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var reelRemixLabelId: Long = -1
|
||||
var relatedChipCloudMarginLabelId: Long = -1
|
||||
var rightCommentLabelId: Long = -1
|
||||
var searchSuggestionEntryLabelId: Long = -1
|
||||
var scrubbingLabelId: Long = -1
|
||||
var timeBarPlayedDarkLabelId: Long = -1
|
||||
var timeStampsContainerLabelId: Long = -1
|
||||
@ -89,6 +90,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
reelRemixLabelId = find(ID, "reel_dyn_remix")
|
||||
relatedChipCloudMarginLabelId = find(LAYOUT, "related_chip_cloud_reduced_margins")
|
||||
rightCommentLabelId = find(DRAWABLE, "ic_right_comment_32c")
|
||||
searchSuggestionEntryLabelId = find(LAYOUT, "search_suggestion_entry")
|
||||
scrubbingLabelId = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
timeBarPlayedDarkLabelId = find(COLOR, "inline_time_bar_colorized_bar_played_color_dark")
|
||||
timeStampsContainerLabelId = find(ID, "timestamps_container")
|
||||
|
Reference in New Issue
Block a user