Skip to content

Commit 9d9cce3

Browse files
feat(YouTube - Hide layout components): Add Hide channel links preview and Hide 'Visit Community' button in channel page (#5320)
1 parent 5abbfcc commit 9d9cce3

File tree

7 files changed

+142
-124
lines changed

7 files changed

+142
-124
lines changed

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

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public final class AdsFilter extends Filter {
3434
private final StringFilterGroup playerShoppingShelf;
3535
private final ByteArrayFilterGroup playerShoppingShelfBuffer;
3636

37-
private final StringFilterGroup channelProfile;
38-
private final ByteArrayFilterGroup visitStoreButton;
39-
40-
private final StringFilterGroup shoppingLinks;
4137

4238
public AdsFilter() {
4339
exceptions.addPatterns(
@@ -113,18 +109,13 @@ public AdsFilter() {
113109
"shopping_overlay.eml" // Video player overlay shopping links.
114110
);
115111

116-
shoppingLinks = new StringFilterGroup(
117-
Settings.HIDE_TAGGED_PRODUCTS,
118-
"expandable_list"
119-
);
120-
121-
final var storeProductsShelf = new StringFilterGroup(
122-
Settings.HIDE_CREATOR_STORE_SHELVES,
112+
final var shoppingLinks = new StringFilterGroup(
113+
Settings.HIDE_SHOPPING_LINKS,
123114
"shopping_description_shelf.eml"
124115
);
125116

126117
playerShoppingShelf = new StringFilterGroup(
127-
Settings.HIDE_CREATOR_STORE_SHELVES,
118+
Settings.HIDE_CREATOR_STORE_SHELF,
128119
"horizontal_shelf.eml"
129120
);
130121

@@ -133,17 +124,6 @@ public AdsFilter() {
133124
"shopping_item_card_list"
134125
);
135126

136-
channelProfile = new StringFilterGroup(
137-
Settings.HIDE_VISIT_STORE_BUTTON,
138-
"channel_profile.eml",
139-
"page_header.eml"
140-
);
141-
142-
visitStoreButton = new ByteArrayFilterGroup(
143-
null,
144-
"header_store_button"
145-
);
146-
147127
final var webLinkPanel = new StringFilterGroup(
148128
Settings.HIDE_WEB_SEARCH_RESULTS,
149129
"web_link_panel"
@@ -161,15 +141,13 @@ public AdsFilter() {
161141
);
162142

163143
addPathCallbacks(
164-
channelProfile,
165144
fullscreenAd,
166145
generalAds,
167146
merchandise,
168147
movieAds,
169148
playerShoppingShelf,
170149
selfSponsor,
171150
shoppingLinks,
172-
storeProductsShelf,
173151
viewProducts,
174152
webLinkPanel
175153
);
@@ -182,11 +160,6 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
182160
return contentIndex == 0 && playerShoppingShelfBuffer.check(protobufBufferArray).isFiltered();
183161
}
184162

185-
// Check for the index because of likelihood of false positives.
186-
if (contentIndex != 0 && matchedGroup == shoppingLinks) {
187-
return false;
188-
}
189-
190163
if (exceptions.matches(path)) {
191164
return false;
192165
}
@@ -198,10 +171,6 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
198171
return false;
199172
}
200173

201-
if (matchedGroup == channelProfile) {
202-
return visitStoreButton.check(protobufBufferArray).isFiltered();
203-
}
204-
205174
return true;
206175
}
207176

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

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

10-
private final StringFilterGroup filterChipBar;
10+
private final StringFilterGroup chipBar;
1111
private final ByteArrayFilterGroup aiCommentsSummary;
1212

1313
public CommentsFilter() {
@@ -16,6 +16,21 @@ public CommentsFilter() {
1616
"live_chat_summary_banner.eml"
1717
);
1818

19+
chipBar = new StringFilterGroup(
20+
Settings.HIDE_COMMENTS_AI_SUMMARY,
21+
"chip_bar.eml"
22+
);
23+
24+
aiCommentsSummary = new ByteArrayFilterGroup(
25+
null,
26+
"yt_fill_spark_"
27+
);
28+
29+
var channelGuidelines = new StringFilterGroup(
30+
Settings.HIDE_COMMENTS_CHANNEL_GUIDELINES,
31+
"channel_guidelines_entry_banner"
32+
);
33+
1934
var commentsByMembers = new StringFilterGroup(
2035
Settings.HIDE_COMMENTS_BY_MEMBERS_HEADER,
2136
"sponsorships_comments_header.eml",
@@ -28,6 +43,11 @@ public CommentsFilter() {
2843
"_comments"
2944
);
3045

46+
var communityGuidelines = new StringFilterGroup(
47+
Settings.HIDE_COMMENTS_COMMUNITY_GUIDELINES,
48+
"community_guidelines"
49+
);
50+
3151
var createAShort = new StringFilterGroup(
3252
Settings.HIDE_COMMENTS_CREATE_A_SHORT_BUTTON,
3353
"composer_short_creation_button.eml"
@@ -50,32 +70,25 @@ public CommentsFilter() {
5070
"composer_timestamp_button.eml"
5171
);
5272

53-
filterChipBar = new StringFilterGroup(
54-
Settings.HIDE_COMMENTS_AI_SUMMARY,
55-
"chip_bar.eml"
56-
);
57-
58-
aiCommentsSummary = new ByteArrayFilterGroup(
59-
null,
60-
"yt_fill_spark_"
61-
);
62-
6373
addPathCallbacks(
74+
channelGuidelines,
6475
chatSummary,
76+
chipBar,
6577
commentsByMembers,
6678
comments,
79+
communityGuidelines,
6780
createAShort,
6881
previewComment,
6982
thanksButton,
70-
timestampButton,
71-
filterChipBar
83+
timestampButton
84+
7285
);
7386
}
7487

7588
@Override
7689
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
7790
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
78-
if (matchedGroup == filterChipBar) {
91+
if (matchedGroup == chipBar) {
7992
return aiCommentsSummary.check(protobufBufferArray).isFiltered();
8093
}
8194

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

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public final class LayoutComponentsFilter extends Filter {
4040
private final StringFilterGroup horizontalShelves;
4141
private final ByteArrayFilterGroup ticketShelf;
4242
private final StringFilterGroup chipBar;
43+
private final StringFilterGroup channelProfile;
44+
private final ByteArrayFilterGroupList channelProfileBuffer;
4345

4446
public LayoutComponentsFilter() {
4547
exceptions.addPatterns(
@@ -81,18 +83,13 @@ public LayoutComponentsFilter() {
8183
"poll_post_responsive_root.eml"
8284
);
8385

84-
final var communityGuidelines = new StringFilterGroup(
85-
Settings.HIDE_COMMUNITY_GUIDELINES,
86-
"community_guidelines"
87-
);
88-
8986
final var subscribersCommunityGuidelines = new StringFilterGroup(
9087
Settings.HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES,
9188
"sponsorships_comments_upsell"
9289
);
9390

94-
final var channelMemberShelf = new StringFilterGroup(
95-
Settings.HIDE_CHANNEL_MEMBER_SHELF,
91+
final var channelMembersShelf = new StringFilterGroup(
92+
Settings.HIDE_MEMBERS_SHELF,
9693
"member_recognition_shelf"
9794
);
9895

@@ -139,13 +136,13 @@ public LayoutComponentsFilter() {
139136
);
140137

141138
final var latestPosts = new StringFilterGroup(
142-
Settings.HIDE_HIDE_LATEST_POSTS,
139+
Settings.HIDE_LATEST_POSTS,
143140
"post_shelf"
144141
);
145142

146-
final var channelGuidelines = new StringFilterGroup(
147-
Settings.HIDE_HIDE_CHANNEL_GUIDELINES,
148-
"channel_guidelines_entry_banner"
143+
final var channelLinksPreview = new StringFilterGroup(
144+
Settings.HIDE_LINKS_PREVIEW,
145+
"attribution.eml"
149146
);
150147

151148
final var emergencyBox = new StringFilterGroup(
@@ -200,7 +197,6 @@ public LayoutComponentsFilter() {
200197
"image_shelf"
201198
);
202199

203-
204200
final var timedReactions = new StringFilterGroup(
205201
Settings.HIDE_TIMED_REACTIONS,
206202
"emoji_control_panel",
@@ -227,7 +223,6 @@ public LayoutComponentsFilter() {
227223
"sponsorships"
228224
);
229225

230-
231226
final var channelWatermark = new StringFilterGroup(
232227
Settings.HIDE_VIDEO_CHANNEL_WATERMARK,
233228
"featured_channel_watermark_overlay"
@@ -243,6 +238,22 @@ public LayoutComponentsFilter() {
243238
"endorsement_header_footer.eml"
244239
);
245240

241+
channelProfile = new StringFilterGroup(
242+
null,
243+
"channel_profile.eml",
244+
"page_header.eml"
245+
);
246+
channelProfileBuffer = new ByteArrayFilterGroupList();
247+
channelProfileBuffer.addAll(new ByteArrayFilterGroup(
248+
Settings.HIDE_VISIT_STORE_BUTTON,
249+
"header_store_button"
250+
),
251+
new ByteArrayFilterGroup(
252+
Settings.HIDE_VISIT_COMMUNITY_BUTTON,
253+
"community_button"
254+
)
255+
);
256+
246257
horizontalShelves = new StringFilterGroup(
247258
Settings.HIDE_HORIZONTAL_SHELVES,
248259
"horizontal_video_shelf.eml",
@@ -266,7 +277,6 @@ public LayoutComponentsFilter() {
266277
searchResultRecommendationLabels,
267278
latestPosts,
268279
channelWatermark,
269-
communityGuidelines,
270280
playables,
271281
quickActions,
272282
relatedVideos,
@@ -279,12 +289,13 @@ public LayoutComponentsFilter() {
279289
subscribersCommunityGuidelines,
280290
subscriptionsChipBar,
281291
chipBar,
282-
channelGuidelines,
292+
channelLinksPreview,
293+
channelProfile,
283294
audioTrackButton,
284295
artistCard,
285296
timedReactions,
286297
imageShelf,
287-
channelMemberShelf,
298+
channelMembersShelf,
288299
forYouShelf,
289300
horizontalShelves
290301
);
@@ -308,6 +319,10 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
308319
return true;
309320
}
310321

322+
if (matchedGroup == channelProfile) {
323+
return channelProfileBuffer.check(protobufBufferArray).isFiltered();
324+
}
325+
311326
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
312327

313328
if (matchedGroup == compactChannelBarInner) {
@@ -332,7 +347,7 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
332347
* Injection point.
333348
* Called from a different place then the other filters.
334349
*/
335-
public static boolean filterMixPlaylists(final Object conversionContext, @Nullable final byte[] bytes) {
350+
public static boolean filterMixPlaylists(Object conversionContext, @Nullable final byte[] bytes) {
336351
try {
337352
if (!Settings.HIDE_MIX_PLAYLISTS.get()) {
338353
return false;

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,18 @@ public class Settings extends BaseSettings {
7474
public static final BooleanSetting FORCE_ORIGINAL_AUDIO = new BooleanSetting("revanced_force_original_audio", FALSE, new ForceOriginalAudioAvailability());
7575

7676
// Ads
77-
public static final BooleanSetting HIDE_CREATOR_STORE_SHELVES = new BooleanSetting("revanced_hide_creator_store_shelves", TRUE);
77+
public static final BooleanSetting HIDE_CREATOR_STORE_SHELF = new BooleanSetting("revanced_hide_creator_store_shelf", TRUE);
7878
public static final BooleanSetting HIDE_END_SCREEN_STORE_BANNER = new BooleanSetting("revanced_hide_end_screen_store_banner", TRUE, true);
7979
public static final BooleanSetting HIDE_FULLSCREEN_ADS = new BooleanSetting("revanced_hide_fullscreen_ads", TRUE);
8080
public static final BooleanSetting HIDE_GENERAL_ADS = new BooleanSetting("revanced_hide_general_ads", TRUE);
8181
public static final BooleanSetting HIDE_GET_PREMIUM = new BooleanSetting("revanced_hide_get_premium", TRUE);
82-
public static final BooleanSetting HIDE_HIDE_LATEST_POSTS = new BooleanSetting("revanced_hide_latest_posts_ads", TRUE);
82+
public static final BooleanSetting HIDE_LATEST_POSTS = new BooleanSetting("revanced_hide_latest_posts", TRUE);
8383
public static final BooleanSetting HIDE_MERCHANDISE_BANNERS = new BooleanSetting("revanced_hide_merchandise_banners", TRUE);
8484
public static final BooleanSetting HIDE_PAID_PROMOTION_LABEL = new BooleanSetting("revanced_hide_paid_promotion_label", TRUE);
8585
public static final BooleanSetting HIDE_SELF_SPONSOR = new BooleanSetting("revanced_hide_self_sponsor_ads", TRUE);
86-
public static final BooleanSetting HIDE_TAGGED_PRODUCTS = new BooleanSetting("revanced_hide_tagged_products", TRUE);
86+
public static final BooleanSetting HIDE_SHOPPING_LINKS = new BooleanSetting("revanced_hide_shopping_links", TRUE);
8787
public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_hide_video_ads", TRUE, true);
8888
public static final BooleanSetting HIDE_VIEW_PRODUCTS_BANNER = new BooleanSetting("revanced_hide_view_products_banner", TRUE);
89-
public static final BooleanSetting HIDE_VISIT_STORE_BUTTON = new BooleanSetting("revanced_hide_visit_store_button", TRUE);
9089
public static final BooleanSetting HIDE_WEB_SEARCH_RESULTS = new BooleanSetting("revanced_hide_web_search_results", TRUE);
9190

9291
// Feed
@@ -104,7 +103,6 @@ public class Settings extends BaseSettings {
104103
public static final BooleanSetting HIDE_FILTER_BAR_FEED_IN_RELATED_VIDEOS = new BooleanSetting("revanced_hide_filter_bar_feed_in_related_videos", FALSE, true);
105104
public static final BooleanSetting HIDE_FILTER_BAR_FEED_IN_SEARCH = new BooleanSetting("revanced_hide_filter_bar_feed_in_search", FALSE, true);
106105
public static final BooleanSetting HIDE_FLOATING_MICROPHONE_BUTTON = new BooleanSetting("revanced_hide_floating_microphone_button", TRUE, true);
107-
public static final BooleanSetting HIDE_FOR_YOU_SHELF = new BooleanSetting("revanced_hide_for_you_shelf", TRUE);
108106
public static final BooleanSetting HIDE_HORIZONTAL_SHELVES = new BooleanSetting("revanced_hide_horizontal_shelves", TRUE);
109107
public static final BooleanSetting HIDE_IMAGE_SHELF = new BooleanSetting("revanced_hide_image_shelf", TRUE);
110108
public static final BooleanSetting HIDE_MIX_PLAYLISTS = new BooleanSetting("revanced_hide_mix_playlists", TRUE);
@@ -131,6 +129,12 @@ public class Settings extends BaseSettings {
131129
public static final BooleanSetting HIDE_KEYWORD_CONTENT_SEARCH = new BooleanSetting("revanced_hide_keyword_content_search", FALSE);
132130
public static final StringSetting HIDE_KEYWORD_CONTENT_PHRASES = new StringSetting("revanced_hide_keyword_content_phrases", "",
133131
parentsAny(HIDE_KEYWORD_CONTENT_HOME, HIDE_KEYWORD_CONTENT_SUBSCRIPTIONS, HIDE_KEYWORD_CONTENT_SEARCH));
132+
// Channel page
133+
public static final BooleanSetting HIDE_FOR_YOU_SHELF = new BooleanSetting("revanced_hide_for_you_shelf", FALSE);
134+
public static final BooleanSetting HIDE_LINKS_PREVIEW = new BooleanSetting("revanced_hide_links_preview", TRUE);
135+
public static final BooleanSetting HIDE_MEMBERS_SHELF = new BooleanSetting("revanced_hide_members_shelf", TRUE);
136+
public static final BooleanSetting HIDE_VISIT_COMMUNITY_BUTTON = new BooleanSetting("revanced_hide_visit_community_button", TRUE);
137+
public static final BooleanSetting HIDE_VISIT_STORE_BUTTON = new BooleanSetting("revanced_hide_visit_store_button", TRUE);
134138

135139
// Player
136140
public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE);
@@ -144,13 +148,10 @@ public class Settings extends BaseSettings {
144148
public static final BooleanSetting HIDE_CAST_BUTTON = new BooleanSetting("revanced_hide_cast_button", TRUE, true);
145149
public static final BooleanSetting HIDE_PLAYER_CONTROL_BUTTONS_BACKGROUND = new BooleanSetting("revanced_hide_player_control_buttons_background", FALSE, true);
146150
public static final BooleanSetting HIDE_CHANNEL_BAR = new BooleanSetting("revanced_hide_channel_bar", FALSE);
147-
public static final BooleanSetting HIDE_CHANNEL_MEMBER_SHELF = new BooleanSetting("revanced_hide_channel_member_shelf", TRUE);
148-
public static final BooleanSetting HIDE_COMMUNITY_GUIDELINES = new BooleanSetting("revanced_hide_community_guidelines", TRUE);
149151
public static final BooleanSetting HIDE_EMERGENCY_BOX = new BooleanSetting("revanced_hide_emergency_box", TRUE);
150152
public static final BooleanSetting HIDE_ENDSCREEN_CARDS = new BooleanSetting("revanced_hide_endscreen_cards", FALSE);
151153
public static final BooleanSetting HIDE_END_SCREEN_SUGGESTED_VIDEO = new BooleanSetting("revanced_end_screen_suggested_video", FALSE, true);
152154
public static final BooleanSetting HIDE_RELATED_VIDEO_OVERLAY = new BooleanSetting("revanced_hide_related_video_overlay", FALSE, true);
153-
public static final BooleanSetting HIDE_HIDE_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_channel_guidelines", TRUE);
154155
public static final BooleanSetting HIDE_INFO_PANELS = new BooleanSetting("revanced_hide_info_panels", TRUE);
155156
public static final BooleanSetting HIDE_INFO_CARDS = new BooleanSetting("revanced_hide_info_cards", FALSE);
156157
public static final BooleanSetting HIDE_JOIN_MEMBERSHIP_BUTTON = new BooleanSetting("revanced_hide_join_membership_button", TRUE);
@@ -185,7 +186,9 @@ public class Settings extends BaseSettings {
185186
// Comments
186187
public static final BooleanSetting HIDE_COMMENTS_AI_CHAT_SUMMARY = new BooleanSetting("revanced_hide_comments_ai_chat_summary", FALSE);
187188
public static final BooleanSetting HIDE_COMMENTS_AI_SUMMARY = new BooleanSetting("revanced_hide_comments_ai_summary", FALSE);
189+
public static final BooleanSetting HIDE_COMMENTS_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_comments_channel_guidelines", TRUE);
188190
public static final BooleanSetting HIDE_COMMENTS_BY_MEMBERS_HEADER = new BooleanSetting("revanced_hide_comments_by_members_header", FALSE);
191+
public static final BooleanSetting HIDE_COMMENTS_COMMUNITY_GUIDELINES = new BooleanSetting("revanced_hide_comments_community_guidelines", TRUE);
189192
public static final BooleanSetting HIDE_COMMENTS_CREATE_A_SHORT_BUTTON = new BooleanSetting("revanced_hide_comments_create_a_short_button", TRUE);
190193
public static final BooleanSetting HIDE_COMMENTS_PREVIEW_COMMENT = new BooleanSetting("revanced_hide_comments_preview_comment", FALSE);
191194
public static final BooleanSetting HIDE_COMMENTS_SECTION = new BooleanSetting("revanced_hide_comments_section", FALSE);

patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@ private val hideAdsResourcePatch = resourcePatch {
4343
addResources("youtube", "ad.general.hideAdsResourcePatch")
4444

4545
PreferenceScreen.ADS.addPreferences(
46-
SwitchPreference("revanced_hide_creator_store_shelves"),
46+
SwitchPreference("revanced_hide_creator_store_shelf"),
4747
SwitchPreference("revanced_hide_end_screen_store_banner"),
4848
SwitchPreference("revanced_hide_fullscreen_ads"),
4949
SwitchPreference("revanced_hide_general_ads"),
5050
SwitchPreference("revanced_hide_merchandise_banners"),
5151
SwitchPreference("revanced_hide_paid_promotion_label"),
5252
SwitchPreference("revanced_hide_self_sponsor_ads"),
53-
SwitchPreference("revanced_hide_tagged_products"),
53+
SwitchPreference("revanced_hide_shopping_links"),
5454
SwitchPreference("revanced_hide_view_products_banner"),
55-
SwitchPreference("revanced_hide_visit_store_button"),
5655
SwitchPreference("revanced_hide_web_search_results"),
5756
)
5857

0 commit comments

Comments
 (0)