Skip to content

Commit da4cf94

Browse files
feat(YouTube - Hide layout components): Add video description "Hide Featured content" and "Hide Subscribe button" (#6253)
1 parent d23fa5e commit da4cf94

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/DescriptionComponentsFilter.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
@SuppressWarnings("unused")
88
final class DescriptionComponentsFilter extends Filter {
99

10-
private final StringTrieSearch exceptions = new StringTrieSearch();
11-
12-
private final ByteArrayFilterGroupList macroMarkersCarouselGroupList = new ByteArrayFilterGroupList();
10+
private static final String INFOCARDS_SECTION_PATH = "infocards_section.e";
1311

12+
private final StringTrieSearch exceptions = new StringTrieSearch();
1413
private final StringFilterGroup macroMarkersCarousel;
15-
14+
private final ByteArrayFilterGroupList macroMarkersCarouselGroupList = new ByteArrayFilterGroupList();
1615
private final StringFilterGroup horizontalShelf;
1716
private final ByteArrayFilterGroup cellVideoAttribute;
18-
17+
private final StringFilterGroup infoCardsSection;
18+
private final StringFilterGroup subscribeButton;
1919
private final StringFilterGroup aiGeneratedVideoSummarySection;
2020
private final StringFilterGroup hypePoints;
2121

@@ -44,9 +44,10 @@ public DescriptionComponentsFilter() {
4444
"video_attributes_section"
4545
);
4646

47-
final StringFilterGroup infoCardsSection = new StringFilterGroup(
48-
Settings.HIDE_INFO_CARDS_SECTION,
49-
"infocards_section"
47+
final StringFilterGroup featuredSection = new StringFilterGroup(
48+
Settings.HIDE_FEATURED_SECTION,
49+
// "media_lockup", "structured_description_video_lockup"
50+
"compact_infocard"
5051
);
5152

5253
final StringFilterGroup podcastSection = new StringFilterGroup(
@@ -69,6 +70,16 @@ public DescriptionComponentsFilter() {
6970
"hype_points_factoid"
7071
);
7172

73+
infoCardsSection = new StringFilterGroup(
74+
Settings.HIDE_INFO_CARDS_SECTION,
75+
INFOCARDS_SECTION_PATH
76+
);
77+
78+
subscribeButton = new StringFilterGroup(
79+
Settings.HIDE_DESCRIPTION_SUBSCRIBE_BUTTON,
80+
"subscribe_button"
81+
);
82+
7283
macroMarkersCarousel = new StringFilterGroup(
7384
null,
7485
"macro_markers_carousel.e"
@@ -99,12 +110,14 @@ public DescriptionComponentsFilter() {
99110
aiGeneratedVideoSummarySection,
100111
askSection,
101112
attributesSection,
102-
infoCardsSection,
113+
featuredSection,
103114
horizontalShelf,
104115
howThisWasMadeSection,
105116
hypePoints,
117+
infoCardsSection,
106118
macroMarkersCarousel,
107119
podcastSection,
120+
subscribeButton,
108121
transcriptSection
109122
);
110123
}
@@ -118,6 +131,10 @@ boolean isFiltered(String identifier, String path, byte[] buffer,
118131
return PlayerType.getCurrent().isMaximizedOrFullscreen();
119132
}
120133

134+
if (matchedGroup == subscribeButton) {
135+
return path.startsWith(INFOCARDS_SECTION_PATH);
136+
}
137+
121138
if (exceptions.matches(path)) return false;
122139

123140
if (matchedGroup == macroMarkersCarousel) {

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,13 @@ public class Settings extends BaseSettings {
210210
public static final BooleanSetting HIDE_ASK_SECTION = new BooleanSetting("revanced_hide_ask_section", FALSE);
211211
public static final BooleanSetting HIDE_ATTRIBUTES_SECTION = new BooleanSetting("revanced_hide_attributes_section", FALSE);
212212
public static final BooleanSetting HIDE_CHAPTERS_SECTION = new BooleanSetting("revanced_hide_chapters_section", TRUE);
213+
public static final BooleanSetting HIDE_FEATURED_SECTION = new BooleanSetting("revanced_hide_featured_section", TRUE);
213214
public static final BooleanSetting HIDE_HOW_THIS_WAS_MADE_SECTION = new BooleanSetting("revanced_hide_how_this_was_made_section", FALSE);
214215
public static final BooleanSetting HIDE_HYPE_POINTS = new BooleanSetting("revanced_hide_hype_points", FALSE);
215216
public static final BooleanSetting HIDE_INFO_CARDS_SECTION = new BooleanSetting("revanced_hide_info_cards_section", TRUE);
216217
public static final BooleanSetting HIDE_KEY_CONCEPTS_SECTION = new BooleanSetting("revanced_hide_key_concepts_section", FALSE);
217218
public static final BooleanSetting HIDE_PODCAST_SECTION = new BooleanSetting("revanced_hide_podcast_section", TRUE);
219+
public static final BooleanSetting HIDE_DESCRIPTION_SUBSCRIBE_BUTTON = new BooleanSetting("revanced_hide_description_subscribe_button", TRUE);
218220
public static final BooleanSetting HIDE_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", TRUE);
219221

220222
// Action buttons

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ val hideLayoutComponentsPatch = bytecodePatch(
145145
SwitchPreference("revanced_hide_ask_section"),
146146
SwitchPreference("revanced_hide_attributes_section"),
147147
SwitchPreference("revanced_hide_chapters_section"),
148+
SwitchPreference("revanced_hide_featured_section"),
148149
SwitchPreference("revanced_hide_info_cards_section"),
149150
SwitchPreference("revanced_hide_how_this_was_made_section"),
150151
SwitchPreference("revanced_hide_hype_points"),
151152
SwitchPreference("revanced_hide_key_concepts_section"),
152153
SwitchPreference("revanced_hide_podcast_section"),
154+
SwitchPreference("revanced_hide_description_subscribe_button"),
153155
SwitchPreference("revanced_hide_transcript_section"),
154156
),
155157
),

patches/src/main/resources/addresources/values/strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,18 @@ If a Doodle is currently showing in your region and this hide setting is on, the
346346
<string name="revanced_hide_podcast_section_title">Hide \'Explore the podcast\'</string>
347347
<string name="revanced_hide_podcast_section_summary_on">Explore the podcast section is hidden</string>
348348
<string name="revanced_hide_podcast_section_summary_off">Explore the podcast section is shown</string>
349+
<string name="revanced_hide_featured_section_title">Hide Featured content</string>
350+
<string name="revanced_hide_featured_section_summary_on">Featured content section is hidden</string>
351+
<string name="revanced_hide_featured_section_summary_off">Featured content section is shown</string>
349352
<string name="revanced_hide_info_cards_section_title">Hide Info cards</string>
350353
<string name="revanced_hide_info_cards_section_summary_on">Info cards section is hidden</string>
351354
<string name="revanced_hide_info_cards_section_summary_off">Info cards section is shown</string>
352355
<string name="revanced_hide_key_concepts_section_title">Hide \'Key concepts\'</string>
353356
<string name="revanced_hide_key_concepts_section_summary_on">Key concepts section is hidden</string>
354357
<string name="revanced_hide_key_concepts_section_summary_off">Key concepts section is shown</string>
358+
<string name="revanced_hide_description_subscribe_button_title">Hide Subscribe button</string>
359+
<string name="revanced_hide_description_subscribe_button_summary_on">Subscribe button is hidden</string>
360+
<string name="revanced_hide_description_subscribe_button_summary_off">Subscribe button is shown</string>
355361
<string name="revanced_hide_transcript_section_title">Hide Transcript</string>
356362
<string name="revanced_hide_transcript_section_summary_on">Transcript section is hidden</string>
357363
<string name="revanced_hide_transcript_section_summary_off">Transcript section is shown</string>

0 commit comments

Comments
 (0)