Skip to content

fix(YouTube - Hide Shorts components): Fix "Hide Use this sound button" #5233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ public final class ShortsFilter extends Filter {

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

private final StringFilterGroup shortsCompactFeedVideoPath;
private final StringFilterGroup shortsCompactFeedVideo;
private final ByteArrayFilterGroup shortsCompactFeedVideoBuffer;
private final StringFilterGroup useSoundButton;
private final ByteArrayFilterGroup useSoundButtonBuffer;

private final StringFilterGroup subscribeButton;
private final StringFilterGroup joinButton;
private final StringFilterGroup paidPromotionButton;
private final StringFilterGroup shelfHeader;

private final StringFilterGroup suggestedAction;
private final ByteArrayFilterGroupList suggestedActionsGroupList = new ByteArrayFilterGroupList();
private final ByteArrayFilterGroupList suggestedActionsBuffer = new ByteArrayFilterGroupList();

private final StringFilterGroup shortsActionBar;
private final StringFilterGroup actionButton;
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();
private final StringFilterGroup videoActionButton;
private final ByteArrayFilterGroupList videoActionButtonBuffer = new ByteArrayFilterGroupList();

public ShortsFilter() {
//
Expand Down Expand Up @@ -82,7 +84,7 @@ public ShortsFilter() {
// Path components.
//

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

actionButton = new StringFilterGroup(
useSoundButton = new StringFilterGroup(
Settings.HIDE_SHORTS_USE_SOUND_BUTTON,
"floating_action_button.eml",
REEL_METAPANEL_PATH
);

useSoundButtonBuffer = new ByteArrayFilterGroup(
null,
"yt_outline_camera_"
);

videoActionButton = new StringFilterGroup(
null,
// Can be simply 'button.eml', 'shorts_video_action_button.eml' or 'reel_action_button.eml'
"button.eml"
Expand All @@ -186,16 +199,16 @@ public ShortsFilter() {
);

addPathCallbacks(
shortsCompactFeedVideoPath, joinButton, subscribeButton, paidPromotionButton,
shortsCompactFeedVideo, joinButton, subscribeButton, paidPromotionButton,
shortsActionBar, suggestedAction, pausedOverlayButtons, channelBar,
fullVideoLinkLabel, videoTitle, reelSoundMetadata, soundButton, infoPanel,
fullVideoLinkLabel, videoTitle, useSoundButton, reelSoundMetadata, soundButton, infoPanel,
stickers, likeFountain, likeButton, dislikeButton
);

//
// All other action buttons.
//
videoActionButtonGroupList.addAll(
videoActionButtonBuffer.addAll(
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_COMMENTS_BUTTON,
"reel_comment_button",
Expand All @@ -216,7 +229,7 @@ public ShortsFilter() {
//
// Suggested actions.
//
suggestedActionsGroupList.addAll(
suggestedActionsBuffer.addAll(
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_PREVIEW_COMMENT,
// Preview comment that can popup while a Short is playing.
Expand All @@ -242,10 +255,7 @@ public ShortsFilter() {
"yt_outline_bookmark_",
// 'Save sound' button. It seems this has been removed and only 'Save music' is used.
// Still hide this in case it's still present.
"yt_outline_list_add_",
// 'Use this sound' button. It seems this has been removed and only 'Save music' is used.
// Still hide this in case it's still present.
"yt_outline_camera_"
"yt_outline_list_add_"
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_SEARCH_SUGGESTIONS,
Expand Down Expand Up @@ -279,7 +289,7 @@ public ShortsFilter() {
}

private boolean isEverySuggestedActionFilterEnabled() {
for (ByteArrayFilterGroup group : suggestedActionsGroupList) {
for (ByteArrayFilterGroup group : suggestedActionsBuffer) {
if (!group.isEnabled()) {
return false;
}
Expand All @@ -297,15 +307,19 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
return path.startsWith(REEL_CHANNEL_BAR_PATH) || path.startsWith(REEL_METAPANEL_PATH);
}

if (matchedGroup == shortsCompactFeedVideoPath) {
if (matchedGroup == useSoundButton) {
return useSoundButtonBuffer.check(protobufBufferArray).isFiltered();
}

if (matchedGroup == shortsCompactFeedVideo) {
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(protobufBufferArray).isFiltered();
}

// Video action buttons (comment, share, remix) have the same path.
// Like and dislike are separate path filters and don't require buffer searching.
if (matchedGroup == shortsActionBar) {
return actionButton.check(path).isFiltered()
&& videoActionButtonGroupList.check(protobufBufferArray).isFiltered();
return videoActionButton.check(path).isFiltered()
&& videoActionButtonBuffer.check(protobufBufferArray).isFiltered();
}

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

return suggestedActionsGroupList.check(protobufBufferArray).isFiltered();
return suggestedActionsBuffer.check(protobufBufferArray).isFiltered();
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_SHORTS_SUPER_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_super_thanks_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_TAGGED_PRODUCTS = new BooleanSetting("revanced_hide_shorts_tagged_products", TRUE);
public static final BooleanSetting HIDE_SHORTS_UPCOMING_BUTTON = new BooleanSetting("revanced_hide_shorts_upcoming_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_USE_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_use_sound_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_USE_TEMPLATE_BUTTON = new BooleanSetting("revanced_hide_shorts_use_template_button", TRUE);
public static final BooleanSetting HIDE_SHORTS_VIDEO_TITLE = new BooleanSetting("revanced_hide_shorts_video_title", FALSE);
public static final BooleanSetting SHORTS_AUTOPLAY = new BooleanSetting("revanced_shorts_autoplay", FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
// Suggested actions.
SwitchPreference("revanced_hide_shorts_preview_comment"),
SwitchPreference("revanced_hide_shorts_save_sound_button"),
SwitchPreference("revanced_hide_shorts_use_sound_button"),
SwitchPreference("revanced_hide_shorts_use_template_button"),
SwitchPreference("revanced_hide_shorts_upcoming_button"),
SwitchPreference("revanced_hide_shorts_green_screen_button"),
Expand Down
9 changes: 6 additions & 3 deletions patches/src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,12 @@ To show the Audio track menu, change \'Spoof video streams\' to iOS TV"</string>
<string name="revanced_hide_shorts_save_sound_button_title">Hide Save music button</string>
<string name="revanced_hide_shorts_save_sound_button_summary_on">Save music button is hidden</string>
<string name="revanced_hide_shorts_save_sound_button_summary_off">Save music button is shown</string>
<string name="revanced_hide_shorts_use_template_button_title">Hide Use template button</string>
<string name="revanced_hide_shorts_use_template_button_summary_on">Use template button is hidden</string>
<string name="revanced_hide_shorts_use_template_button_summary_off">Use template button is shown</string>
<string name="revanced_hide_shorts_use_sound_button_title">Hide Use this sound button</string>
<string name="revanced_hide_shorts_use_sound_button_summary_on">Use this sound button is hidden</string>
<string name="revanced_hide_shorts_use_sound_button_summary_off">Use this sound button is shown</string>
<string name="revanced_hide_shorts_use_template_button_title">Hide Use this template button</string>
<string name="revanced_hide_shorts_use_template_button_summary_on">Use this template button is hidden</string>
<string name="revanced_hide_shorts_use_template_button_summary_off">Use this template button is shown</string>
<string name="revanced_hide_shorts_upcoming_button_title">Hide Upcoming button</string>
<string name="revanced_hide_shorts_upcoming_button_summary_on">Upcoming button is hidden</string>
<string name="revanced_hide_shorts_upcoming_button_summary_off">Upcoming button is shown</string>
Expand Down