feat(YouTube): Merge multiple layout patches into Hide Layout Components (#3799)

This commit is contained in:
LisoUseInAIKyrios 2024-10-22 18:29:23 -04:00 committed by GitHub
parent 77568428a7
commit bbcb57a32d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 289 additions and 499 deletions

View File

@ -1,56 +1,13 @@
package app.revanced.patches.youtube.layout.hide.albumcards
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.hide.albumcards.fingerprints.AlbumCardsFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch
@Patch(
name = "Hide album cards",
description = "Adds an option to hide album cards below artist descriptions.",
dependencies = [
IntegrationsPatch::class,
AlbumCardsResourcePatch::class
],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.38.44",
"18.49.37",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Deprecated("This patch has been merged to HideLayoutComponentsPatch.")
@Suppress("unused")
object AlbumCardsPatch : BytecodePatch(
setOf(AlbumCardsFingerprint)
dependencies = setOf(HideLayoutComponentsPatch::class),
) {
override fun execute(context: BytecodeContext) {
AlbumCardsFingerprint.result?.let {
it.mutableMethod.apply {
val checkCastAnchorIndex = it.scanResult.patternScanResult!!.endIndex
val insertIndex = checkCastAnchorIndex + 1
val albumCardViewRegister = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
addInstruction(
insertIndex,
"invoke-static {v$albumCardViewRegister}, " +
"Lapp/revanced/integrations/youtube/patches/HideAlbumCardsPatch;" +
"->" +
"hideAlbumCard(Landroid/view/View;)V"
)
}
} ?: throw AlbumCardsFingerprint.exception
}
override fun execute(context: BytecodeContext) { }
}

View File

@ -1,30 +0,0 @@
package app.revanced.patches.youtube.layout.hide.albumcards
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(
dependencies = [
SettingsPatch::class,
ResourceMappingPatch::class,
AddResourcesPatch::class,
],
)
internal object AlbumCardsResourcePatch : ResourcePatch() {
internal var albumCardId: Long = -1
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.FEED.addPreferences(
SwitchPreference("revanced_hide_album_cards"),
)
albumCardId = ResourceMappingPatch["layout", "album_card"]
}
}

View File

@ -2,58 +2,12 @@ package app.revanced.patches.youtube.layout.hide.comments
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch
@Patch(
name = "Comments",
description = "Adds options to hide components related to comments.",
dependencies = [
SettingsPatch::class,
LithoFilterPatch::class,
AddResourcesPatch::class
],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.38.44",
"18.49.37",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Deprecated("This patch has been merged to HideLayoutComponentsPatch.")
@Suppress("unused")
object CommentsPatch : ResourcePatch() {
private const val FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/components/CommentsFilter;"
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.PLAYER.addPreferences(
PreferenceScreen(
"revanced_comments_screen",
preferences = setOf(
SwitchPreference("revanced_hide_comments_by_members_header"),
SwitchPreference("revanced_hide_comments_section"),
SwitchPreference("revanced_hide_comments_create_a_short_button"),
SwitchPreference("revanced_hide_comments_preview_comment"),
SwitchPreference("revanced_hide_comments_thanks_button"),
SwitchPreference("revanced_hide_comments_timestamp_and_emoji_buttons")
),
sorting = PreferenceScreen.Sorting.UNSORTED
)
)
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
}
object CommentsPatch : ResourcePatch(
dependencies = setOf(HideLayoutComponentsPatch::class),
) {
override fun execute(context: ResourceContext) { }
}

View File

@ -1,51 +1,13 @@
package app.revanced.patches.youtube.layout.hide.crowdfundingbox
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch
@Patch(
name = "Hide crowdfunding box",
description = "Adds an option to hide the crowdfunding box between the player and video description.",
dependencies = [
IntegrationsPatch::class,
CrowdfundingBoxResourcePatch::class
],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.38.44",
"18.49.37",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Deprecated("This patch has been merged to HideLayoutComponentsPatch.")
@Suppress("unused")
object CrowdfundingBoxPatch : BytecodePatch(
setOf(CrowdfundingBoxFingerprint)
dependencies = setOf(HideLayoutComponentsPatch::class),
) {
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/HideCrowdfundingBoxPatch;->hideCrowdfundingBox(Landroid/view/View;)V"
override fun execute(context: BytecodeContext) {
CrowdfundingBoxFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addInstruction(insertIndex, "invoke-static {v$objectRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR")
}
} ?: throw CrowdfundingBoxFingerprint.exception
}
override fun execute(context: BytecodeContext) { }
}

View File

@ -1,33 +0,0 @@
package app.revanced.patches.youtube.layout.hide.crowdfundingbox
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(
dependencies = [
SettingsPatch::class,
ResourceMappingPatch::class,
AddResourcesPatch::class,
],
)
internal object CrowdfundingBoxResourcePatch : ResourcePatch() {
internal var crowdfundingBoxId: Long = -1
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.FEED.addPreferences(
SwitchPreference("revanced_hide_crowdfunding_box"),
)
crowdfundingBoxId = ResourceMappingPatch[
"layout",
"donation_companion",
]
}
}

