From f8b9d3b54e8e6fd3bb52703db4ffc4e0502fa189 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Thu, 2 May 2024 03:40:57 +0900 Subject: [PATCH] feat(YouTube/Description components): `Expand video description` setting clicks chapter --- .../DescriptionComponentsPatch.kt | 31 ++++++++++--------- .../EngagementPanelSubHeaderFingerprint.kt | 13 -------- .../EngagementPanelTitleFingerprint.kt | 8 +++++ .../EngagementPanelTitleParentFingerprint.kt | 7 +++++ .../utils/resourceid/SharedResourceIdPatch.kt | 2 -- 5 files changed, 32 insertions(+), 29 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelSubHeaderFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleParentFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/DescriptionComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/DescriptionComponentsPatch.kt index d10be454d..ffb764cfb 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/DescriptionComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/DescriptionComponentsPatch.kt @@ -5,17 +5,18 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patches.shared.litho.LithoFilterPatch -import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelSubHeaderFingerprint +import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelTitleFingerprint +import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelTitleParentFingerprint import app.revanced.patches.youtube.player.descriptions.fingerprints.TextViewComponentFingerprint import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR -import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch -import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch -import app.revanced.util.getTargetIndexReversed +import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndexWithMethodReferenceName +import app.revanced.util.getWalkerMethod +import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.Opcode @@ -29,13 +30,11 @@ object DescriptionComponentsPatch : BaseBytecodePatch( dependencies = setOf( BottomSheetRecyclerViewPatch::class, LithoFilterPatch::class, - PlayerTypeHookPatch::class, - SettingsPatch::class, - SharedResourceIdPatch::class + SettingsPatch::class ), compatiblePackages = COMPATIBLE_PACKAGE, fingerprints = setOf( - EngagementPanelSubHeaderFingerprint, + EngagementPanelTitleParentFingerprint, TextViewComponentFingerprint ) ) { @@ -60,14 +59,18 @@ object DescriptionComponentsPatch : BaseBytecodePatch( } } - EngagementPanelSubHeaderFingerprint.resultOrThrow().mutableMethod.apply { - val instructionIndex = getTargetIndexReversed(Opcode.INVOKE_INTERFACE) + 1 - val viewRegister = getInstruction(instructionIndex).registerA + EngagementPanelTitleFingerprint.resolve( + context, + EngagementPanelTitleParentFingerprint.resultOrThrow().classDef + ) + EngagementPanelTitleFingerprint.resultOrThrow().mutableMethod.apply { + val contentDescriptionIndex = getTargetIndexWithMethodReferenceName("setContentDescription") + val contentDescriptionRegister = getInstruction(contentDescriptionIndex).registerD addInstruction( - instructionIndex + 1, - "invoke-static { v$viewRegister }, " + - "$PLAYER_CLASS_DESCRIPTOR->engagementPanelSubHeaderViewLoaded(Landroid/view/View;)V", + contentDescriptionIndex, + "invoke-static {v$contentDescriptionRegister}," + + "$PLAYER_CLASS_DESCRIPTOR->setContentDescription(Ljava/lang/String;)V" ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelSubHeaderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelSubHeaderFingerprint.kt deleted file mode 100644 index dacc0b053..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelSubHeaderFingerprint.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.revanced.patches.youtube.player.descriptions.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.PanelSubHeader -import app.revanced.util.fingerprint.LiteralValueFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -internal object EngagementPanelSubHeaderFingerprint : LiteralValueFingerprint( - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - returnType = "V", - parameters = listOf("Landroid/view/ViewGroup;", "L"), - literalSupplier = { PanelSubHeader } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleFingerprint.kt new file mode 100644 index 000000000..723f7803e --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleFingerprint.kt @@ -0,0 +1,8 @@ +package app.revanced.patches.youtube.player.descriptions.fingerprints + +import app.revanced.util.fingerprint.MethodReferenceNameFingerprint + +internal object EngagementPanelTitleFingerprint : MethodReferenceNameFingerprint( + strings = listOf(". "), + reference = { "setContentDescription" } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleParentFingerprint.kt new file mode 100644 index 000000000..16a8aca2f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/player/descriptions/fingerprints/EngagementPanelTitleParentFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.youtube.player.descriptions.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object EngagementPanelTitleParentFingerprint : MethodFingerprint( + strings = listOf("[EngagementPanelTitleHeader] Cannot remove action buttons from header as the child count is out of sync. Buttons to remove exceed current header child count.") +) \ 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 afc9e9b15..1b93ab185 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 @@ -67,7 +67,6 @@ object SharedResourceIdPatch : ResourcePatch() { var ModernMiniPlayerRewindButton = -1L var MusicAppDeeplinkButtonView = -1L var NotificationBigPictureIconWidth = -1L - var PanelSubHeader = -1L var PlayerCollapseButton = -1L var PosterArtWidthDefault = -1L var QualityAuto = -1L @@ -155,7 +154,6 @@ object SharedResourceIdPatch : ResourcePatch() { ModernMiniPlayerRewindButton = getId(ID, "modern_miniplayer_rewind_button") MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view") NotificationBigPictureIconWidth = getId(DIMEN, "notification_big_picture_icon_width") - PanelSubHeader = getId(ID, "panel_subheader") PlayerCollapseButton = getId(ID, "player_collapse_button") PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default") QualityAuto = getId(STRING, "quality_auto")