mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(youtube): remove hide-search-terms
patch
This commit is contained in:
@ -1,19 +0,0 @@
|
||||
package app.revanced.patches.youtube.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",
|
||||
accessFlags = 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
|
||||
)
|
||||
)
|
@ -1,12 +0,0 @@
|
||||
package app.revanced.patches.youtube.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",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf(),
|
||||
strings = listOf("voz-target-id")
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
package app.revanced.patches.youtube.general.searchterms.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SearchSuggestionEntry
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
|
||||
object SearchSuggestionEntryFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(SearchSuggestionEntry) }
|
||||
)
|
@ -1,95 +0,0 @@
|
||||
package app.revanced.patches.youtube.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.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
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.youtube.general.searchterms.fingerprints.SearchEndpointFingerprint
|
||||
import app.revanced.patches.youtube.general.searchterms.fingerprints.SearchEndpointParentFingerprint
|
||||
import app.revanced.patches.youtube.general.searchterms.fingerprints.SearchSuggestionEntryFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SearchSuggestionEntry
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@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 {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val targetRegister =
|
||||
getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"sput-boolean v$targetRegister, $GENERAL->isSearchWordEmpty:Z"
|
||||
)
|
||||
}
|
||||
} ?: return SearchEndpointFingerprint.toErrorResult()
|
||||
} ?: return SearchEndpointParentFingerprint.toErrorResult()
|
||||
|
||||
SearchSuggestionEntryFingerprint.result?.mutableMethod?.let {
|
||||
val targetIndex = it.getWideLiteralIndex(SearchSuggestionEntry) + 2
|
||||
val targetRegister = it.getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
it.addInstruction(
|
||||
targetIndex + 4,
|
||||
"invoke-static {v$targetRegister}, $GENERAL->hideSearchTerms(Landroid/view/View;)V"
|
||||
)
|
||||
|
||||
it.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()
|
||||
}
|
||||
}
|
@ -72,7 +72,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var RightComment: Long = -1
|
||||
var ScrimOverlay: Long = -1
|
||||
var Scrubbing: Long = -1
|
||||
var SearchSuggestionEntry: Long = -1
|
||||
var SettingsBooleanTimeRangeDialog: Long = -1
|
||||
var SuggestedAction: Long = -1
|
||||
var ToolBarPaddingHome: Long = -1
|
||||
@ -140,7 +139,6 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
RightComment = find(DRAWABLE, "ic_right_comment_32c")
|
||||
ScrimOverlay = find(ID, "scrim_overlay")
|
||||
Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
SearchSuggestionEntry = find(LAYOUT, "search_suggestion_entry")
|
||||
SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog")
|
||||
SuggestedAction = find(LAYOUT, "suggested_action")
|
||||
ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up")
|
||||
|
Reference in New Issue
Block a user