mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 16:44:29 +02:00
feat(YouTube/Hide feed components): add Channel tab filter
settings
This commit is contained in:
parent
8261c06f7e
commit
e6411d946a
@ -13,6 +13,8 @@ import app.revanced.patches.youtube.feed.components.fingerprints.BreakingNewsFin
|
|||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletSyntheticFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelListSubMenuTabletSyntheticFingerprint
|
||||||
|
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelTabBuilderFingerprint
|
||||||
|
import app.revanced.patches.youtube.feed.components.fingerprints.ChannelTabRendererFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserParentFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ElementParserParentFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.FilterBarHeightFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.FilterBarHeightFingerprint
|
||||||
@ -20,6 +22,7 @@ import app.revanced.patches.youtube.feed.components.fingerprints.LatestVideosBut
|
|||||||
import app.revanced.patches.youtube.feed.components.fingerprints.RelatedChipCloudFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.RelatedChipCloudFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.SearchResultsChipBarFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.SearchResultsChipBarFingerprint
|
||||||
import app.revanced.patches.youtube.feed.components.fingerprints.ShowMoreButtonFingerprint
|
import app.revanced.patches.youtube.feed.components.fingerprints.ShowMoreButtonFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.fingerprints.ScrollTopParentFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
||||||
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.FEED_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.FEED_CLASS_DESCRIPTOR
|
||||||
@ -27,10 +30,13 @@ import app.revanced.patches.youtube.utils.navigation.NavigationBarHookPatch
|
|||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
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.getTargetIndexWithMethodReferenceName
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
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
|
||||||
@ -52,10 +58,12 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
|||||||
ChannelListSubMenuFingerprint,
|
ChannelListSubMenuFingerprint,
|
||||||
ChannelListSubMenuTabletFingerprint,
|
ChannelListSubMenuTabletFingerprint,
|
||||||
ChannelListSubMenuTabletSyntheticFingerprint,
|
ChannelListSubMenuTabletSyntheticFingerprint,
|
||||||
|
ChannelTabRendererFingerprint,
|
||||||
ElementParserParentFingerprint,
|
ElementParserParentFingerprint,
|
||||||
FilterBarHeightFingerprint,
|
FilterBarHeightFingerprint,
|
||||||
LatestVideosButtonFingerprint,
|
LatestVideosButtonFingerprint,
|
||||||
RelatedChipCloudFingerprint,
|
RelatedChipCloudFingerprint,
|
||||||
|
ScrollTopParentFingerprint,
|
||||||
SearchResultsChipBarFingerprint,
|
SearchResultsChipBarFingerprint,
|
||||||
ShowMoreButtonFingerprint
|
ShowMoreButtonFingerprint
|
||||||
)
|
)
|
||||||
@ -197,6 +205,48 @@ object FeedComponentsPatch : BaseBytecodePatch(
|
|||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
// region patch for hide channel tab
|
||||||
|
|
||||||
|
ChannelTabBuilderFingerprint.resolve(
|
||||||
|
context,
|
||||||
|
ScrollTopParentFingerprint.resultOrThrow().classDef
|
||||||
|
)
|
||||||
|
|
||||||
|
val channelTabBuilderMethod = ChannelTabBuilderFingerprint.resultOrThrow().mutableMethod
|
||||||
|
|
||||||
|
ChannelTabRendererFingerprint.resultOrThrow().let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val iteratorIndex = getTargetIndexWithMethodReferenceName("hasNext")
|
||||||
|
val iteratorRegister = getInstruction<FiveRegisterInstruction>(iteratorIndex).registerC
|
||||||
|
|
||||||
|
val targetIndex = indexOfFirstInstruction {
|
||||||
|
val reference = ((this as? ReferenceInstruction)?.reference as? MethodReference)
|
||||||
|
|
||||||
|
opcode == Opcode.INVOKE_INTERFACE
|
||||||
|
&& reference?.returnType == channelTabBuilderMethod.returnType
|
||||||
|
&& reference.parameterTypes == channelTabBuilderMethod.parameterTypes
|
||||||
|
}
|
||||||
|
|
||||||
|
val objectIndex = getTargetIndexReversed(targetIndex, Opcode.IGET_OBJECT)
|
||||||
|
val objectInstruction = getInstruction<TwoRegisterInstruction>(objectIndex)
|
||||||
|
val objectReference = getInstruction<ReferenceInstruction>(objectIndex).reference
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
objectIndex + 1, """
|
||||||
|
invoke-static {v${objectInstruction.registerA}}, $FEED_CLASS_DESCRIPTOR->hideChannelTab(Ljava/lang/String;)Z
|
||||||
|
move-result v${objectInstruction.registerA}
|
||||||
|
if-eqz v${objectInstruction.registerA}, :ignore
|
||||||
|
invoke-interface {v$iteratorRegister}, Ljava/util/Iterator;->remove()V
|
||||||
|
goto :next_iterator
|
||||||
|
:ignore
|
||||||
|
iget-object v${objectInstruction.registerA}, v${objectInstruction.registerB}, $objectReference
|
||||||
|
""", ExternalLabel("next_iterator", getInstruction(iteratorIndex))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
LithoFilterPatch.addFilter(FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
|
LithoFilterPatch.addFilter(FEED_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
|
||||||
LithoFilterPatch.addFilter(FEED_VIDEO_FILTER_CLASS_DESCRIPTOR)
|
LithoFilterPatch.addFilter(FEED_VIDEO_FILTER_CLASS_DESCRIPTOR)
|
||||||
LithoFilterPatch.addFilter(FEED_VIDEO_VIEWS_FILTER_CLASS_DESCRIPTOR)
|
LithoFilterPatch.addFilter(FEED_VIDEO_VIEWS_FILTER_CLASS_DESCRIPTOR)
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.feed.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ChannelTabBuilderFingerprint : MethodFingerprint(
|
||||||
|
returnType = "Landroid/view/View;",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("Ljava/lang/CharSequence;", "Ljava/lang/CharSequence;", "Z", "L")
|
||||||
|
)
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.feed.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ChannelTabRendererFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("L", "Ljava/util/List;", "I"),
|
||||||
|
strings = listOf("TabRenderer.content contains SectionListRenderer but the tab does not have a section list controller.")
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint
|
package app.revanced.patches.youtube.utils.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
@ -5,9 +5,9 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
|||||||
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.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
|
import app.revanced.patches.youtube.utils.fingerprints.ScrollTopParentFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollPositionFingerprint
|
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollPositionFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopFingerprint
|
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.doublebacktoclose.fingerprint.ScrollTopParentFingerprint
|
|
||||||
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.mainactivity.MainActivityResolvePatch
|
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
|
||||||
import app.revanced.util.getWalkerMethod
|
import app.revanced.util.getWalkerMethod
|
||||||
|
@ -149,6 +149,14 @@ Tap here to learn more about DeArrow."</string>
|
|||||||
<string name="revanced_preference_screen_channel_profile_title">Channel profile</string>
|
<string name="revanced_preference_screen_channel_profile_title">Channel profile</string>
|
||||||
<string name="revanced_preference_screen_channel_profile_summary">Hide or show components in the channel profile.</string>
|
<string name="revanced_preference_screen_channel_profile_summary">Hide or show components in the channel profile.</string>
|
||||||
|
|
||||||
|
<string name="revanced_hide_channel_tab_title">Enable channel tab filter</string>
|
||||||
|
<string name="revanced_hide_channel_tab_summary_on">Channel tab filter is enabled.</string>
|
||||||
|
<string name="revanced_hide_channel_tab_summary_off">Channel tab filter is disabled.</string>
|
||||||
|
<string name="revanced_hide_channel_tab_filter_strings_title">Channel tab filter</string>
|
||||||
|
<string name="revanced_hide_channel_tab_filter_strings_summary">List of channel tab names to filter separated by a new line.</string>
|
||||||
|
<string name="revanced_hide_channel_tab_filter_strings_hint">"Shorts
|
||||||
|
Playlists
|
||||||
|
Store"</string>
|
||||||
<string name="revanced_hide_browse_store_button_title">Hide browse store button</string>
|
<string name="revanced_hide_browse_store_button_title">Hide browse store button</string>
|
||||||
<string name="revanced_hide_browse_store_button_summary_on">Browse store button is hidden.</string>
|
<string name="revanced_hide_browse_store_button_summary_on">Browse store button is hidden.</string>
|
||||||
<string name="revanced_hide_browse_store_button_summary_off">Browse store button is shown.</string>
|
<string name="revanced_hide_browse_store_button_summary_off">Browse store button is shown.</string>
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
<SwitchPreference android:title="@string/revanced_hide_category_bar_in_related_videos_title" android:key="revanced_hide_category_bar_in_related_videos" android:summaryOn="@string/revanced_hide_category_bar_in_related_videos_summary_on" android:summaryOff="@string/revanced_hide_category_bar_in_related_videos_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_category_bar_in_related_videos_title" android:key="revanced_hide_category_bar_in_related_videos" android:summaryOn="@string/revanced_hide_category_bar_in_related_videos_summary_on" android:summaryOff="@string/revanced_hide_category_bar_in_related_videos_summary_off" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
<PreferenceScreen android:title="@string/revanced_preference_screen_channel_profile_title" android:key="revanced_preference_screen_channel_profile" android:summary="@string/revanced_preference_screen_channel_profile_summary">
|
<PreferenceScreen android:title="@string/revanced_preference_screen_channel_profile_title" android:key="revanced_preference_screen_channel_profile" android:summary="@string/revanced_preference_screen_channel_profile_summary">
|
||||||
|
<SwitchPreference android:title="@string/revanced_hide_channel_tab_title" android:key="revanced_hide_channel_tab" android:defaultValue="false" android:summaryOn="@string/revanced_hide_channel_tab_summary_on" android:summaryOff="@string/revanced_hide_channel_tab_summary_off" />
|
||||||
|
<app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference android:title="@string/revanced_hide_channel_tab_filter_strings_title" android:key="revanced_hide_channel_tab_filter_strings" android:summary="@string/revanced_hide_channel_tab_filter_strings_summary" android:defaultValue="" android:hint="@string/revanced_hide_channel_tab_filter_strings_hint" android:inputType="textMultiLine" />
|
||||||
<SwitchPreference android:title="@string/revanced_hide_browse_store_button_title" android:key="revanced_hide_browse_store_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_browse_store_button_summary_on" android:summaryOff="@string/revanced_hide_browse_store_button_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_browse_store_button_title" android:key="revanced_hide_browse_store_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_browse_store_button_summary_on" android:summaryOff="@string/revanced_hide_browse_store_button_summary_off" />
|
||||||
<SwitchPreference android:title="@string/revanced_hide_channel_member_shelf_title" android:key="revanced_hide_channel_member_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_channel_member_shelf_summary_on" android:summaryOff="@string/revanced_hide_channel_member_shelf_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_channel_member_shelf_title" android:key="revanced_hide_channel_member_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_channel_member_shelf_summary_on" android:summaryOff="@string/revanced_hide_channel_member_shelf_summary_off" />
|
||||||
<SwitchPreference android:title="@string/revanced_hide_channel_profile_links_title" android:key="revanced_hide_channel_profile_links" android:defaultValue="true" android:summaryOn="@string/revanced_hide_channel_profile_links_summary_on" android:summaryOff="@string/revanced_hide_channel_profile_links_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_channel_profile_links_title" android:key="revanced_hide_channel_profile_links" android:defaultValue="true" android:summaryOn="@string/revanced_hide_channel_profile_links_summary_on" android:summaryOff="@string/revanced_hide_channel_profile_links_summary_off" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user