View File

@ -1,90 +1,12 @@
package app.revanced.patches.youtube.layout.hide.filterbar
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.hide.filterbar.fingerprints.FilterBarHeightFingerprint
import app.revanced.patches.youtube.layout.hide.filterbar.fingerprints.RelatedChipCloudFingerprint
import app.revanced.patches.youtube.layout.hide.filterbar.fingerprints.SearchResultsChipBarFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch
@Patch(
name = "Hide filter bar",
description = "Adds options to hide the category bar at the top of video feeds.",
dependencies = [HideFilterBarResourcePatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.38.44",
"18.49.37",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Suppress("unused")
@Deprecated("This patch class has been merged into HideLayoutComponentsPatch.")
object HideFilterBarPatch : BytecodePatch(
setOf(
RelatedChipCloudFingerprint,
SearchResultsChipBarFingerprint,
FilterBarHeightFingerprint
)
dependencies = setOf(HideLayoutComponentsPatch::class)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/HideFilterBarPatch;"
override fun execute(context: BytecodeContext) {
FilterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
"""
invoke-static { v$register }, $INTEGRATIONS_CLASS_DESCRIPTOR->hideInFeed(I)I
move-result v$register
"""
}
RelatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
"invoke-static { v$register }, " +
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideInRelatedVideos(Landroid/view/View;)V"
}
SearchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
"""
invoke-static { v$register }, $INTEGRATIONS_CLASS_DESCRIPTOR->hideInSearch(I)I
move-result v$register
"""
}
}
/**
* Patch a [MethodFingerprint] with a given [instructions].
*
* @param RegisterInstruction The type of instruction to get the register from.
* @param insertIndexOffset The offset to add to the end index of the [MethodFingerprint].
* @param hookRegisterOffset The offset to add to the register of the hook.
* @param instructions The instructions to add with the register as a parameter.
*/
private fun <RegisterInstruction : OneRegisterInstruction> MethodFingerprint.patch(
insertIndexOffset: Int = 0,
hookRegisterOffset: Int = 0,
instructions: (Int) -> String
) =
result?.let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val insertIndex = endIndex + insertIndexOffset
val register =
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
addInstructions(insertIndex, instructions(register))
}
} ?: throw exception
override fun execute(context: BytecodeContext) {}
}

View File

@ -1,36 +0,0 @@
package app.revanced.patches.youtube.layout.hide.filterbar
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(dependencies = [SettingsPatch::class, ResourceMappingPatch::class, AddResourcesPatch::class])
internal object HideFilterBarResourcePatch : ResourcePatch() {
internal var filterBarHeightId = -1L
internal var relatedChipCloudMarginId = -1L
internal var barContainerHeightId = -1L
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.FEED.addPreferences(
PreferenceScreen(
key = "revanced_hide_filter_bar_screen",
preferences = setOf(
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
),
),
)
relatedChipCloudMarginId = ResourceMappingPatch["layout", "related_chip_cloud_reduced_margins"]
filterBarHeightId = ResourceMappingPatch["dimen", "filter_bar_height"]
barContainerHeightId = ResourceMappingPatch["dimen", "bar_container_height"]
}
}

