From 726a2510a5b28da3afb77c7f5fdda87a3bd2c809 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 18 Nov 2023 04:34:16 +0100 Subject: [PATCH] feat(YouTube - Hide layout components): Hide description components --- .../DescriptionComponentsFilter.java | 69 +++++++++++++++++++ .../components/LayoutComponentsFilter.java | 9 +-- .../integrations/settings/SettingsEnum.java | 8 ++- 3 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/app/revanced/integrations/patches/components/DescriptionComponentsFilter.java diff --git a/app/src/main/java/app/revanced/integrations/patches/components/DescriptionComponentsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/DescriptionComponentsFilter.java new file mode 100644 index 00000000..ccdd3210 --- /dev/null +++ b/app/src/main/java/app/revanced/integrations/patches/components/DescriptionComponentsFilter.java @@ -0,0 +1,69 @@ +package app.revanced.integrations.patches.components; + +import androidx.annotation.Nullable; +import app.revanced.integrations.settings.SettingsEnum; +import app.revanced.integrations.utils.StringTrieSearch; + +final class DescriptionComponentsFilter extends Filter { + + private final StringTrieSearch exceptions = new StringTrieSearch(); + + public DescriptionComponentsFilter() { + exceptions.addPatterns( + "compact_channel", + "description", + "grid_video", + "inline_expander", + "metadata" + ); + + final StringFilterGroup chapterSection = new StringFilterGroup( + SettingsEnum.HIDE_CHAPTERS, + "macro_markers_carousel" + ); + + final StringFilterGroup infoCardsSection = new StringFilterGroup( + SettingsEnum.HIDE_INFO_CARDS_SECTION, + "infocards_section" + ); + + final StringFilterGroup gameSection = new StringFilterGroup( + SettingsEnum.HIDE_GAME_SECTION, + "gaming_section" + ); + + final StringFilterGroup musicSection = new StringFilterGroup( + SettingsEnum.HIDE_MUSIC_SECTION, + "music_section", + "video_attributes_section" + ); + + final StringFilterGroup podcastSection = new StringFilterGroup( + SettingsEnum.HIDE_PODCAST_SECTION, + "playlist_section" + ); + + final StringFilterGroup transcriptSection = new StringFilterGroup( + SettingsEnum.HIDE_TRANSCIPT_SECTION, + "transcript_section" + ); + + pathFilterGroupList.addAll( + chapterSection, + infoCardsSection, + gameSection, + musicSection, + podcastSection, + transcriptSection + ); + } + + + @Override + boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, + FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) { + if (exceptions.matches(path)) return false; + + return super.isFiltered(path, identifier, protobufBufferArray, matchedList, matchedGroup, matchedIndex); + } +} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java index 6589976a..7603bc68 100644 --- a/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java +++ b/app/src/main/java/app/revanced/integrations/patches/components/LayoutComponentsFilter.java @@ -136,11 +136,6 @@ public final class LayoutComponentsFilter extends Filter { "quality_sheet_footer" ); - final var chapters = new StringFilterGroup( - SettingsEnum.HIDE_CHAPTERS, - "macro_markers_carousel" - ); - final var channelBar = new StringFilterGroup( SettingsEnum.HIDE_CHANNEL_BAR, "channel_bar" @@ -226,8 +221,7 @@ public final class LayoutComponentsFilter extends Filter { this.identifierFilterGroupList.addAll( graySeparator, - chipsShelf, - chapters + chipsShelf ); } @@ -249,7 +243,6 @@ public final class LayoutComponentsFilter extends Filter { return super.isFiltered(identifier, path, protobufBufferArray, matchedList, matchedGroup, matchedIndex); } - /** * Injection point. * Called from a different place then the other filters. diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index d830d06b..fe011e47 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -72,7 +72,6 @@ public enum SettingsEnum { HIDE_CAST_BUTTON("revanced_hide_cast_button", BOOLEAN, TRUE, true), HIDE_CHANNEL_BAR("revanced_hide_channel_bar", BOOLEAN, FALSE), HIDE_CHANNEL_MEMBER_SHELF("revanced_hide_channel_member_shelf", BOOLEAN, TRUE), - HIDE_CHAPTERS("revanced_hide_chapters", BOOLEAN, TRUE), HIDE_CHIPS_SHELF("revanced_hide_chips_shelf", BOOLEAN, TRUE), HIDE_COMMENTS_SECTION("revanced_hide_comments_section", BOOLEAN, FALSE, true), HIDE_COMMUNITY_GUIDELINES("revanced_hide_community_guidelines", BOOLEAN, TRUE), @@ -123,6 +122,13 @@ public enum SettingsEnum { TABLET_LAYOUT("revanced_tablet_layout", BOOLEAN, FALSE, true, "revanced_tablet_layout_user_dialog_message"), USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", BOOLEAN, FALSE, true), WIDE_SEARCHBAR("revanced_wide_searchbar", BOOLEAN, FALSE, true), + // Description + HIDE_CHAPTERS("revanced_hide_chapters", BOOLEAN, TRUE), + HIDE_INFO_CARDS_SECTION("revanced_hide_info_cards_section", BOOLEAN, TRUE), + HIDE_GAME_SECTION("revanced_hide_game_section", BOOLEAN, TRUE), + HIDE_MUSIC_SECTION("revanced_hide_music_section", BOOLEAN, TRUE), + HIDE_PODCAST_SECTION("revanced_hide_podcast_section", BOOLEAN, TRUE), + HIDE_TRANSCIPT_SECTION("revanced_hide_transcript_section", BOOLEAN, TRUE), // Shorts HIDE_SHORTS("revanced_hide_shorts", BOOLEAN, FALSE, true),