Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Hide Shorts components): Channel headers were hidden if…
Browse files Browse the repository at this point in the history
… Shorts is disabled

Fixes anddea/revanced-patches#426
  • Loading branch information
anddea committed May 7, 2024
1 parent ac46e4d commit 5451719
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class ShortsFilter extends Filter {
// Disabled comments button or with label "0"
// won't have any number in protobuf, so it will be filtered out
private static final Pattern REEL_COMMENTS_DISABLED_PATTERN = Pattern.compile("reel_comment_button.+\\d+");
private static final Pattern SHORTS_HEADER_PATTERN = Pattern.compile("Shorts.+eml.shelf_header");
private static final String SHORTS_SHELF_HEADER_CONVERSION_CONTEXT = "horizontalCollectionSwipeProtector=null";

private final StringFilterGroup shortsCompactFeedVideoPath;
Expand Down Expand Up @@ -64,12 +65,12 @@ public ShortsFilter() {
"shorts_shelf",
"inline_shorts",
"shorts_grid",
"shorts_pivot_item", // Shorts pivot item in Channel Home tab
"shorts_video_cell"
);


identifierFilterGroupList.addAll(
shelfHeader,
shorts
);

Expand Down Expand Up @@ -152,6 +153,7 @@ public ShortsFilter() {
paidPromotion,
pausedOverlayButtons,
reelSoundMetadata,
shelfHeader,
shortsCompactFeedVideoPath,
subscribeButton,
suggestedAction,
Expand Down Expand Up @@ -250,6 +252,18 @@ boolean isFiltered(String path, @Nullable String identifier, String allValue, by
return false;
}

if (matchedGroup == shelfHeader) {
if (!shouldHideShortsFeedItems()) return false;

String protobufString = new String(protobufBufferArray).replaceAll("\\s+", " ");

// The headers for the channel (Home tab) sections are hidden if Shorts are disabled.
// For now, the regular expression is used to hide the header only if this header contains "Shorts".
// A potential issue: if there is "Shorts" in the title of a section provided by channel itself
// (for example, the title of a playlist containing "Shorts"), it will also be hidden.
return SHORTS_HEADER_PATTERN.matcher(protobufString).find();
}

if (matchedGroup == infoPanel || matchedGroup == videoLinkLabel ||
matchedGroup == videoTitle || matchedGroup == reelSoundMetadata ||
matchedGroup == liveHeader) {
Expand Down Expand Up @@ -277,13 +291,6 @@ boolean isFiltered(String path, @Nullable String identifier, String allValue, by
return path.startsWith(REEL_CHANNEL_BAR_PATH);
}
} else {
// Feed/search path components.
if (matchedGroup == shelfHeader) {
// Because the header is used in watch history and possibly other places, check for the index,
// which is 0 when the shelf header is used for Shorts.
if (matchedIndex != 0) return false;
}

if (!shouldHideShortsFeedItems()) return false;
}

Expand Down

0 comments on commit 5451719

Please sign in to comment.