View File

@ -1,54 +1,13 @@
package app.revanced.patches.youtube.layout.hide.floatingmicrophone
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.hide.floatingmicrophone.fingerprints.ShowFloatingMicrophoneButtonFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch
@Patch(
name = "Hide floating microphone button",
description = "Adds an option to hide the floating microphone button when searching.",
dependencies = [HideFloatingMicrophoneButtonResourcePatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.38.44",
"18.49.37",
"19.16.39",
"19.25.37",
"19.34.42",
]
)
]
)
@Deprecated("This patch has been merged to HideLayoutComponentsPatch.")
@Suppress("unused")
object HideFloatingMicrophoneButtonPatch : BytecodePatch(
setOf(ShowFloatingMicrophoneButtonFingerprint)
dependencies = setOf(HideLayoutComponentsPatch::class),
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/HideFloatingMicrophoneButtonPatch;"
override fun execute(context: BytecodeContext) {
ShowFloatingMicrophoneButtonFingerprint.result?.let { result ->
with(result.mutableMethod) {
val insertIndex = result.scanResult.patternScanResult!!.startIndex + 1
val showButtonRegister =
getInstruction<TwoRegisterInstruction>(insertIndex - 1).registerA
addInstructions(
insertIndex,
"""
invoke-static {v$showButtonRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->hideFloatingMicrophoneButton(Z)Z
move-result v$showButtonRegister
"""
)
}
} ?: throw ShowFloatingMicrophoneButtonFingerprint.exception
}
override fun execute(context: BytecodeContext) { }
}

View File

@ -1,30 +0,0 @@
package app.revanced.patches.youtube.layout.hide.floatingmicrophone
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(
dependencies = [
SettingsPatch::class,
ResourceMappingPatch::class,
AddResourcesPatch::class,
],
)
internal object HideFloatingMicrophoneButtonResourcePatch : ResourcePatch() {
internal var fabButtonId: Long = -1
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences(
SwitchPreference("revanced_hide_floating_microphone_button"),
)
fabButtonId = ResourceMappingPatch["id", "fab"]
}
}

View File

