diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt index 4cff19559..859c3cdbc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/ChannelProfileComponentsPatch.kt @@ -1,19 +1,28 @@ -package app.revanced.patches.youtube.general.descriptions +package app.revanced.patches.youtube.general.channelprofile 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.general.channelprofile.fingerprints.DefaultsTabsBarFingerprint import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.youtube.utils.litho.LithoFilterPatch +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TabsBarTextTabView import app.revanced.patches.youtube.utils.settings.SettingsPatch +import app.revanced.util.exception +import app.revanced.util.getWideLiteralInstructionIndex +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Patch( name = "Hide channel profile components", description = "Hides channel profile components.", dependencies = [ LithoFilterPatch::class, - SettingsPatch::class + SettingsPatch::class, + SharedResourceIdPatch::class ], compatiblePackages = [ CompatiblePackage( @@ -43,9 +52,27 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch ] ) @Suppress("unused") -object ChannelProfileComponentsPatch : BytecodePatch(emptySet()) { +object ChannelProfileComponentsPatch : BytecodePatch( + setOf(DefaultsTabsBarFingerprint) +) { + private const val FILTER_CLASS_DESCRIPTOR = + "$COMPONENTS_PATH/ChannelProfileFilter;" + override fun execute(context: BytecodeContext) { - LithoFilterPatch.addFilter("$COMPONENTS_PATH/ChannelProfileFilter;") + + DefaultsTabsBarFingerprint.result?.let { + it.mutableMethod.apply { + val viewIndex = getWideLiteralInstructionIndex(TabsBarTextTabView) + 2 + val viewRegister = getInstruction(viewIndex).registerA + + addInstruction( + viewIndex + 1, + "sput-object v$viewRegister, $FILTER_CLASS_DESCRIPTOR->channelTabView:Landroid/view/View;" + ) + } + } ?: throw DefaultsTabsBarFingerprint.exception + + LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) /** * Add settings diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/fingerprints/DefaultsTabsBarFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/fingerprints/DefaultsTabsBarFingerprint.kt new file mode 100644 index 000000000..c53270278 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/general/channelprofile/fingerprints/DefaultsTabsBarFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.youtube.general.channelprofile.fingerprints + +import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TabsBarTextTabView +import app.revanced.util.fingerprint.LiteralValueFingerprint + +object DefaultsTabsBarFingerprint : LiteralValueFingerprint( + returnType = "Landroid/view/View;", + parameters = listOf("Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;", "Z"), + literalSupplier = { TabsBarTextTabView } +) \ 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 f229ae2e8..d1a085688 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 @@ -77,6 +77,7 @@ object SharedResourceIdPatch : ResourcePatch() { var SettingsBooleanTimeRangeDialog: Long = -1 var SubtitleMenuSettingsFooterInfo: Long = -1 var SuggestedAction: Long = -1 + var TabsBarTextTabView: Long = -1 var ToolBarPaddingHome: Long = -1 var ToolTipContentView: Long = -1 var TotalTime: Long = -1 @@ -159,6 +160,7 @@ object SharedResourceIdPatch : ResourcePatch() { SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog") SubtitleMenuSettingsFooterInfo = find(STRING, "subtitle_menu_settings_footer_info") SuggestedAction = find(LAYOUT, "suggested_action") + TabsBarTextTabView = find(ID, "tabs_bar_text_tab_view") ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up") ToolTipContentView = find(LAYOUT, "tooltip_content_view") TotalTime = find(STRING, "total_time") diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 72c493164..0a66dafc5 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -594,6 +594,9 @@ Known issue: Official headers in search results are hidden." Start trial button is shown. Start trial button is hidden. Hide start trial button + Store tab is shown. + Store tab is hidden. + Hide store tab Subscriptions button in navigation bar is shown. Subscriptions button in navigation bar is hidden. Hide subscriptions button diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 5e1c50702..d476589c4 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -264,7 +264,8 @@ - SETTINGS: HIDE_CHANNEL_PROFILE_COMPONENTS --> + + SETTINGS: HIDE_CHANNEL_PROFILE_COMPONENTS -->