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

fix(YouTube - Hide Shorts): Hide Shorts in feed when using tablet layout #572

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 @@ -17,6 +17,9 @@ public final class ShortsFilter extends Filter {
public static PivotBar pivotBar; // Set by patch.
private final String REEL_CHANNEL_BAR_PATH = "reel_channel_bar.eml";

private final StringFilterGroup shortsCompactFeedVideoPath;
private final ByteArrayFilterGroup shortsCompactFeedVideoBuffer;

private final StringFilterGroup channelBar;
private final StringFilterGroup subscribeButton;
private final StringFilterGroup subscribeButtonPaused;
Expand All @@ -35,7 +38,6 @@ public ShortsFilter() {
"shorts_grid",
"shorts_video_cell",
"shorts_pivot_item"

);
// Feed Shorts shelf header.
// Use a different filter group for this pattern, as it requires an additional check after matching.
Expand All @@ -52,6 +54,15 @@ public ShortsFilter() {

addIdentifierCallbacks(shorts, shelfHeader, thanksButton);

// Shorts that appear in the feed/search when the device is using tablet layout.
shortsCompactFeedVideoPath = new StringFilterGroup(Settings.HIDE_SHORTS,
"compact_video.eml");
// Filter out items that use the 'frame0' thumbnail.
// This is a valid thumbnail for both regular videos and Shorts,
// but it appears these thumbnails are used only for Shorts.
shortsCompactFeedVideoBuffer = new ByteArrayFilterGroup(Settings.HIDE_SHORTS,
"/frame0.jpg");

// Shorts player components.
var joinButton = new StringFilterGroup(
Settings.HIDE_SHORTS_JOIN_BUTTON,
Expand Down Expand Up @@ -89,6 +100,7 @@ public ShortsFilter() {
);

addPathCallbacks(
shortsCompactFeedVideoPath,
joinButton, subscribeButton, subscribeButtonPaused,
channelBar, soundButton, infoPanel, videoActionButton
);
Expand Down Expand Up @@ -122,6 +134,13 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
matchedGroup == subscribeButtonPaused
) return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);

if (matchedGroup == shortsCompactFeedVideoPath) {
if (contentIndex == 0 && shortsCompactFeedVideoBuffer.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
return false;
}

// Video action buttons (comment, share, remix) have the same path.
if (matchedGroup == videoActionButton) {
if (videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) return super.isFiltered(
Expand All @@ -132,10 +151,11 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff

// Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible
// to avoid false positives.
if (path.startsWith(REEL_CHANNEL_BAR_PATH))
if (matchedGroup == subscribeButton) return super.isFiltered(
if (matchedGroup == subscribeButton) {
if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered(
identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex
);
}

return false;
} else if (matchedGroup == shelfHeader) {
Expand Down
Loading