feat(YouTube - Description components): Add Hide 'Key concepts' section option (#670)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: ILoveOpenSourceApplications <ILoveOpenSourceApplications@users.noreply.github.com>
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
ILoveOpenSourceApplications 2024-08-01 16:57:19 +05:30 committed by GitHub
parent e879e40e56
commit 86b25ea468
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 10 deletions

View File

@ -1,14 +1,19 @@
package app.revanced.integrations.youtube.patches.components; package app.revanced.integrations.youtube.patches.components;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.StringTrieSearch; import app.revanced.integrations.youtube.StringTrieSearch;
import app.revanced.integrations.youtube.settings.Settings;
@SuppressWarnings("unused") @SuppressWarnings("unused")
final class DescriptionComponentsFilter extends Filter { final class DescriptionComponentsFilter extends Filter {
private final StringTrieSearch exceptions = new StringTrieSearch(); private final StringTrieSearch exceptions = new StringTrieSearch();
private final ByteArrayFilterGroupList macroMarkersCarouselGroupList = new ByteArrayFilterGroupList();
private final StringFilterGroup macroMarkersCarousel;
public DescriptionComponentsFilter() { public DescriptionComponentsFilter() {
exceptions.addPatterns( exceptions.addPatterns(
"compact_channel", "compact_channel",
@ -25,11 +30,6 @@ final class DescriptionComponentsFilter extends Filter {
"video_attributes_section" "video_attributes_section"
); );
final StringFilterGroup chaptersSection = new StringFilterGroup(
Settings.HIDE_CHAPTERS_SECTION,
"macro_markers_carousel"
);
final StringFilterGroup infoCardsSection = new StringFilterGroup( final StringFilterGroup infoCardsSection = new StringFilterGroup(
Settings.HIDE_INFO_CARDS_SECTION, Settings.HIDE_INFO_CARDS_SECTION,
"infocards_section" "infocards_section"
@ -45,21 +45,44 @@ final class DescriptionComponentsFilter extends Filter {
"transcript_section" "transcript_section"
); );
macroMarkersCarousel = new StringFilterGroup(
null,
"macro_markers_carousel.eml"
);
macroMarkersCarouselGroupList.addAll(
new ByteArrayFilterGroup(
Settings.HIDE_CHAPTERS_SECTION,
"chapters_horizontal_shelf"
),
new ByteArrayFilterGroup(
Settings.HIDE_KEY_CONCEPTS_SECTION,
"learning_concept_macro_markers_carousel_shelf"
)
);
addPathCallbacks( addPathCallbacks(
attributesSection, attributesSection,
chaptersSection,
infoCardsSection, infoCardsSection,
podcastSection, podcastSection,
transcriptSection transcriptSection,
macroMarkersCarousel
); );
} }
@Override @Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) { StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (exceptions.matches(path)) return false; if (exceptions.matches(path)) return false;
if (matchedGroup == macroMarkersCarousel) {
if (contentIndex == 0 && macroMarkersCarouselGroupList.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
return false;
}
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex); return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
} }
} }

View File

@ -157,6 +157,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_ATTRIBUTES_SECTION = new BooleanSetting("revanced_hide_attributes_section", FALSE); public static final BooleanSetting HIDE_ATTRIBUTES_SECTION = new BooleanSetting("revanced_hide_attributes_section", FALSE);
public static final BooleanSetting HIDE_CHAPTERS_SECTION = new BooleanSetting("revanced_hide_chapters_section", TRUE); public static final BooleanSetting HIDE_CHAPTERS_SECTION = new BooleanSetting("revanced_hide_chapters_section", TRUE);
public static final BooleanSetting HIDE_INFO_CARDS_SECTION = new BooleanSetting("revanced_hide_info_cards_section", TRUE); public static final BooleanSetting HIDE_INFO_CARDS_SECTION = new BooleanSetting("revanced_hide_info_cards_section", TRUE);
public static final BooleanSetting HIDE_KEY_CONCEPTS_SECTION = new BooleanSetting("revanced_hide_key_concepts_section", FALSE);
public static final BooleanSetting HIDE_PODCAST_SECTION = new BooleanSetting("revanced_hide_podcast_section", TRUE); public static final BooleanSetting HIDE_PODCAST_SECTION = new BooleanSetting("revanced_hide_podcast_section", TRUE);
public static final BooleanSetting HIDE_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", TRUE); public static final BooleanSetting HIDE_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", TRUE);