From 1c9a966354243dd1a106e1fc767227c1b025125e Mon Sep 17 00:00:00 2001 From: MarcaD <152095496+MarcaDian@users.noreply.github.com> Date: Sat, 19 Oct 2024 15:39:00 +0300 Subject: [PATCH] feat(YouTube - Hide Shorts components): Hide `Hashtag` button (#717) --- .../patches/components/ShortsFilter.java | 22 ++++++++++++++++++- .../youtube/settings/Settings.java | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) 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 f48d10cf..41369c2f 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 @@ -247,10 +247,24 @@ public final class ShortsFilter extends Filter { new ByteArrayFilterGroup( Settings.HIDE_SHORTS_GREEN_SCREEN_BUTTON, "greenscreen_temp" + ), + new ByteArrayFilterGroup( + Settings.HIDE_SHORTS_HASHTAG_BUTTON, + "yt_outline_hashtag_" ) ); } + private boolean isEverySuggestedActionFilterEnabled() { + for (ByteArrayFilterGroup group : suggestedActionsGroupList) { + if (!group.isEnabled()) { + return false; + } + } + + return true; + } + @Override boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray, StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) { @@ -279,7 +293,13 @@ public final class ShortsFilter extends Filter { } if (matchedGroup == suggestedAction) { - // Suggested actions can be at the start or in the middle of a path. + // Skip searching the buffer if all suggested actions are set to hidden. + // This has a secondary effect of hiding all new un-identified actions + // under the assumption that the user wants all actions hidden. + if (isEverySuggestedActionFilterEnabled()) { + return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex); + } + if (suggestedActionsGroupList.check(protobufBufferArray).isFiltered()) { return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex); } 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 85af3e46..cdf05b91 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 @@ -230,6 +230,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_SHORTS_USE_TEMPLATE_BUTTON = new BooleanSetting("revanced_hide_shorts_use_template_button", TRUE); public static final BooleanSetting HIDE_SHORTS_UPCOMING_BUTTON = new BooleanSetting("revanced_hide_shorts_upcoming_button", TRUE); public static final BooleanSetting HIDE_SHORTS_GREEN_SCREEN_BUTTON = new BooleanSetting("revanced_hide_shorts_green_screen_button", TRUE); + public static final BooleanSetting HIDE_SHORTS_HASHTAG_BUTTON = new BooleanSetting("revanced_hide_shorts_hashtag_button", TRUE); public static final BooleanSetting HIDE_SHORTS_SEARCH_SUGGESTIONS = new BooleanSetting("revanced_hide_shorts_search_suggestions", FALSE); public static final BooleanSetting HIDE_SHORTS_STICKERS = new BooleanSetting("revanced_hide_shorts_stickers", TRUE); public static final BooleanSetting HIDE_SHORTS_SUPER_THANKS_BUTTON = new BooleanSetting("revanced_hide_shorts_super_thanks_button", TRUE);