@ -7,6 +7,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
@ -14,17 +15,23 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.*
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen.Sorting
import app.revanced.patches.youtube.layout.hide.general.fingerprints.AlbumCardsFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.CrowdfundingBoxFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.FilterBarHeightFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.HideShowMoreButtonFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ParseElementFromBufferFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.PlayerOverlayFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.RelatedChipCloudFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.SearchResultsChipBarFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowFloatingMicrophoneButtonFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ShowWatermarkFingerprint
import app.revanced.patches.youtube.layout.hide.general.fingerprints.YoodlesImageViewFingerprint
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.alsoResolve
import app.revanced.util.findOpcodeIndicesReversed
import app.revanced.util.getReference
import app.revanced.util.alsoResolve
import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@ -61,13 +68,21 @@ object HideLayoutComponentsPatch : BytecodePatch(
ParseElementFromBufferFingerprint,
PlayerOverlayFingerprint,
HideShowMoreButtonFingerprint,
AlbumCardsFingerprint,
CrowdfundingBoxFingerprint,
YoodlesImageViewFingerprint,
RelatedChipCloudFingerprint,
SearchResultsChipBarFingerprint,
ShowFloatingMicrophoneButtonFingerprint,
FilterBarHeightFingerprint
),
) {
private const val LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/components/LayoutComponentsFilter;"
private const val DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME =
"Lapp/revanced/integrations/youtube/patches/components/DescriptionComponentsFilter;"
private const val COMMENTS_FILTER_CLASS_NAME =
"Lapp/revanced/integrations/youtube/patches/components/CommentsFilter;"
private const val CUSTOM_FILTER_CLASS_NAME =
"Lapp/revanced/integrations/youtube/patches/components/CustomFilter;"
private const val KEYWORD_FILTER_CLASS_NAME =
@ -77,11 +92,6 @@ object HideLayoutComponentsPatch : BytecodePatch(
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.PLAYER.addPreferences(
SwitchPreference("revanced_hide_channel_bar"),
SwitchPreference("revanced_hide_channel_guidelines"),
SwitchPreference("revanced_hide_channel_member_shelf"),
SwitchPreference("revanced_hide_channel_watermark"),
SwitchPreference("revanced_hide_community_guidelines"),
PreferenceScreen(
key = "revanced_hide_description_components_screen",
preferences = setOf(
@ -93,6 +103,23 @@ object HideLayoutComponentsPatch : BytecodePatch(
SwitchPreference("revanced_hide_transcript_section"),
),
),
PreferenceScreen(
"revanced_comments_screen",
preferences = setOf(
SwitchPreference("revanced_hide_comments_by_members_header"),
SwitchPreference("revanced_hide_comments_section"),
SwitchPreference("revanced_hide_comments_create_a_short_button"),
SwitchPreference("revanced_hide_comments_preview_comment"),
SwitchPreference("revanced_hide_comments_thanks_button"),
SwitchPreference("revanced_hide_comments_timestamp_and_emoji_buttons")
),
sorting = PreferenceScreen.Sorting.UNSORTED
),
SwitchPreference("revanced_hide_channel_bar"),
SwitchPreference("revanced_hide_channel_guidelines"),
SwitchPreference("revanced_hide_channel_member_shelf"),
SwitchPreference("revanced_hide_channel_watermark"),
SwitchPreference("revanced_hide_community_guidelines"),
SwitchPreference("revanced_hide_emergency_box"),
SwitchPreference("revanced_hide_info_panels"),
SwitchPreference("revanced_hide_join_membership_button"),
@ -105,24 +132,6 @@ object HideLayoutComponentsPatch : BytecodePatch(
)
SettingsPatch.PreferenceScreen.FEED.addPreferences(
SwitchPreference("revanced_hide_artist_cards"),
SwitchPreference("revanced_hide_community_posts"),
SwitchPreference("revanced_hide_compact_banner"),
SwitchPreference("revanced_hide_chips_shelf"),
SwitchPreference("revanced_hide_expandable_chip"),
SwitchPreference("revanced_hide_feed_survey"),
SwitchPreference("revanced_hide_for_you_shelf"),
SwitchPreference("revanced_hide_horizontal_shelves"),
SwitchPreference("revanced_hide_image_shelf"),
SwitchPreference("revanced_hide_latest_posts_ads"),
SwitchPreference("revanced_hide_mix_playlists"),
SwitchPreference("revanced_hide_movies_section"),
SwitchPreference("revanced_hide_notify_me_button"),
SwitchPreference("revanced_hide_playables"),
SwitchPreference("revanced_hide_search_result_recommendations"),
SwitchPreference("revanced_hide_search_result_shelf_header"),
SwitchPreference("revanced_hide_show_more_button"),
SwitchPreference("revanced_hide_doodles"),
PreferenceScreen(
key = "revanced_hide_keyword_content_screen",
sorting = Sorting.UNSORTED,
@ -135,7 +144,36 @@ object HideLayoutComponentsPatch : BytecodePatch(
NonInteractivePreference(key = "revanced_hide_keyword_content_about_whole_words",
tag = "app.revanced.integrations.youtube.settings.preference.HtmlPreference")
)
)
),
PreferenceScreen(
key = "revanced_hide_filter_bar_screen",
preferences = setOf(
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
),
),
SwitchPreference("revanced_hide_album_cards"),
SwitchPreference("revanced_hide_artist_cards"),
SwitchPreference("revanced_hide_community_posts"),
SwitchPreference("revanced_hide_compact_banner"),
SwitchPreference("revanced_hide_crowdfunding_box"),
SwitchPreference("revanced_hide_chips_shelf"),
SwitchPreference("revanced_hide_expandable_chip"),
SwitchPreference("revanced_hide_feed_survey"),
SwitchPreference("revanced_hide_floating_microphone_button"),
SwitchPreference("revanced_hide_for_you_shelf"),
SwitchPreference("revanced_hide_horizontal_shelves"),
SwitchPreference("revanced_hide_image_shelf"),
SwitchPreference("revanced_hide_latest_posts_ads"),
SwitchPreference("revanced_hide_mix_playlists"),
SwitchPreference("revanced_hide_movies_section"),
SwitchPreference("revanced_hide_notify_me_button"),
SwitchPreference("revanced_hide_playables"),
SwitchPreference("revanced_hide_search_result_recommendations"),
SwitchPreference("revanced_hide_search_result_shelf_header"),
SwitchPreference("revanced_hide_show_more_button"),
SwitchPreference("revanced_hide_doodles"),
)
SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences(
@ -153,6 +191,7 @@ object HideLayoutComponentsPatch : BytecodePatch(
LithoFilterPatch.addFilter(LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
LithoFilterPatch.addFilter(DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME)
LithoFilterPatch.addFilter(COMMENTS_FILTER_CLASS_NAME)
LithoFilterPatch.addFilter(KEYWORD_FILTER_CLASS_NAME)
LithoFilterPatch.addFilter(CUSTOM_FILTER_CLASS_NAME)
@ -213,8 +252,60 @@ object HideLayoutComponentsPatch : BytecodePatch(
val insertIndex = moveRegisterIndex + 1
addInstruction(
insertIndex,
"invoke-static { v$viewRegister }, " +
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V",
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
"->hideShowMoreButton(Landroid/view/View;)V",
)
}
}
// endregion
// region crowd funding box
CrowdfundingBoxFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,
"invoke-static {v$objectRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
"->hideCrowdfundingBox(Landroid/view/View;)V")
}
}
// endregion
// region hide album cards
AlbumCardsFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val checkCastAnchorIndex = it.scanResult.patternScanResult!!.endIndex
val insertIndex = checkCastAnchorIndex + 1
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
addInstruction(
insertIndex,
"invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
"->hideAlbumCard(Landroid/view/View;)V"
)
}
}
// endregion
// region hide floating microphone
ShowFloatingMicrophoneButtonFingerprint.resultOrThrow().let { result ->
with(result.mutableMethod) {
val startIndex = result.scanResult.patternScanResult!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(startIndex).registerA
addInstructions(
startIndex + 1,
"""
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideFloatingMicrophoneButton(Z)Z
move-result v$register
"""
)
}
}
@ -243,5 +334,50 @@ object HideLayoutComponentsPatch : BytecodePatch(
}
// endregion
// region hide filter bar
FilterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
"""
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInFeed(I)I
move-result v$register
"""
}
SearchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
"""
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInSearch(I)I
move-result v$register
"""
}
RelatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
"invoke-static { v$register }, " +
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInRelatedVideos(Landroid/view/View;)V"
}
}
/**
* Patch a [MethodFingerprint] with a given [instructions].
*
* @param RegisterInstruction The type of instruction to get the register from.
* @param insertIndexOffset The offset to add to the end index of the [MethodFingerprint].
* @param hookRegisterOffset The offset to add to the register of the hook.
* @param instructions The instructions to add with the register as a parameter.
*/
private fun <RegisterInstruction : OneRegisterInstruction> MethodFingerprint.patch(
insertIndexOffset: Int = 0,
hookRegisterOffset: Int = 0,
instructions: (Int) -> String
) = resultOrThrow().let {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val insertIndex = endIndex + insertIndexOffset
val register =
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
addInstructions(insertIndex, instructions(register))
}
}
}

