Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
feat(YouTube - Description components): Add `Hide 'Key concepts' sect…
Browse files Browse the repository at this point in the history
…ion` option (#670)

Co-authored-by: oSumAtrIX <[email protected]>
Co-authored-by: ILoveOpenSourceApplications <[email protected]>
Co-authored-by: LisoUseInAIKyrios <[email protected]>
  • Loading branch information
4 people authored Aug 1, 2024
1 parent e879e40 commit 86b25ea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package app.revanced.integrations.youtube.patches.components;

import androidx.annotation.Nullable;
import app.revanced.integrations.youtube.settings.Settings;

import app.revanced.integrations.youtube.StringTrieSearch;
import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings("unused")
final class DescriptionComponentsFilter extends Filter {

private final StringTrieSearch exceptions = new StringTrieSearch();

private final ByteArrayFilterGroupList macroMarkersCarouselGroupList = new ByteArrayFilterGroupList();

private final StringFilterGroup macroMarkersCarousel;

public DescriptionComponentsFilter() {
exceptions.addPatterns(
"compact_channel",
Expand All @@ -25,11 +30,6 @@ public DescriptionComponentsFilter() {
"video_attributes_section"
);

final StringFilterGroup chaptersSection = new StringFilterGroup(
Settings.HIDE_CHAPTERS_SECTION,
"macro_markers_carousel"
);

final StringFilterGroup infoCardsSection = new StringFilterGroup(
Settings.HIDE_INFO_CARDS_SECTION,
"infocards_section"
Expand All @@ -45,21 +45,44 @@ public DescriptionComponentsFilter() {
"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(
attributesSection,
chaptersSection,
infoCardsSection,
podcastSection,
transcriptSection
transcriptSection,
macroMarkersCarousel
);
}


@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_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_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_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", TRUE);

Expand Down

0 comments on commit 86b25ea

Please sign in to comment.