Skip to content

Commit ffff45a

Browse files
fix(YouTube - Hide Shorts components): Resolve "Hide 'Use this sound' button" and "Hide 'Use this template' button" breaking Shorts player (#830)
1 parent 0202d57 commit ffff45a

1 file changed

Lines changed: 28 additions & 42 deletions

File tree

  • extensions/youtube/src/main/java/app/morphe/extension/youtube/patches/components

extensions/youtube/src/main/java/app/morphe/extension/youtube/patches/components/ShortsFilter.java

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ public final class ShortsFilter extends Filter {
7373
private final StringFilterGroup shortsCompactFeedVideo;
7474
private final ByteArrayFilterGroup shortsCompactFeedVideoBuffer;
7575
private final StringFilterGroup channelProfile;
76-
private final StringFilterGroup useSoundButton;
77-
private final ByteArrayFilterGroup useSoundButtonBuffer;
78-
private final StringFilterGroup useTemplateButton;
79-
private final ByteArrayFilterGroup useTemplateButtonBuffer;
8076

8177
private final StringFilterGroup autoDubbedLabel;
8278
private final StringFilterGroup subscribeButton;
@@ -91,6 +87,9 @@ public final class ShortsFilter extends Filter {
9187
private final StringFilterGroup suggestedAction;
9288
private final ByteArrayFilterGroupList suggestedActionsBuffer = new ByteArrayFilterGroupList();
9389

90+
private final StringFilterGroup useButtons;
91+
private final ByteArrayFilterGroupList useButtonsBuffer = new ByteArrayFilterGroupList();
92+
9493
private final StringFilterGroup shortsActionBar;
9594
private final StringFilterGroup shortsActionButton;
9695
private final StringFilterGroupList shortsActionButtonGroupList = new StringFilterGroupList();
@@ -266,35 +265,6 @@ public ShortsFilter() {
266265
)
267266
);
268267

269-
useSoundButton = new StringFilterGroup(
270-
Settings.HIDE_SHORTS_USE_SOUND_BUTTON,
271-
// First filter needed for "Use this sound" that can appear when viewing Shorts
272-
// through the "Short remixing this video" section.
273-
"floating_action_button.e",
274-
// Second filter needed for "Use this sound" that can appear below the video title.
275-
REEL_METAPANEL_PATH,
276-
REEL_PLAYER_OVERLAY_PATH
277-
);
278-
279-
useSoundButtonBuffer = new ByteArrayFilterGroup(
280-
null,
281-
"yt_outline_camera_",
282-
"yt_outline_experimental_camera_"
283-
);
284-
285-
useTemplateButton = new StringFilterGroup(
286-
Settings.HIDE_SHORTS_USE_TEMPLATE_BUTTON,
287-
// Second filter needed for "Use this template" that can appear below the video title.
288-
REEL_METAPANEL_PATH,
289-
REEL_PLAYER_OVERLAY_PATH
290-
);
291-
292-
useTemplateButtonBuffer = new ByteArrayFilterGroup(
293-
null,
294-
"yt_outline_template_add_",
295-
"yt_outline_experimental_template_add_"
296-
);
297-
298268
shortsActionButton = new StringFilterGroup(
299269
null,
300270
// Can be any of:
@@ -305,6 +275,26 @@ public ShortsFilter() {
305275
"button.e"
306276
);
307277

278+
useButtons = new StringFilterGroup(
279+
null,
280+
REEL_PLAYER_OVERLAY_PATH,
281+
REEL_METAPANEL_PATH,
282+
"floating_action_button.e"
283+
);
284+
285+
useButtonsBuffer.addAll(
286+
new ByteArrayFilterGroup(
287+
Settings.HIDE_SHORTS_USE_SOUND_BUTTON,
288+
"yt_outline_camera_",
289+
"yt_outline_experimental_camera_"
290+
),
291+
new ByteArrayFilterGroup(
292+
Settings.HIDE_SHORTS_USE_TEMPLATE_BUTTON,
293+
"yt_outline_template_add_",
294+
"yt_outline_experimental_template_add_"
295+
)
296+
);
297+
308298
suggestedAction = new StringFilterGroup(
309299
null,
310300
"suggested_action.e"
@@ -313,7 +303,7 @@ public ShortsFilter() {
313303
addPathCallbacks(
314304
shortsCompactFeedVideo, shelfHeaderPath, joinButton, subscribeButton, paidPromotionLabel,
315305
livePreview, suggestedAction, pausedOverlayButtons, channelBar, infoPanel, previewComment,
316-
autoDubbedLabel, fullVideoLinkLabel, videoTitle, useSoundButton, soundButton, stickers,
306+
autoDubbedLabel, fullVideoLinkLabel, videoTitle, soundButton, stickers, useButtons,
317307
reelCarousel, reelSoundMetadata, likeFountain, likeButton, dislikeButton, shortsActionBar
318308
);
319309

@@ -453,14 +443,6 @@ boolean isFiltered(String identifier, String accessibility, String path, byte[]
453443
return reelCarouselBuffer.check(buffer).isFiltered();
454444
}
455445

456-
if (matchedGroup == useSoundButton) {
457-
return useSoundButtonBuffer.check(buffer).isFiltered();
458-
}
459-
460-
if (matchedGroup == useTemplateButton) {
461-
return useTemplateButtonBuffer.check(buffer).isFiltered();
462-
}
463-
464446
if (matchedGroup == shortsCompactFeedVideo) {
465447
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(buffer).isFiltered();
466448
}
@@ -484,6 +466,10 @@ boolean isFiltered(String identifier, String accessibility, String path, byte[]
484466
return false;
485467
}
486468

469+
if (matchedGroup == useButtons) {
470+
return path.contains("button.e") && useButtonsBuffer.check(buffer).isFiltered();
471+
}
472+
487473
if (matchedGroup == suggestedAction) {
488474
// Skip searching the buffer if all suggested actions are set to hidden.
489475
// This has a secondary effect of hiding all new un-identified actions

0 commit comments

Comments
 (0)