diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/components/DescriptionsFilter.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/components/DescriptionsFilter.java index fb2224d18..abf9981e3 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/components/DescriptionsFilter.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/components/DescriptionsFilter.java @@ -7,12 +7,15 @@ import app.revanced.extension.shared.patches.components.ByteArrayFilterGroupList import app.revanced.extension.shared.patches.components.Filter; import app.revanced.extension.shared.patches.components.StringFilterGroup; import app.revanced.extension.youtube.settings.Settings; +import app.revanced.extension.youtube.shared.EngagementPanel; +import app.revanced.extension.youtube.shared.RootView; @SuppressWarnings("unused") public final class DescriptionsFilter extends Filter { private final ByteArrayFilterGroupList macroMarkerShelfGroupList = new ByteArrayFilterGroupList(); private final StringFilterGroup howThisWasMadeSection; + private final StringFilterGroup horizontalShelf; private final StringFilterGroup infoCardsSection; private final StringFilterGroup macroMarkerShelf; private final StringFilterGroup shoppingLinks; @@ -54,6 +57,13 @@ public final class DescriptionsFilter extends Filter { "how_this_was_made_section.eml" ); + // In the latest YouTube, the Attribute section has the same path as the Carousel shelf. + // To hide only the Attribute section, check if the Description panel is open. + horizontalShelf = new StringFilterGroup( + Settings.HIDE_ATTRIBUTES_SECTION, + "horizontal_shelf.eml" + ); + infoCardsSection = new StringFilterGroup( Settings.HIDE_INFO_CARDS_SECTION, "infocards_section.eml" @@ -72,6 +82,7 @@ public final class DescriptionsFilter extends Filter { addPathCallbacks( howThisWasMadeSection, + horizontalShelf, infoCardsSection, macroMarkerShelf, shoppingLinks @@ -104,6 +115,16 @@ public final class DescriptionsFilter extends Filter { if (!macroMarkerShelfGroupList.check(protobufBufferArray).isFiltered()) { return false; } + } else if (matchedGroup == horizontalShelf) { + if (contentIndex != 0) { + return false; + } + if (!RootView.isPlayerActive()) { + return false; + } + if (!EngagementPanel.isDescription()) { + return false; + } } return super.isFiltered(path, identifier, allValue, protobufBufferArray, matchedGroup, contentType, contentIndex); diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/shared/EngagementPanel.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/shared/EngagementPanel.java index 11c4b3c8b..9b6fe69fc 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/shared/EngagementPanel.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/shared/EngagementPanel.java @@ -6,7 +6,7 @@ import java.util.concurrent.atomic.AtomicReference; import app.revanced.extension.shared.utils.Logger; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "BooleanMethodIsAlwaysInverted"}) public final class EngagementPanel { private static final AtomicReference engagementPanelId = new AtomicReference<>("");