From acfa3c98868b6d84572ee682ad806a0282ac6dad Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Fri, 12 Apr 2024 23:43:51 +0400 Subject: [PATCH] feat(YouTube - Hide Shorts components): Hide `Shop`, `Location` and `Save sound to playlist` buttons (#614) --- .../patches/components/ShortsFilter.java | 57 ++++++++++++++++--- .../youtube/settings/Settings.java | 3 + 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java index 039cb9d1..05835b50 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ShortsFilter.java @@ -33,11 +33,16 @@ public final class ShortsFilter extends Filter { private final StringFilterGroup joinButton; private final StringFilterGroup shelfHeader; + private final StringFilterGroup suggestedActionPath; + private final ByteArrayFilterGroupList suggestedActions = new ByteArrayFilterGroupList(); + private final StringFilterGroup actionBar; private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList(); public ShortsFilter() { + // // Identifier components. + // var shorts = new StringFilterGroup( null, // Setting is based on navigation state. @@ -55,14 +60,17 @@ public final class ShortsFilter extends Filter { ); // Home / subscription feed components. - var thanksButton = new StringFilterGroup( + + var thanksButton = new StringFilterGroup( // Edit: Does this item show up anymore? Settings.HIDE_SHORTS_THANKS_BUTTON, "suggested_action" ); addIdentifierCallbacks(shorts, shelfHeader, thanksButton); + // // Path components. + // // Shorts that appear in the feed/search when the device is using tablet layout. shortsCompactFeedVideoPath = new StringFilterGroup(null, "compact_video.eml"); @@ -122,13 +130,21 @@ public final class ShortsFilter extends Filter { "shorts_action_bar" ); + suggestedActionPath = new StringFilterGroup( + null, + "suggested_action.eml" + ); + addPathCallbacks( shortsCompactFeedVideoPath, - joinButton, subscribeButton, subscribeButtonPaused, + joinButton, subscribeButton, subscribeButtonPaused, suggestedActionPath, channelBar, fullVideoLinkLabel, videoTitle, reelSoundMetadata, soundButton, infoPanel, actionBar ); + // + // Action buttons + // var shortsLikeButton = new ByteArrayFilterGroup( Settings.HIDE_SHORTS_LIKE_BUTTON, "shorts_like_button" @@ -161,6 +177,24 @@ public final class ShortsFilter extends Filter { shortsShareButton, shortsRemixButton ); + + // + // Suggested actions. + // + suggestedActions.addAll( + new ByteArrayFilterGroup( + Settings.HIDE_SHORTS_SHOP_BUTTON, + "yt_outline_bag_" + ), + new ByteArrayFilterGroup( + Settings.HIDE_SHORTS_LOCATION_BUTTON, + "yt_outline_location_point_" + ), + new ByteArrayFilterGroup( + Settings.HIDE_SHORTS_SAVE_SOUND_BUTTON, + "yt_outline_list_add_" + ) + ); } @Override @@ -185,6 +219,14 @@ public final class ShortsFilter extends Filter { return false; } + if (matchedGroup == subscribeButton || matchedGroup == joinButton) { + // Filter only when reelChannelBar is visible to avoid false positives. + if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered( + identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex + ); + return false; + } + // Video action buttons (like, dislike, comment, share, remix) have the same path. if (matchedGroup == actionBar) { if (videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) return super.isFiltered( @@ -193,14 +235,11 @@ public final class ShortsFilter extends Filter { return false; } - // Filter other path groups from pathFilterGroupList, only when reelChannelBar is visible - // to avoid false positives. - if (matchedGroup == subscribeButton || - matchedGroup == joinButton - ) { - if (path.startsWith(REEL_CHANNEL_BAR_PATH)) return super.isFiltered( + if (matchedGroup == suggestedActionPath) { + if (contentIndex == 0 && suggestedActions.check(protobufBufferArray).isFiltered()) return super.isFiltered( identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex - ); // else, return false. + ); + // else, return false; } return false; diff --git a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java index e8261ff3..ed90f89d 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java +++ b/app/src/main/java/app/revanced/integrations/youtube/settings/Settings.java @@ -160,6 +160,9 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_SHORTS_SUBSCRIBE_BUTTON = new BooleanSetting("revanced_hide_shorts_subscribe_button", TRUE); public static final BooleanSetting HIDE_SHORTS_SUBSCRIBE_BUTTON_PAUSED = new BooleanSetting("revanced_hide_shorts_subscribe_button_paused", FALSE); public static final BooleanSetting HIDE_SHORTS_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_thanks_button", TRUE); + public static final BooleanSetting HIDE_SHORTS_SHOP_BUTTON = new BooleanSetting("revanced_hide_shorts_shop_button", TRUE); + public static final BooleanSetting HIDE_SHORTS_LOCATION_BUTTON = new BooleanSetting("revanced_hide_shorts_location_button", FALSE); + public static final BooleanSetting HIDE_SHORTS_SAVE_SOUND_BUTTON = new BooleanSetting("revanced_hide_shorts_save_sound_button", FALSE); public static final BooleanSetting HIDE_SHORTS_LIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_like_button", FALSE); public static final BooleanSetting HIDE_SHORTS_DISLIKE_BUTTON = new BooleanSetting("revanced_hide_shorts_dislike_button", FALSE); public static final BooleanSetting HIDE_SHORTS_COMMENTS_BUTTON = new BooleanSetting("revanced_hide_shorts_comments_button", FALSE);