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

Commit

Permalink
fix(YouTube - Hide feed components): Rollback CarouselShelfFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
anddea committed Nov 10, 2024
1 parent 74d26e5 commit 15dff30
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import app.revanced.integrations.shared.patches.components.Filter;
import app.revanced.integrations.shared.patches.components.StringFilterGroup;
import app.revanced.integrations.shared.utils.Logger;
import app.revanced.integrations.shared.utils.StringTrieSearch;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.youtube.shared.NavigationBar.NavigationButton;
import app.revanced.integrations.youtube.shared.RootView;
Expand All @@ -33,16 +34,25 @@ public final class CarouselShelfFilter extends Filter {
BROWSE_ID_NOTIFICATION_INBOX
);

private final StringTrieSearch exceptions = new StringTrieSearch();
public final StringFilterGroup horizontalShelf;

public CarouselShelfFilter() {
addPathCallbacks(
new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml",
"horizontal_shelf_inline.eml",
"horizontal_tile_shelf.eml"
)
exceptions.addPattern("library_recent_shelf.eml");

final StringFilterGroup carouselShelf = new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_shelf_inline.eml",
"horizontal_tile_shelf.eml",
"horizontal_video_shelf.eml"
);

horizontalShelf = new StringFilterGroup(
Settings.HIDE_CAROUSEL_SHELF,
"horizontal_shelf.eml"
);

addPathCallbacks(carouselShelf, horizontalShelf);
}

private static boolean hideShelves(boolean playerActive, boolean searchBarActive, NavigationButton selectedNavButton, String browseId) {
Expand All @@ -64,12 +74,15 @@ private static boolean hideShelves(boolean playerActive, boolean searchBarActive
@Override
public boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (exceptions.matches(path)) {
return false;
}
final boolean playerActive = RootView.isPlayerActive();
final boolean searchBarActive = RootView.isSearchBarActive();
final NavigationButton navigationButton = NavigationButton.getSelectedNavigationButton();
final String navigation = navigationButton == null ? "null" : navigationButton.name();
final String browseId = RootView.getBrowseId();
final boolean hideShelves = hideShelves(playerActive, searchBarActive, navigationButton, browseId);
final boolean hideShelves = matchedGroup != horizontalShelf || hideShelves(playerActive, searchBarActive, navigationButton, browseId);
if (contentIndex != 0) {
return false;
}
Expand Down

0 comments on commit 15dff30

Please sign in to comment.