Skip to content

fix(YouTube - Hide Shorts components): Fix hiding of untoggled components #5266

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
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 @@ -44,6 +44,8 @@ public final class ShortsFilter extends Filter {
private final ByteArrayFilterGroup shortsCompactFeedVideoBuffer;
private final StringFilterGroup useSoundButton;
private final ByteArrayFilterGroup useSoundButtonBuffer;
private final StringFilterGroup useTemplateButton;
private final ByteArrayFilterGroup useTemplateButtonBuffer;

private final StringFilterGroup subscribeButton;
private final StringFilterGroup joinButton;
Expand Down Expand Up @@ -178,7 +180,10 @@ public ShortsFilter() {

useSoundButton = new StringFilterGroup(
Settings.HIDE_SHORTS_USE_SOUND_BUTTON,
// First filter needed for "Use this sound" that can appear when viewing Shorts
// through the "Short remixing this video" section.
"floating_action_button.eml",
// Second filter needed for "Use this sound" that can appear below the video title.
REEL_METAPANEL_PATH
);

Expand All @@ -187,6 +192,17 @@ public ShortsFilter() {
"yt_outline_camera_"
);

useTemplateButton = new StringFilterGroup(
Settings.HIDE_SHORTS_USE_TEMPLATE_BUTTON,
// Second filter needed for "Use this template" that can appear below the video title.
REEL_METAPANEL_PATH
);

useTemplateButtonBuffer = new ByteArrayFilterGroup(
null,
"yt_outline_template_add_"
);

videoActionButton = new StringFilterGroup(
null,
// Can be simply 'button.eml', 'shorts_video_action_button.eml' or 'reel_action_button.eml'
Expand All @@ -195,8 +211,7 @@ public ShortsFilter() {

suggestedAction = new StringFilterGroup(
null,
"suggested_action.eml",
REEL_METAPANEL_PATH
"suggested_action.eml"
);

addPathCallbacks(
Expand Down Expand Up @@ -268,6 +283,7 @@ public ShortsFilter() {
),
new ByteArrayFilterGroup(
Settings.HIDE_SHORTS_USE_TEMPLATE_BUTTON,
// "Use this template" can appear in two different places.
"yt_outline_template_add_"
),
new ByteArrayFilterGroup(
Expand Down Expand Up @@ -317,6 +333,10 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
return useSoundButtonBuffer.check(protobufBufferArray).isFiltered();
}

if (matchedGroup == useTemplateButton) {
return useTemplateButtonBuffer.check(protobufBufferArray).isFiltered();
}

if (matchedGroup == shortsCompactFeedVideo) {
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(protobufBufferArray).isFiltered();
}
Expand Down Expand Up @@ -402,17 +422,6 @@ private static boolean shouldHideShortsFeedItems() {
};
}

/**
* Injection point. Only used if patching older than 19.03.
* This hook may be obsolete even for old versions
* as they now use a litho layout like newer versions.
*/
public static void hideShortsShelf(final View shortsShelfView) {
if (shouldHideShortsFeedItems()) {
Utils.hideViewByLayoutParams(shortsShelfView);
}
}

public static int getSoundButtonSize(int original) {
if (Settings.HIDE_SHORTS_SOUND_BUTTON.get()) {
return 0;
Expand Down
Loading