From 9de566ca02398ab9c628565091ed02316c5e1ed0 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 23 Apr 2024 19:31:27 +0200 Subject: [PATCH] feat(YouTube - Hide ads): Add option to hide the 'Visit store' button on channel pages (#622) --- .../youtube/patches/components/AdsFilter.java | 22 +++++++++++++++++++ .../youtube/settings/Settings.java | 1 + 2 files changed, 23 insertions(+) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/AdsFilter.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/AdsFilter.java index 22daf6dd..3e817b81 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/AdsFilter.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/AdsFilter.java @@ -23,6 +23,10 @@ public final class AdsFilter extends Filter { // endregion private final StringTrieSearch exceptions = new StringTrieSearch(); + + private final StringFilterGroup channelProfile; + private final ByteArrayFilterGroup visitStoreButton; + private final StringFilterGroup shoppingLinks; public AdsFilter() { @@ -100,6 +104,16 @@ public final class AdsFilter extends Filter { "expandable_list" ); + channelProfile = new StringFilterGroup( + null, + "channel_profile.eml" + ); + + visitStoreButton = new ByteArrayFilterGroup( + Settings.HIDE_VISIT_STORE_BUTTON, + "header_store_button" + ); + final var webLinkPanel = new StringFilterGroup( Settings.HIDE_WEB_SEARCH_RESULTS, "web_link_panel" @@ -122,6 +136,7 @@ public final class AdsFilter extends Filter { viewProducts, selfSponsor, fullscreenAd, + channelProfile, webLinkPanel, shoppingLinks, movieAds @@ -140,6 +155,13 @@ public final class AdsFilter extends Filter { return false; // Do not actually filter the fullscreen ad otherwise it will leave a dimmed screen. } + if (matchedGroup == channelProfile) { + if (visitStoreButton.check(protobufBufferArray).isFiltered()) { + return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex); + } + return false; + } + // Check for the index because of likelihood of false positives. if (matchedGroup == shoppingLinks && contentIndex != 0) 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 78072220..c2556984 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 @@ -45,6 +45,7 @@ public class Settings extends BaseSettings { public static final BooleanSetting HIDE_SHOPPING_LINKS = new BooleanSetting("revanced_hide_shopping_links", TRUE); public static final BooleanSetting HIDE_SELF_SPONSOR = new BooleanSetting("revanced_hide_self_sponsor_ads", TRUE); public static final BooleanSetting HIDE_VIDEO_ADS = new BooleanSetting("revanced_hide_video_ads", TRUE, true); + public static final BooleanSetting HIDE_VISIT_STORE_BUTTON = new BooleanSetting("revanced_hide_visit_store_button", TRUE); public static final BooleanSetting HIDE_WEB_SEARCH_RESULTS = new BooleanSetting("revanced_hide_web_search_results", TRUE); // Feed