feat(YouTube): Hide player shopping shelf in playlists (#724)

This commit is contained in:
LisoUseInAIKyrios 2024-10-22 23:55:53 -04:00 committed by GitHub
parent ac570aabe1
commit d108f59554
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 13 deletions

View File

@ -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;
@ -110,6 +113,16 @@ public final class AdsFilter extends Filter {
"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"
@ -140,6 +153,7 @@ public final class AdsFilter extends Filter {
channelProfile,
webLinkPanel,
shoppingLinks,
playerShoppingShelf,
movieAds
);
}
@ -147,6 +161,13 @@ public final class AdsFilter extends Filter {
@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;

View File

@ -251,7 +251,7 @@ public final class LayoutComponentsFilter extends Filter {
);
horizontalShelves = new StringFilterGroup(
null, // Multiple settings use this filter.
Settings.HIDE_HORIZONTAL_SHELVES,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml",
"horizontal_shelf_inline.eml",
@ -458,18 +458,11 @@ public final class LayoutComponentsFilter extends Filter {
}
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;
}