feat(YouTube/Shorts components): add Return shorts channel name settings

This commit is contained in:
inotia00 2024-05-01 00:14:34 +09:00
parent 06358a58e8
commit a9b24ae626
6 changed files with 52 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsPivotLe
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletFingerprint
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletParentFingerprint import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsSubscriptionsTabletParentFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.fingerprints.TextComponentSpecFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
@ -30,12 +31,15 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelRightLikeIcon import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelRightLikeIcon
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.RightComment import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.RightComment
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.patches.youtube.video.information.VideoInformationPatch
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed
import app.revanced.util.getTargetIndexWithReference
import app.revanced.util.getWideLiteralInstructionIndex import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@ -43,15 +47,16 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused") @Suppress("unused")
object ShortsComponentPatch : BaseBytecodePatch( object ShortsComponentPatch : BaseBytecodePatch(
name = "Hide shorts components", name = "Shorts components",
description = "Adds options to hide components related to YouTube Shorts.", description = "Adds options to hide or change components related to YouTube Shorts.",
dependencies = setOf( dependencies = setOf(
LithoFilterPatch::class, LithoFilterPatch::class,
PlayerTypeHookPatch::class, PlayerTypeHookPatch::class,
SettingsPatch::class, SettingsPatch::class,
SharedResourceIdPatch::class, SharedResourceIdPatch::class,
ShortsNavigationBarPatch::class, ShortsNavigationBarPatch::class,
ShortsToolBarPatch::class ShortsToolBarPatch::class,
VideoInformationPatch::class
), ),
compatiblePackages = COMPATIBLE_PACKAGE, compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf( fingerprints = setOf(
@ -59,7 +64,8 @@ object ShortsComponentPatch : BaseBytecodePatch(
ShortsPaidPromotionFingerprint, ShortsPaidPromotionFingerprint,
ShortsPivotFingerprint, ShortsPivotFingerprint,
ShortsPivotLegacyFingerprint, ShortsPivotLegacyFingerprint,
ShortsSubscriptionsTabletParentFingerprint ShortsSubscriptionsTabletParentFingerprint,
TextComponentSpecFingerprint
) )
) { ) {
private const val BUTTON_FILTER_CLASS_DESCRIPTOR = private const val BUTTON_FILTER_CLASS_DESCRIPTOR =
@ -236,6 +242,35 @@ object ShortsComponentPatch : BaseBytecodePatch(
// endregion // endregion
// region patch for return shorts channel name
TextComponentSpecFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val insertIndex = getTargetIndexWithReference("Landroid/text/SpannableString;->valueOf(Ljava/lang/CharSequence;)Landroid/text/SpannableString;")
val charSequenceRegister =
getInstruction<FiveRegisterInstruction>(insertIndex).registerC
val conversionContextRegister =
getInstruction<TwoRegisterInstruction>(0).registerA
val replaceReference =
getInstruction<ReferenceInstruction>(insertIndex).reference
addInstructions(
insertIndex + 1, """
invoke-static {v$conversionContextRegister, v$charSequenceRegister}, $SHORTS_CLASS_DESCRIPTOR->onCharSequenceLoaded(Ljava/lang/Object;Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
move-result-object v$charSequenceRegister
invoke-static {v$charSequenceRegister}, $replaceReference
"""
)
removeInstruction(insertIndex)
}
}
VideoInformationPatch.hookShorts("$SHORTS_CLASS_DESCRIPTOR->newShortsVideoStarted(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JZ)V")
// endregion
LithoFilterPatch.addFilter(BUTTON_FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(BUTTON_FILTER_CLASS_DESCRIPTOR)
LithoFilterPatch.addFilter(SHELF_FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(SHELF_FILTER_CLASS_DESCRIPTOR)
@ -245,7 +280,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
SettingsPatch.addPreference( SettingsPatch.addPreference(
arrayOf( arrayOf(
"PREFERENCE_SCREEN: SHORTS", "PREFERENCE_SCREEN: SHORTS",
"SETTINGS: HIDE_SHORTS_COMPONENTS" "SETTINGS: SHORTS_COMPONENTS"
) )
) )

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints package app.revanced.patches.youtube.utils.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint import app.revanced.patcher.fingerprint.MethodFingerprint

View File

@ -8,9 +8,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.utils.fingerprints.TextComponentSpecFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.ShortsTextViewFingerprint
import app.revanced.patches.youtube.utils.returnyoutubedislike.shorts.fingerprints.TextComponentSpecFingerprint
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getTargetIndex import app.revanced.util.getTargetIndex
import app.revanced.util.getTargetIndexReversed import app.revanced.util.getTargetIndexReversed

View File

@ -93,6 +93,7 @@ object VideoInformationPatch : BytecodePatch(
private const val REGISTER_VIDEO_ID = 2 private const val REGISTER_VIDEO_ID = 2
private const val REGISTER_VIDEO_TITLE = 3 private const val REGISTER_VIDEO_TITLE = 3
private const val REGISTER_VIDEO_LENGTH = 4 private const val REGISTER_VIDEO_LENGTH = 4
@Suppress("unused")
private const val REGISTER_VIDEO_LENGTH_DUMMY = 5 private const val REGISTER_VIDEO_LENGTH_DUMMY = 5
private const val REGISTER_VIDEO_IS_LIVE = 6 private const val REGISTER_VIDEO_IS_LIVE = 6

View File

@ -965,6 +965,9 @@ Limitation: Official headers in search results will be hidden."</string>
<string name="revanced_hide_shorts_navigation_bar_title">Hide navigation bar</string> <string name="revanced_hide_shorts_navigation_bar_title">Hide navigation bar</string>
<string name="revanced_hide_shorts_navigation_bar_summary_on">Navigation bar is hidden.</string> <string name="revanced_hide_shorts_navigation_bar_summary_on">Navigation bar is hidden.</string>
<string name="revanced_hide_shorts_navigation_bar_summary_off">Navigation bar is shown.</string> <string name="revanced_hide_shorts_navigation_bar_summary_off">Navigation bar is shown.</string>
<string name="revanced_return_shorts_channel_name_title">Return shorts channel name</string>
<string name="revanced_return_shorts_channel_name_summary_on">Channel name is used.</string>
<string name="revanced_return_shorts_channel_name_summary_off">Channel handle is used.</string>
<!-- PreferenceScreen: Swipe controls --> <!-- PreferenceScreen: Swipe controls -->

View File

@ -399,7 +399,7 @@
<!-- PREFERENCE_SCREEN: SHORTS <!-- PREFERENCE_SCREEN: SHORTS
<PreferenceScreen android:title="@string/revanced_preference_screen_shorts_title" android:key="revanced_preference_screen_shorts">PREFERENCE_SCREEN: SHORTS --> <PreferenceScreen android:title="@string/revanced_preference_screen_shorts_title" android:key="revanced_preference_screen_shorts">PREFERENCE_SCREEN: SHORTS -->
<!-- SETTINGS: HIDE_SHORTS_COMPONENTS <!-- SETTINGS: SHORTS_COMPONENTS
<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"> <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:defaultValue="true" 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_join_button_title" android:key="revanced_hide_shorts_join_button" android:defaultValue="true" 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:defaultValue="true" 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_subscribe_button_title" android:key="revanced_hide_shorts_subscribe_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_subscribe_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_subscribe_button_summary_off" />
@ -427,8 +427,8 @@
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/> <PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_title" android:key="revanced_hide_shorts_toolbar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_title" android:key="revanced_hide_shorts_toolbar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" /> <SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />
<SwitchPreference android:title="@string/revanced_return_shorts_channel_name_title" android:key="revanced_return_shorts_channel_name" android:defaultValue="false" android:summaryOn="@string/revanced_return_shorts_channel_name_summary_on" android:summaryOff="@string/revanced_return_shorts_channel_name_summary_off" />
</PreferenceScreen>SETTINGS: HIDE_SHORTS_COMPONENTS --> </PreferenceScreen>SETTINGS: SHORTS_COMPONENTS -->
<!-- SETTINGS: CHANGE_SHORTS_REPEAT_STATE <!-- SETTINGS: CHANGE_SHORTS_REPEAT_STATE
<ListPreference android:entries="@array/revanced_change_shorts_repeat_state_entries" android:title="@string/revanced_change_shorts_repeat_state_title" android:key="revanced_change_shorts_repeat_state" android:defaultValue="2" android:entryValues="@array/revanced_change_shorts_repeat_state_entry_values" />SETTINGS: CHANGE_SHORTS_REPEAT_STATE --> <ListPreference android:entries="@array/revanced_change_shorts_repeat_state_entries" android:title="@string/revanced_change_shorts_repeat_state_title" android:key="revanced_change_shorts_repeat_state" android:defaultValue="2" android:entryValues="@array/revanced_change_shorts_repeat_state_entry_values" />SETTINGS: CHANGE_SHORTS_REPEAT_STATE -->
@ -436,13 +436,13 @@
<!-- SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER <!-- SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER
<SwitchPreference android:title="@string/revanced_disable_resuming_shorts_player_title" android:key="revanced_disable_resuming_shorts_player" android:defaultValue="true" android:summaryOn="@string/revanced_disable_resuming_shorts_player_summary_on" android:summaryOff="@string/revanced_disable_resuming_shorts_player_summary_off" />SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER --> <SwitchPreference android:title="@string/revanced_disable_resuming_shorts_player_title" android:key="revanced_disable_resuming_shorts_player" android:defaultValue="true" android:summaryOn="@string/revanced_disable_resuming_shorts_player_summary_on" android:summaryOff="@string/revanced_disable_resuming_shorts_player_summary_off" />SETTINGS: DISABLE_RESUMING_SHORTS_PLAYER -->
<!-- SETTINGS: HIDE_SHORTS_COMPONENTS <!-- SETTINGS: SHORTS_COMPONENTS
<PreferenceCategory android:title="@string/revanced_preference_category_shorts_shelf" android:layout="@layout/revanced_settings_preferences_category"/> <PreferenceCategory android:title="@string/revanced_preference_category_shorts_shelf" android:layout="@layout/revanced_settings_preferences_category"/>
<SwitchPreference android:title="@string/revanced_hide_shorts_shelf_title" android:key="revanced_hide_shorts_shelf" android:defaultValue="true" android:summary="@string/revanced_hide_shorts_shelf_summary" /> <SwitchPreference android:title="@string/revanced_hide_shorts_shelf_title" android:key="revanced_hide_shorts_shelf" android:defaultValue="true" android:summary="@string/revanced_hide_shorts_shelf_summary" />
<SwitchPreference android:title="@string/revanced_hide_shorts_shelf_home_related_videos_title" android:key="revanced_hide_shorts_shelf_home_related_videos" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_home_related_videos_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_home_related_videos_summary_off" android:dependency="revanced_hide_shorts_shelf" /> <SwitchPreference android:title="@string/revanced_hide_shorts_shelf_home_related_videos_title" android:key="revanced_hide_shorts_shelf_home_related_videos" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_home_related_videos_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_home_related_videos_summary_off" android:dependency="revanced_hide_shorts_shelf" />
<SwitchPreference android:title="@string/revanced_hide_shorts_shelf_subscriptions_title" android:key="revanced_hide_shorts_shelf_subscriptions" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_subscriptions_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_subscriptions_summary_off" android:dependency="revanced_hide_shorts_shelf" /> <SwitchPreference android:title="@string/revanced_hide_shorts_shelf_subscriptions_title" android:key="revanced_hide_shorts_shelf_subscriptions" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_subscriptions_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_subscriptions_summary_off" android:dependency="revanced_hide_shorts_shelf" />
<SwitchPreference android:title="@string/revanced_hide_shorts_shelf_search_title" android:key="revanced_hide_shorts_shelf_search" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_search_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_search_summary_off" android:dependency="revanced_hide_shorts_shelf" /> <SwitchPreference android:title="@string/revanced_hide_shorts_shelf_search_title" android:key="revanced_hide_shorts_shelf_search" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_shelf_search_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_search_summary_off" android:dependency="revanced_hide_shorts_shelf" />
<SwitchPreference android:title="@string/revanced_hide_shorts_shelf_history_title" android:key="revanced_hide_shorts_shelf_history" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_shelf_history_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_history_summary_off" android:dependency="revanced_hide_shorts_shelf" />SETTINGS: HIDE_SHORTS_COMPONENTS --> <SwitchPreference android:title="@string/revanced_hide_shorts_shelf_history_title" android:key="revanced_hide_shorts_shelf_history" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_shelf_history_summary_on" android:summaryOff="@string/revanced_hide_shorts_shelf_history_summary_off" android:dependency="revanced_hide_shorts_shelf" />SETTINGS: SHORTS_COMPONENTS -->
<!-- PREFERENCE_SCREEN: SHORTS <!-- PREFERENCE_SCREEN: SHORTS
</PreferenceScreen>PREFERENCE_SCREEN: SHORTS --> </PreferenceScreen>PREFERENCE_SCREEN: SHORTS -->
@ -596,7 +596,7 @@
<PreferenceCategory android:title="@string/revanced_preference_screen_shorts_title" > <PreferenceCategory android:title="@string/revanced_preference_screen_shorts_title" >
<Preference android:title="Change shorts repeat state" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Change shorts repeat state" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Disable resuming shorts on startup" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Disable resuming shorts on startup" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide shorts components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Shorts components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Shorts outline button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/> <Preference android:title="Shorts outline button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
</PreferenceCategory> </PreferenceCategory>