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

Commit

Permalink
feat(YouTube): Hide player shopping shelf in playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 23, 2024
1 parent ac570aa commit d2487ba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public final class AdsFilter extends Filter {

private final StringTrieSearch exceptions = new StringTrieSearch();

private final StringFilterGroup playerShoppingShelf;
private final ByteArrayFilterGroup playerShoppingShelfBuffer;

private final StringFilterGroup channelProfile;
private final ByteArrayFilterGroup visitStoreButton;

Expand Down Expand Up @@ -110,6 +113,16 @@ public AdsFilter() {
"channel_profile.eml"
);

playerShoppingShelf = new StringFilterGroup(
null,
"horizontal_shelf.eml"
);

playerShoppingShelfBuffer = new ByteArrayFilterGroup(
Settings.HIDE_PLAYER_STORE_SHELF,
"shopping_item_card_list.eml"
);

visitStoreButton = new ByteArrayFilterGroup(
Settings.HIDE_VISIT_STORE_BUTTON,
"header_store_button"
Expand Down Expand Up @@ -140,13 +153,21 @@ public AdsFilter() {
channelProfile,
webLinkPanel,
shoppingLinks,
playerShoppingShelf,
movieAds
);
}

@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (matchedGroup == playerShoppingShelf) {
if (contentIndex == 0 && playerShoppingShelfBuffer.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
return false;
}

if (exceptions.matches(path))
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public LayoutComponentsFilter() {
);

horizontalShelves = new StringFilterGroup(
null, // Multiple settings use this filter.
Settings.HIDE_HORIZONTAL_SHELVES,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml",
"horizontal_shelf_inline.eml",
Expand Down Expand Up @@ -458,18 +458,11 @@ public static void hideShowMoreButton(View view) {
}

private static boolean hideShelves() {
// Video player can show a horizontal shopping shelf below the video.
// It appears this is the only shelf that can appear in the player,
// and no shelves are shown in the recommendations under the video.
if (PlayerType.getCurrent().isMaximizedOrFullscreen()) {
return Settings.HIDE_PLAYER_STORE_SHELF.get();
}

if (!Settings.HIDE_HORIZONTAL_SHELVES.get()) {
return false;
}

if (NavigationBar.isSearchBarActive()) {
// If the player is opened while library is selected,
// then filter any recommendations below the player.
if (PlayerType.getCurrent().isMaximizedOrFullscreen()
// Or if the search is active while library is selected, then also filter.
|| NavigationBar.isSearchBarActive()) {
return true;
}

Expand Down

0 comments on commit d2487ba

Please sign in to comment.