diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/trendingsearches/TrendingSearchesPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/trendingsearches/TrendingSearchesPatch.kt index d2bfc4fa7..75426b080 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/trendingsearches/TrendingSearchesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/trendingsearches/TrendingSearchesPatch.kt @@ -11,6 +11,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineArrowTimeBlack import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineFireBlack +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineNewSearchBlack import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.YtOutlineSearchBlack import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.util.exception @@ -66,20 +67,22 @@ object TrendingSearchesPatch : BytecodePatch( SearchBarEntryFingerprint.result?.let { it.mutableMethod.apply { SearchTerm.entries - .map { searchTerm -> getWideLiteralInstructionIndex(searchTerm.resourceId) to searchTerm.value } + .map { searchTerm -> getWideLiteralInstructionIndex(searchTerm.resourceId) to searchTerm.booleanValue } .sortedBy { searchTerm -> searchTerm.first } .reversed() - .forEach { (index, value) -> - val freeRegister = getInstruction(index).registerA - val viewRegister = - getInstruction(index - 1).registerA + .forEach { (targetIndex, booleanValue) -> + if (targetIndex > 1) { + val freeRegister = getInstruction(targetIndex).registerA + val viewRegister = + getInstruction(targetIndex - 1).registerA - addInstructions( - index, """ - const/4 v$freeRegister, $value - invoke-static {v$viewRegister, v$freeRegister}, $GENERAL->hideTrendingSearches(Landroid/widget/ImageView;Z)V - """ - ) + addInstructions( + targetIndex, """ + const/4 v$freeRegister, $booleanValue + invoke-static {v$viewRegister, v$freeRegister}, $GENERAL->hideTrendingSearches(Landroid/widget/ImageView;Z)V + """ + ) + } } } } ?: throw SearchBarEntryFingerprint.exception @@ -98,9 +101,10 @@ object TrendingSearchesPatch : BytecodePatch( } - private enum class SearchTerm(val resourceId: Long, val value: Int) { + private enum class SearchTerm(val resourceId: Long, val booleanValue: Int) { HISTORY(YtOutlineArrowTimeBlack, 0), SEARCH(YtOutlineSearchBlack, 0), + NEW_SEARCH(YtOutlineNewSearchBlack, 0), TRENDING(YtOutlineFireBlack, 1) } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt index 8a91c065c..004a5f8fd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt @@ -86,6 +86,7 @@ object SharedResourceIdPatch : ResourcePatch() { var YoutubeControlsOverlaySubtitleButton: Long = -1 var YtOutlineArrowTimeBlack: Long = -1 var YtOutlineFireBlack: Long = -1 + var YtOutlineNewSearchBlack: Long = -1 var YtOutlineSearchBlack: Long = -1 override fun execute(context: ResourceContext) { @@ -169,6 +170,7 @@ object SharedResourceIdPatch : ResourcePatch() { YoutubeControlsOverlaySubtitleButton = find(LAYOUT, "youtube_controls_overlay_subtitle_button") YtOutlineArrowTimeBlack = find(DRAWABLE, "yt_outline_arrow_time_black_24") YtOutlineFireBlack = find(DRAWABLE, "yt_outline_fire_black_24") + YtOutlineNewSearchBlack = find(DRAWABLE, "yt_outline_new_search_black_24") YtOutlineSearchBlack = find(DRAWABLE, "yt_outline_search_black_24") }