1
mirror of https://github.com/revanced/revanced-integrations synced 2024-11-22 05:02:19 +01:00

feat(YouTube - Hide layout components): Hide description components

This commit is contained in:
oSumAtrIX 2023-11-18 04:34:16 +01:00
parent 0978e64655
commit 726a2510a5
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 77 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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),