View File

@ -15,19 +15,56 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
],
)
internal object HideLayoutComponentsResourcePatch : ResourcePatch() {
internal var expandButtonDownId: Long = -1
var expandButtonDownId: Long = -1
var albumCardId: Long = -1
var crowdfundingBoxId: Long = -1
var youTubeLogo = -1L
var filterBarHeightId = -1L
var relatedChipCloudMarginId = -1L
var barContainerHeightId = -1L
var fabButtonId: Long = -1
override fun execute(context: ResourceContext) {
expandButtonDownId = ResourceMappingPatch[
"layout",
"expand_button_down",
]
albumCardId = ResourceMappingPatch[
"layout",
"album_card"
]
crowdfundingBoxId = ResourceMappingPatch[
"layout",
"donation_companion",
]
youTubeLogo = ResourceMappingPatch[
"id",
"youtube_logo"
]
relatedChipCloudMarginId = ResourceMappingPatch[
"layout",
"related_chip_cloud_reduced_margins"
]
filterBarHeightId = ResourceMappingPatch[
"dimen",
"filter_bar_height"
]
barContainerHeightId = ResourceMappingPatch[
"dimen",
"bar_container_height"
]
fabButtonId = ResourceMappingPatch[
"id",
"fab"
]
}
}

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.albumcards.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.albumcards.AlbumCardsResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -16,5 +16,5 @@ internal object AlbumCardsFingerprint : LiteralValueFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
),
literalSupplier = { AlbumCardsResourcePatch.albumCardId }
literalSupplier = { HideLayoutComponentsResourcePatch.albumCardId }
)

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.crowdfundingbox.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.crowdfundingbox.CrowdfundingBoxResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -13,5 +13,5 @@ internal object CrowdfundingBoxFingerprint : LiteralValueFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT,
),
literalSupplier = { CrowdfundingBoxResourcePatch.crowdfundingBoxId }
literalSupplier = { HideLayoutComponentsResourcePatch.crowdfundingBoxId }
)

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.filterbar.HideFilterBarResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -15,5 +15,5 @@ internal object FilterBarHeightFingerprint : LiteralValueFingerprint(
Opcode.MOVE_RESULT,
Opcode.IPUT
),
literalSupplier = { HideFilterBarResourcePatch.filterBarHeightId }
literalSupplier = { HideLayoutComponentsResourcePatch.filterBarHeightId }
)

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.filterbar.HideFilterBarResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -14,5 +14,5 @@ internal object RelatedChipCloudFingerprint : LiteralValueFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
literalSupplier = { HideFilterBarResourcePatch.relatedChipCloudMarginId }
literalSupplier = { HideLayoutComponentsResourcePatch.relatedChipCloudMarginId }
)

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.filterbar.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.filterbar.HideFilterBarResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -16,5 +16,5 @@ internal object SearchResultsChipBarFingerprint : LiteralValueFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
literalSupplier = { HideFilterBarResourcePatch.barContainerHeightId }
literalSupplier = { HideLayoutComponentsResourcePatch.barContainerHeightId }
)

