Skip to content

Commit 5d6ec9e

Browse files
fix(YouTube - Hide Shorts components): Fix "Hide Use this sound button" (#5233)
1 parent 9b96576 commit 5d6ec9e

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

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

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ public final class ShortsFilter extends Filter {
4040

4141
private static WeakReference<PivotBar> pivotBarRef = new WeakReference<>(null);
4242

43-
private final StringFilterGroup shortsCompactFeedVideoPath;
43+
private final StringFilterGroup shortsCompactFeedVideo;
4444
private final ByteArrayFilterGroup shortsCompactFeedVideoBuffer;
45+
private final StringFilterGroup useSoundButton;
46+
private final ByteArrayFilterGroup useSoundButtonBuffer;
4547

4648
private final StringFilterGroup subscribeButton;
4749
private final StringFilterGroup joinButton;
4850
private final StringFilterGroup paidPromotionButton;
4951
private final StringFilterGroup shelfHeader;
5052

5153
private final StringFilterGroup suggestedAction;
52-
private final ByteArrayFilterGroupList suggestedActionsGroupList = new ByteArrayFilterGroupList();
54+
private final ByteArrayFilterGroupList suggestedActionsBuffer = new ByteArrayFilterGroupList();
5355

5456
private final StringFilterGroup shortsActionBar;
55-
private final StringFilterGroup actionButton;
56-
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();
57+
private final StringFilterGroup videoActionButton;
58+
private final ByteArrayFilterGroupList videoActionButtonBuffer = new ByteArrayFilterGroupList();
5759

5860
public ShortsFilter() {
5961
//
@@ -82,7 +84,7 @@ public ShortsFilter() {
8284
// Path components.
8385
//
8486

85-
shortsCompactFeedVideoPath = new StringFilterGroup(null,
87+
shortsCompactFeedVideo = new StringFilterGroup(null,
8688
// Shorts that appear in the feed/search when the device is using tablet layout.
8789
"compact_video.eml",
8890
// 'video_lockup_with_attachment.eml' is shown instead of 'compact_video.eml' for some users
@@ -174,7 +176,18 @@ public ShortsFilter() {
174176
"reel_action_bar.eml"
175177
);
176178

177-
actionButton = new StringFilterGroup(
179+
useSoundButton = new StringFilterGroup(
180+
Settings.HIDE_SHORTS_USE_SOUND_BUTTON,
181+
"floating_action_button.eml",
182+
REEL_METAPANEL_PATH
183+
);
184+
185+
useSoundButtonBuffer = new ByteArrayFilterGroup(
186+
null,
187+
"yt_outline_camera_"
188+
);
189+
190+
videoActionButton = new StringFilterGroup(
178191
null,
179192
// Can be simply 'button.eml', 'shorts_video_action_button.eml' or 'reel_action_button.eml'
180193
"button.eml"
@@ -186,16 +199,16 @@ public ShortsFilter() {
186199
);
187200

188201
addPathCallbacks(
189-
shortsCompactFeedVideoPath, joinButton, subscribeButton, paidPromotionButton,
202+
shortsCompactFeedVideo, joinButton, subscribeButton, paidPromotionButton,
190203
shortsActionBar, suggestedAction, pausedOverlayButtons, channelBar,
191-
fullVideoLinkLabel, videoTitle, reelSoundMetadata, soundButton, infoPanel,
204+
fullVideoLinkLabel, videoTitle, useSoundButton, reelSoundMetadata, soundButton, infoPanel,
192205
stickers, likeFountain, likeButton, dislikeButton
193206
);
194207

195208
//
196209
// All other action buttons.
197210
//
198-
videoActionButtonGroupList.addAll(
211+
videoActionButtonBuffer.addAll(
199212
new ByteArrayFilterGroup(
200213
Settings.HIDE_SHORTS_COMMENTS_BUTTON,
201214
"reel_comment_button",
@@ -216,7 +229,7 @@ public ShortsFilter() {
216229
//
217230
// Suggested actions.
218231
//
219-
suggestedActionsGroupList.addAll(
232+
suggestedActionsBuffer.addAll(
220233
new ByteArrayFilterGroup(
221234
Settings.HIDE_SHORTS_PREVIEW_COMMENT,
222235
// Preview comment that can popup while a Short is playing.
@@ -242,10 +255,7 @@ public ShortsFilter() {
242255
"yt_outline_bookmark_",
243256
// 'Save sound' button. It seems this has been removed and only 'Save music' is used.
244257
// Still hide this in case it's still present.
245-
"yt_outline_list_add_",
246-
// 'Use this sound' button. It seems this has been removed and only 'Save music' is used.
247-
// Still hide this in case it's still present.
248-
"yt_outline_camera_"
258+
"yt_outline_list_add_"
249259
),
250260
new ByteArrayFilterGroup(
251261
Settings.HIDE_SHORTS_SEARCH_SUGGESTIONS,
@@ -279,7 +289,7 @@ public ShortsFilter() {
279289
}
280290

281291
private boolean isEverySuggestedActionFilterEnabled() {
282-
for (ByteArrayFilterGroup group : suggestedActionsGroupList) {
292+
for (ByteArrayFilterGroup group : suggestedActionsBuffer) {
283293
if (!group.isEnabled()) {
284294
return false;
285295
}
@@ -297,15 +307,19 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
297307
return path.startsWith(REEL_CHANNEL_BAR_PATH) || path.startsWith(REEL_METAPANEL_PATH);
298308
}
299309

300-
if (matchedGroup == shortsCompactFeedVideoPath) {
310+
if (matchedGroup == useSoundButton) {
311+
return useSoundButtonBuffer.check(protobufBufferArray).isFiltered();
312+
}
313+
314+
if (matchedGroup == shortsCompactFeedVideo) {
301315
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(protobufBufferArray).isFiltered();
302316
}
303317

304318
// Video action buttons (comment, share, remix) have the same path.
305319
// Like and dislike are separate path filters and don't require buffer searching.
306320
if (matchedGroup == shortsActionBar) {
307-
return actionButton.check(path).isFiltered()
308-
&& videoActionButtonGroupList.check(protobufBufferArray).isFiltered();
321+
return videoActionButton.check(path).isFiltered()
322+
&& videoActionButtonBuffer.check(protobufBufferArray).isFiltered();
309323
}
310324

311325
if (matchedGroup == suggestedAction) {
@@ -316,7 +330,7 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
316330
return true;
317331
}
318332

319-
return suggestedActionsGroupList.check(protobufBufferArray).isFiltered();
333+
return suggestedActionsBuffer.check(protobufBufferArray).isFiltered();
320334
}
321335

322336
return true;

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
@@ -293,6 +293,7 @@ public class Settings extends BaseSettings {
293293
public static final BooleanSetting HIDE_SHORTS_SUPER_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_super_thanks_button", TRUE);
294294
public static final BooleanSetting HIDE_SHORTS_TAGGED_PRODUCTS = new BooleanSetting("revanced_hide_shorts_tagged_products", TRUE);
295295
public static final BooleanSetting HIDE_SHORTS_UPCOMING_BUTTON = new BooleanSetting("revanced_hide_shorts_upcoming_button", TRUE);
296+
public static final BooleanSetting HIDE_SHORTS_USE_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_use_sound_button", TRUE);
296297
public static final BooleanSetting HIDE_SHORTS_USE_TEMPLATE_BUTTON = new BooleanSetting("revanced_hide_shorts_use_template_button", TRUE);
297298
public static final BooleanSetting HIDE_SHORTS_VIDEO_TITLE = new BooleanSetting("revanced_hide_shorts_video_title", FALSE);
298299
public static final BooleanSetting SHORTS_AUTOPLAY = new BooleanSetting("revanced_shorts_autoplay", FALSE);

patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
9494
// Suggested actions.
9595
SwitchPreference("revanced_hide_shorts_preview_comment"),
9696
SwitchPreference("revanced_hide_shorts_save_sound_button"),
97+
SwitchPreference("revanced_hide_shorts_use_sound_button"),
9798
SwitchPreference("revanced_hide_shorts_use_template_button"),
9899
SwitchPreference("revanced_hide_shorts_upcoming_button"),
99100
SwitchPreference("revanced_hide_shorts_green_screen_button"),

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,12 @@ To show the Audio track menu, change \'Spoof video streams\' to iOS TV"</string>
822822
<string name="revanced_hide_shorts_save_sound_button_title">Hide Save music button</string>
823823
<string name="revanced_hide_shorts_save_sound_button_summary_on">Save music button is hidden</string>
824824
<string name="revanced_hide_shorts_save_sound_button_summary_off">Save music button is shown</string>
825-
<string name="revanced_hide_shorts_use_template_button_title">Hide Use template button</string>
826-
<string name="revanced_hide_shorts_use_template_button_summary_on">Use template button is hidden</string>
827-
<string name="revanced_hide_shorts_use_template_button_summary_off">Use template button is shown</string>
825+
<string name="revanced_hide_shorts_use_sound_button_title">Hide Use this sound button</string>
826+
<string name="revanced_hide_shorts_use_sound_button_summary_on">Use this sound button is hidden</string>
827+
<string name="revanced_hide_shorts_use_sound_button_summary_off">Use this sound button is shown</string>
828+
<string name="revanced_hide_shorts_use_template_button_title">Hide Use this template button</string>
829+
<string name="revanced_hide_shorts_use_template_button_summary_on">Use this template button is hidden</string>
830+
<string name="revanced_hide_shorts_use_template_button_summary_off">Use this template button is shown</string>
828831
<string name="revanced_hide_shorts_upcoming_button_title">Hide Upcoming button</string>
829832
<string name="revanced_hide_shorts_upcoming_button_summary_on">Upcoming button is hidden</string>
830833
<string name="revanced_hide_shorts_upcoming_button_summary_off">Upcoming button is shown</string>

0 commit comments

Comments
 (0)