feat(YouTube/Shorts components): add Hide paused header setting https://github.com/inotia00/ReVanced_Extended/issues/2213

This commit is contained in:
inotia00 2024-07-14 14:26:04 +09:00
parent b9018ad7eb
commit a7b6757701
4 changed files with 28 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsButtonFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPaidPromotionFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPausedHeaderFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotLegacyFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletParentFingerprint
@ -37,6 +38,7 @@ import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.getTargetIndexOrThrow
import app.revanced.util.getTargetIndexReversedOrThrow
import app.revanced.util.getTargetIndexWithReferenceOrThrow
import app.revanced.util.getWalkerMethod
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.literalInstructionHook
import app.revanced.util.patch.BaseBytecodePatch
@ -68,6 +70,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
fingerprints = setOf(
ShortsButtonFingerprint,
ShortsPaidPromotionFingerprint,
ShortsPausedHeaderFingerprint,
ShortsPivotLegacyFingerprint,
ShortsSubscriptionsTabletParentFingerprint,
TextComponentSpecFingerprint
@ -273,6 +276,26 @@ object ShortsComponentPatch : BaseBytecodePatch(
// endregion
// region patch for hide paused header
ShortsPausedHeaderFingerprint.resultOrThrow().let {
val targetMethod = it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
targetMethod.apply {
addInstructionsWithLabels(
0,
"""
invoke-static {}, $SHORTS_CLASS_DESCRIPTOR->hideShortsPausedHeader()Z
move-result v0
if-nez v0, :hide
""",
ExternalLabel("hide", getInstruction(implementation!!.instructions.lastIndex))
)
}
}
// endregion
// region patch for return shorts channel name
TextComponentSpecFingerprint.resultOrThrow().let {

View File

@ -3,7 +3,7 @@ package app.revanced.patches.youtube.shorts.components.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode
internal object ToolBarBannerFingerprint : MethodFingerprint(
internal object ShortsPausedHeaderFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
opcodes = listOf(
Opcode.IF_NEZ,

View File

@ -1037,6 +1037,9 @@ Side effect: Official headers in search results will be hidden."</string>
<string name="revanced_hide_shorts_subscribe_button_title">Hide Subscribe button</string>
<string name="revanced_hide_shorts_subscribe_button_summary_on">Subscribe button is hidden.</string>
<string name="revanced_hide_shorts_subscribe_button_summary_off">Subscribe button is shown.</string>
<string name="revanced_hide_shorts_paused_header_title">Hide paused header</string>
<string name="revanced_hide_shorts_paused_header_summary_on">Paused header is hidden.</string>
<string name="revanced_hide_shorts_paused_header_summary_off">Paused header is shown.</string>
<string name="revanced_hide_shorts_paused_overlay_buttons_title">Hide paused overlay buttons</string>
<string name="revanced_hide_shorts_paused_overlay_buttons_summary_on">Paused overlay buttons are hidden.</string>
<string name="revanced_hide_shorts_paused_overlay_buttons_summary_off">Paused overlay buttons are shown.</string>

View File

@ -461,6 +461,7 @@
<PreferenceScreen android:title="@string/revanced_preference_screen_shorts_player_title" android:key="revanced_preference_screen_shorts_player" android:summary="@string/revanced_preference_screen_shorts_player_summary">
<SwitchPreference android:title="@string/revanced_hide_shorts_join_button_title" android:key="revanced_hide_shorts_join_button" android:summaryOn="@string/revanced_hide_shorts_join_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_join_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_subscribe_button_title" android:key="revanced_hide_shorts_subscribe_button" android:summaryOn="@string/revanced_hide_shorts_subscribe_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_subscribe_button_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_paused_header_title" android:key="revanced_hide_shorts_paused_header" android:summaryOn="@string/revanced_hide_shorts_paused_header_summary_on" android:summaryOff="@string/revanced_hide_shorts_paused_header_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_paused_overlay_buttons_title" android:key="revanced_hide_shorts_paused_overlay_buttons" android:summaryOn="@string/revanced_hide_shorts_paused_overlay_buttons_summary_on" android:summaryOff="@string/revanced_hide_shorts_paused_overlay_buttons_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_paid_promotion_label_title" android:key="revanced_hide_shorts_paid_promotion_label" android:summaryOn="@string/revanced_hide_shorts_paid_promotion_label_summary_on" android:summaryOff="@string/revanced_hide_shorts_paid_promotion_label_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_shop_button_title" android:key="revanced_hide_shorts_shop_button" android:summaryOn="@string/revanced_hide_shorts_shop_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_shop_button_summary_off" />