View File

@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.floatingmicrophone.fingerprints
package app.revanced.patches.youtube.layout.hide.general.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.floatingmicrophone.HideFloatingMicrophoneButtonResourcePatch
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -15,5 +15,5 @@ internal object ShowFloatingMicrophoneButtonFingerprint : LiteralValueFingerprin
Opcode.IF_EQZ,
Opcode.RETURN_VOID
),
literalSupplier = { HideFloatingMicrophoneButtonResourcePatch.fabButtonId }
literalSupplier = { HideLayoutComponentsResourcePatch.fabButtonId }
)

View File

@ -107,6 +107,15 @@ This is because Crowdin requires temporarily flattening this file and removing t
<string name="revanced_disable_like_subscribe_glow_title">Disable like / subscribe button glow</string>
<string name="revanced_disable_like_subscribe_glow_summary_on">Like and subscribe button will not glow when mentioned</string>
<string name="revanced_disable_like_subscribe_glow_summary_off">Like and subscribe button will glow when mentioned</string>
<string name="revanced_hide_album_cards_title">Hide album cards</string>
<string name="revanced_hide_album_cards_summary_on">Album cards are hidden</string>
<string name="revanced_hide_album_cards_summary_off">Album cards are shown</string>
<string name="revanced_hide_crowdfunding_box_title">Hide crowdfunding box</string>
<string name="revanced_hide_crowdfunding_box_summary_on">Crowdfunding box is hidden</string>
<string name="revanced_hide_crowdfunding_box_summary_off">Crowdfunding box is shown</string>
<string name="revanced_hide_floating_microphone_button_title">Hide floating microphone button</string>
<string name="revanced_hide_floating_microphone_button_summary_on">Microphone button hidden</string>
<string name="revanced_hide_floating_microphone_button_summary_off">Microphone button shown</string>
<string name="revanced_hide_gray_separator_title">Hide gray separator</string>
<string name="revanced_hide_gray_separator_summary_on">Gray separators are hidden</string>
<string name="revanced_hide_gray_separator_summary_off">Gray separators are shown</string>
@ -232,6 +241,39 @@ This is because Crowdin requires temporarily flattening this file and removing t
<string name="revanced_hide_description_components_screen_title">Video description</string>
<string name="revanced_hide_description_components_screen_summary">Hide or show video description components</string>
<string name="revanced_hide_filter_bar_screen_title">Filter bar</string>
<string name="revanced_hide_filter_bar_screen_summary">Hide or show the filter bar in the feed, search, and related videos</string>
<string name="revanced_hide_filter_bar_feed_in_feed_title">Hide in feed</string>
<string name="revanced_hide_filter_bar_feed_in_feed_summary_on">Hidden in feed</string>
<string name="revanced_hide_filter_bar_feed_in_feed_summary_off">Shown in feed</string>
<string name="revanced_hide_filter_bar_feed_in_search_title">Hide in search</string>
<string name="revanced_hide_filter_bar_feed_in_search_summary_on">Hidden in search</string>
<string name="revanced_hide_filter_bar_feed_in_search_summary_off">Shown in search</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_title">Hide in related videos</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_summary_on">Hidden in related videos</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_summary_off">Shown in related videos</string>
<string name="revanced_comments_screen_title">Comments</string>
<string name="revanced_comments_screen_summary">Hide or show comments section components</string>
<string name="revanced_hide_comments_by_members_header_title">Hide \'Comments by members\' header</string>
<string name="revanced_hide_comments_by_members_header_summary_on">\'Comments by members\' header is hidden</string>
<string name="revanced_hide_comments_by_members_header_summary_off">\'Comments by members\' header is shown</string>
<string name="revanced_hide_comments_section_title">Hide comments section</string>
<string name="revanced_hide_comments_section_summary_on">Comments section is hidden</string>
<string name="revanced_hide_comments_section_summary_off">Comments section is shown</string>
<string name="revanced_hide_comments_create_a_short_button_title">Hide \'Create a Short\' button</string>
<string name="revanced_hide_comments_create_a_short_button_summary_on">\'Create a Short\' button is hidden</string>
<string name="revanced_hide_comments_create_a_short_button_summary_off">\'Create a Short\' button is shown</string>
<string name="revanced_hide_comments_preview_comment_title">Hide preview comment</string>
<string name="revanced_hide_comments_preview_comment_summary_on">Preview comment is hidden</string>
<string name="revanced_hide_comments_preview_comment_summary_off">Preview comment is shown</string>
<string name="revanced_hide_comments_thanks_button_title">Hide thanks button</string>
<string name="revanced_hide_comments_thanks_button_summary_on">Thanks button is hidden</string>
<string name="revanced_hide_comments_thanks_button_summary_off">Thanks button is shown</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_title">Hide timestamp and emoji buttons</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_summary_on">Timestamp and emoji buttons are hidden</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_summary_off">Timestamp and emoji buttons are shown</string>
<!-- https://logos.fandom.com/wiki/YouTube/Yoodles -->
<string name="revanced_hide_doodles_title">Hide YouTube Doodles</string>
<string name="revanced_hide_doodles_summary_on">Search bar Doodles are hidden</string>
@ -523,61 +565,11 @@ This is because Crowdin requires temporarily flattening this file and removing t
<string name="revanced_hide_player_buttons_summary_on">Buttons are hidden</string>
<string name="revanced_hide_player_buttons_summary_off">Buttons are shown</string>
</patch>
<patch id="layout.hide.albumcards.AlbumCardsResourcePatch">
<string name="revanced_hide_album_cards_title">Hide album cards</string>
<string name="revanced_hide_album_cards_summary_on">Album cards are hidden</string>
<string name="revanced_hide_album_cards_summary_off">Album cards are shown</string>
</patch>
<patch id="layout.hide.comments.CommentsPatch">
<string name="revanced_comments_screen_title">Comments</string>
<string name="revanced_comments_screen_summary">Hide or show comments section components</string>
<string name="revanced_hide_comments_by_members_header_title">Hide \'Comments by members\' header</string>
<string name="revanced_hide_comments_by_members_header_summary_on">\'Comments by members\' header is hidden</string>
<string name="revanced_hide_comments_by_members_header_summary_off">\'Comments by members\' header is shown</string>
<string name="revanced_hide_comments_section_title">Hide comments section</string>
<string name="revanced_hide_comments_section_summary_on">Comments section is hidden</string>
<string name="revanced_hide_comments_section_summary_off">Comments section is shown</string>
<string name="revanced_hide_comments_create_a_short_button_title">Hide \'Create a Short\' button</string>
<string name="revanced_hide_comments_create_a_short_button_summary_on">\'Create a Short\' button is hidden</string>
<string name="revanced_hide_comments_create_a_short_button_summary_off">\'Create a Short\' button is shown</string>
<string name="revanced_hide_comments_preview_comment_title">Hide preview comment</string>
<string name="revanced_hide_comments_preview_comment_summary_on">Preview comment is hidden</string>
<string name="revanced_hide_comments_preview_comment_summary_off">Preview comment is shown</string>
<string name="revanced_hide_comments_thanks_button_title">Hide thanks button</string>
<string name="revanced_hide_comments_thanks_button_summary_on">Thanks button is hidden</string>
<string name="revanced_hide_comments_thanks_button_summary_off">Thanks button is shown</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_title">Hide timestamp and emoji buttons</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_summary_on">Timestamp and emoji buttons are hidden</string>
<string name="revanced_hide_comments_timestamp_and_emoji_buttons_summary_off">Timestamp and emoji buttons are shown</string>
</patch>
<patch id="layout.hide.crowdfundingbox.CrowdfundingBoxResourcePatch">
<string name="revanced_hide_crowdfunding_box_title">Hide crowdfunding box</string>
<string name="revanced_hide_crowdfunding_box_summary_on">Crowdfunding box is hidden</string>
<string name="revanced_hide_crowdfunding_box_summary_off">Crowdfunding box is shown</string>
</patch>
<patch id="layout.hide.endscreencards.HideEndscreenCardsResourcePatch">
<string name="revanced_hide_endscreen_cards_title">Hide end screen cards</string>
<string name="revanced_hide_endscreen_cards_summary_on">End screen cards are hidden</string>
<string name="revanced_hide_endscreen_cards_summary_off">End screen cards are shown</string>
</patch>
<patch id="layout.hide.filterbar.HideFilterBarResourcePatch">
<string name="revanced_hide_filter_bar_screen_title">Filter bar</string>
<string name="revanced_hide_filter_bar_screen_summary">Hide or show the filter bar in the feed, search, and related videos</string>
<string name="revanced_hide_filter_bar_feed_in_feed_title">Hide in feed</string>
<string name="revanced_hide_filter_bar_feed_in_feed_summary_on">Hidden in feed</string>
<string name="revanced_hide_filter_bar_feed_in_feed_summary_off">Shown in feed</string>
<string name="revanced_hide_filter_bar_feed_in_search_title">Hide in search</string>
<string name="revanced_hide_filter_bar_feed_in_search_summary_on">Hidden in search</string>
<string name="revanced_hide_filter_bar_feed_in_search_summary_off">Shown in search</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_title">Hide in related videos</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_summary_on">Hidden in related videos</string>
<string name="revanced_hide_filter_bar_feed_in_related_videos_summary_off">Shown in related videos</string>
</patch>
<patch id="layout.hide.floatingmicrophone.HideFloatingMicrophoneButtonResourcePatch">
<string name="revanced_hide_floating_microphone_button_title">Hide floating microphone button</string>
<string name="revanced_hide_floating_microphone_button_summary_on">Microphone button hidden</string>
<string name="revanced_hide_floating_microphone_button_summary_off">Microphone button shown</string>
</patch>
<patch id="layout.hide.fullscreenambientmode.DisableFullscreenAmbientModePatch">
<string name="revanced_disable_fullscreen_ambient_mode_title">Disable ambient mode in fullscreen</string>
<string name="revanced_disable_fullscreen_ambient_mode_summary_on">Ambient mode disabled</string>