mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-04 00:55:49 +01:00
feat(YouTube): Hide player shopping shelf in playlists (#724)
This commit is contained in:
parent
ac570aabe1
commit
d108f59554
@ -24,6 +24,9 @@ public final class AdsFilter extends Filter {
|
|||||||
|
|
||||||
private final StringTrieSearch exceptions = new StringTrieSearch();
|
private final StringTrieSearch exceptions = new StringTrieSearch();
|
||||||
|
|
||||||
|
private final StringFilterGroup playerShoppingShelf;
|
||||||
|
private final ByteArrayFilterGroup playerShoppingShelfBuffer;
|
||||||
|
|
||||||
private final StringFilterGroup channelProfile;
|
private final StringFilterGroup channelProfile;
|
||||||
private final ByteArrayFilterGroup visitStoreButton;
|
private final ByteArrayFilterGroup visitStoreButton;
|
||||||
|
|
||||||
@ -110,6 +113,16 @@ public final class AdsFilter extends Filter {
|
|||||||
"channel_profile.eml"
|
"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(
|
visitStoreButton = new ByteArrayFilterGroup(
|
||||||
Settings.HIDE_VISIT_STORE_BUTTON,
|
Settings.HIDE_VISIT_STORE_BUTTON,
|
||||||
"header_store_button"
|
"header_store_button"
|
||||||
@ -140,6 +153,7 @@ public final class AdsFilter extends Filter {
|
|||||||
channelProfile,
|
channelProfile,
|
||||||
webLinkPanel,
|
webLinkPanel,
|
||||||
shoppingLinks,
|
shoppingLinks,
|
||||||
|
playerShoppingShelf,
|
||||||
movieAds
|
movieAds
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -147,6 +161,13 @@ public final class AdsFilter extends Filter {
|
|||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
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))
|
if (exceptions.matches(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
);
|
);
|
||||||
|
|
||||||
horizontalShelves = new StringFilterGroup(
|
horizontalShelves = new StringFilterGroup(
|
||||||
null, // Multiple settings use this filter.
|
Settings.HIDE_HORIZONTAL_SHELVES,
|
||||||
"horizontal_video_shelf.eml",
|
"horizontal_video_shelf.eml",
|
||||||
"horizontal_shelf.eml",
|
"horizontal_shelf.eml",
|
||||||
"horizontal_shelf_inline.eml",
|
"horizontal_shelf_inline.eml",
|
||||||
@ -458,18 +458,11 @@ public final class LayoutComponentsFilter extends Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hideShelves() {
|
private static boolean hideShelves() {
|
||||||
// Video player can show a horizontal shopping shelf below the video.
|
// If the player is opened while library is selected,
|
||||||
// It appears this is the only shelf that can appear in the player,
|
// then filter any recommendations below the player.
|
||||||
// and no shelves are shown in the recommendations under the video.
|
if (PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||||
if (PlayerType.getCurrent().isMaximizedOrFullscreen()) {
|
// Or if the search is active while library is selected, then also filter.
|
||||||
return Settings.HIDE_PLAYER_STORE_SHELF.get();
|
|| NavigationBar.isSearchBarActive()) {
|
||||||
}
|
|
||||||
|
|
||||||
if (!Settings.HIDE_HORIZONTAL_SHELVES.get()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NavigationBar.isSearchBarActive()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user