Skip to content

Commit a13e345

Browse files
feat(YouTube - Video description): Add Hide Shopping links
1 parent f15003a commit a13e345

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ final class DescriptionComponentsFilter extends Filter {
1313
private final ByteArrayFilterGroupList macroMarkersCarouselGroupList = new ByteArrayFilterGroupList();
1414

1515
private final StringFilterGroup macroMarkersCarousel;
16+
private final StringFilterGroup expandableList;
17+
private final ByteArrayFilterGroup shoppingLinks;
1618

1719
public DescriptionComponentsFilter() {
1820
exceptions.addPatterns(
@@ -76,15 +78,26 @@ public DescriptionComponentsFilter() {
7678
)
7779
);
7880

81+
expandableList = new StringFilterGroup(
82+
Settings.HIDE_SHOPPING_LINKS_SECTION,
83+
"expandable_list.eml"
84+
);
85+
86+
shoppingLinks = new ByteArrayFilterGroup(
87+
null,
88+
"shopping_link_item"
89+
);
90+
7991
addPathCallbacks(
8092
aiGeneratedVideoSummarySection,
8193
askSection,
8294
attributesSection,
83-
infoCardsSection,
95+
expandableList,
8496
howThisWasMadeSection,
97+
infoCardsSection,
98+
macroMarkersCarousel,
8599
podcastSection,
86-
transcriptSection,
87-
macroMarkersCarousel
100+
transcriptSection
88101
);
89102
}
90103

@@ -99,4 +112,11 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
99112

100113
return true;
101114
}
115+
116+
if (matchedGroup == expandableList) {
117+
if (shoppingLinks.check(protobufBufferArray).isFiltered()) {
118+
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
119+
}
120+
return false;
121+
}
102122
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public class Settings extends BaseSettings {
193193
public static final BooleanSetting HIDE_INFO_CARDS_SECTION = new BooleanSetting("revanced_hide_info_cards_section", TRUE);
194194
public static final BooleanSetting HIDE_KEY_CONCEPTS_SECTION = new BooleanSetting("revanced_hide_key_concepts_section", FALSE);
195195
public static final BooleanSetting HIDE_PODCAST_SECTION = new BooleanSetting("revanced_hide_podcast_section", TRUE);
196+
public static final BooleanSetting HIDE_SHOPPING_LINKS_SECTION = new BooleanSetting("revanced_hide_shopping_links_section", TRUE);
196197
public static final BooleanSetting HIDE_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", TRUE);
197198
// Action buttons
198199
public static final BooleanSetting DISABLE_LIKE_SUBSCRIBE_GLOW = new BooleanSetting("revanced_disable_like_subscribe_glow", FALSE);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
148148
SwitchPreference("revanced_hide_how_this_was_made_section"),
149149
SwitchPreference("revanced_hide_key_concepts_section"),
150150
SwitchPreference("revanced_hide_podcast_section"),
151+
SwitchPreference("revanced_hide_shopping_links_section"),
151152
SwitchPreference("revanced_hide_transcript_section"),
152153
),
153154
),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ You will not be notified of any unexpected events."</string>
337337
<string name="revanced_hide_key_concepts_section_title">Hide \'Key concepts\'</string>
338338
<string name="revanced_hide_key_concepts_section_summary_on">Key concepts section is hidden</string>
339339
<string name="revanced_hide_key_concepts_section_summary_off">Key concepts section is shown</string>
340+
<string name="revanced_hide_shopping_links_section_title">Hide Shopping links</string>
341+
<string name="revanced_hide_shopping_links_section_summary_on">Shopping links section is hidden</string>
342+
<string name="revanced_hide_shopping_links_section_summary_off">Shopping links section is shown</string>
340343
<string name="revanced_hide_transcript_section_title">Hide Transcript</string>
341344
<string name="revanced_hide_transcript_section_summary_on">Transcript section is hidden</string>
342345
<string name="revanced_hide_transcript_section_summary_off">Transcript section is shown</string>

0 commit comments

Comments
 (0)