diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt new file mode 100644 index 000000000..8f9a0e928 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/fingerprints/ShortsInfoPanelFingerprint.kt @@ -0,0 +1,16 @@ +package app.revanced.patches.youtube.layout.general.shortscomponent.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 ShortsInfoPanelFingerprint : MethodFingerprint( + returnType = "V", + customFingerprint = { methodDef -> + methodDef.implementation?.instructions?.any { + it.opcode.ordinal == Opcode.CONST.ordinal && + (it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId + } == true + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt index 4981082ee..c55834747 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsComponentPatch.kt @@ -28,6 +28,7 @@ import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus SettingsPatch::class, SharedResourceIdPatch::class, ShortsCommentButtonPatch::class, + ShortsInfoPanelPatch::class, ShortsRemixButtonPatch::class, ShortsSubscriptionsButtonPatch::class ] diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsInfoPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsInfoPanelPatch.kt new file mode 100644 index 000000000..318830d87 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/shortscomponent/patch/ShortsInfoPanelPatch.kt @@ -0,0 +1,46 @@ +package app.revanced.patches.youtube.layout.general.shortscomponent.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +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.patches.shared.annotation.YouTubeCompatibility +import app.revanced.patches.youtube.layout.general.shortscomponent.fingerprints.ShortsInfoPanelFingerprint +import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch +import app.revanced.util.integrations.Constants.GENERAL +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction +import org.jf.dexlib2.iface.instruction.WideLiteralInstruction + +@Name("hide-shorts-info-panel") +@DependsOn([SharedResourceIdPatch::class]) +@YouTubeCompatibility +@Version("0.0.1") +class ShortsInfoPanelPatch : BytecodePatch( + listOf(ShortsInfoPanelFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + ShortsInfoPanelFingerprint.result?.mutableMethod?.let { method -> + with (method.implementation!!.instructions) { + val insertIndex = this.indexOfFirst { + (it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId + } + 3 + + val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA + + method.addInstructions( + insertIndex + 1, """ + invoke-static {v$insertRegister}, $GENERAL->hideShortsPlayerInfoPanel(Landroid/view/ViewGroup;)Landroid/view/ViewGroup; + move-result-object v$insertRegister + """ + ) + } + } ?: return ShortsInfoPanelFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt index 9eafe90fd..b379a270a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/resourceid/patch/SharedResourceIdPatch.kt @@ -40,6 +40,7 @@ class SharedResourceIdPatch : ResourcePatch { var layoutVideo: Long = -1 var liveChatButtonId: Long = -1 var reelPlayerFooterLabelId: Long = -1 + var reelPlayerInfoPanelLabelId: Long = -1 var reelPlayerPausedLabelId: Long = -1 var reelRemixLabelId: Long = -1 var relatedChipCloudMarginLabelId: Long = -1 @@ -78,6 +79,7 @@ class SharedResourceIdPatch : ResourcePatch { layoutVideo = find(LAYOUT, "endscreen_element_layout_video") liveChatButtonId = find(ID, "live_chat_overlay_button") reelPlayerFooterLabelId = find(LAYOUT, "reel_player_dyn_footer_vert_stories3") + reelPlayerInfoPanelLabelId = find(ID, "reel_player_info_panel") reelPlayerPausedLabelId = find(ID, "reel_player_paused_state_buttons") reelRemixLabelId = find(ID, "reel_dyn_remix") relatedChipCloudMarginLabelId = find(LAYOUT, "related_chip_cloud_reduced_margins") diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 00ee4e276..de80ad956 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -437,6 +437,7 @@ Please do not report any issues you encounter while using this feature."Shorts player comments button is hidden Hide shorts player comments button Hide shorts player component + Hide shorts player info panels Shorts player join button is shown Shorts player join button is hidden Hide shorts player join button diff --git a/src/main/resources/youtube/settings/values-v21/strings.xml b/src/main/resources/youtube/settings/values-v21/strings.xml index 19b156266..bce056845 100644 --- a/src/main/resources/youtube/settings/values-v21/strings.xml +++ b/src/main/resources/youtube/settings/values-v21/strings.xml @@ -8,6 +8,8 @@ @string/settings_ie ReVanced Extended + @string/revanced_hide_info_panel_summary_off + @string/revanced_hide_info_panel_summary_on @string/camera_speed_button_label afn / blue