From 55050878028fed82b0f583a9f7ba06b8f267f8ec Mon Sep 17 00:00:00 2001 From: ILoveOpenSourceApplications <117499019+ILoveOpenSourceApplications@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:02:15 +0530 Subject: [PATCH] feat(YouTube - Hide ads): Add `Hide end screen store banner` (#4351) --- .../youtube/patches/components/AdsFilter.java | 31 ++++++-- .../extension/youtube/settings/Settings.java | 1 + .../youtube/ad/general/HideAdsPatch.kt | 1 + .../resources/addresources/values/strings.xml | 71 ++++++++++--------- 4 files changed, 65 insertions(+), 39 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/AdsFilter.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/AdsFilter.java index 6a4a1ab32..372fcebca 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/AdsFilter.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/AdsFilter.java @@ -27,6 +27,9 @@ public final class AdsFilter extends Filter { private final StringFilterGroup playerShoppingShelf; private final ByteArrayFilterGroup playerShoppingShelfBuffer; + private final StringFilterGroup fullscreenOverlay; + private final ByteArrayFilterGroup endScreenStoreBannerBuffer; + private final StringFilterGroup channelProfile; private final ByteArrayFilterGroup visitStoreButton; @@ -112,11 +115,6 @@ public final class AdsFilter extends Filter { "expandable_list" ); - channelProfile = new StringFilterGroup( - null, - "channel_profile.eml" - ); - playerShoppingShelf = new StringFilterGroup( null, "horizontal_shelf.eml" @@ -127,6 +125,21 @@ public final class AdsFilter extends Filter { "shopping_item_card_list.eml" ); + fullscreenOverlay = new StringFilterGroup( + Settings.HIDE_END_SCREEN_STORE_BANNER, + "fullscreen_overlay.eml" + ); + + endScreenStoreBannerBuffer = new ByteArrayFilterGroup( + null, + "gstatic.com/shopping" + ); + + channelProfile = new StringFilterGroup( + null, + "channel_profile.eml" + ); + visitStoreButton = new ByteArrayFilterGroup( Settings.HIDE_VISIT_STORE_BUTTON, "header_store_button" @@ -154,6 +167,7 @@ public final class AdsFilter extends Filter { viewProducts, selfSponsor, fullscreenAd, + fullscreenOverlay, channelProfile, webLinkPanel, shoppingLinks, @@ -172,6 +186,13 @@ public final class AdsFilter extends Filter { return false; } + if (matchedGroup == fullscreenOverlay) { + if (contentIndex == 0 && endScreenStoreBannerBuffer.check(protobufBufferArray).isFiltered()) { + return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex); + } + return false; + } + if (exceptions.matches(path)) return false; diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index 6977d59e3..29d982369 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -64,6 +64,7 @@ public class Settings extends BaseSettings { // Ads public static final BooleanSetting HIDE_BUTTONED_ADS = new BooleanSetting("revanced_hide_buttoned_ads", TRUE); + public static final BooleanSetting HIDE_END_SCREEN_STORE_BANNER = new BooleanSetting("revanced_hide_end_screen_store_banner", FALSE); public static final BooleanSetting HIDE_FULLSCREEN_ADS = new BooleanSetting("revanced_hide_fullscreen_ads", TRUE); public static final BooleanSetting HIDE_GENERAL_ADS = new BooleanSetting("revanced_hide_general_ads", TRUE); public static final BooleanSetting HIDE_GET_PREMIUM = new BooleanSetting("revanced_hide_get_premium", TRUE); diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt index 14e5aa3b6..3047d6fe4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/ad/general/HideAdsPatch.kt @@ -37,6 +37,7 @@ private val hideAdsResourcePatch = resourcePatch { PreferenceScreen.ADS.addPreferences( SwitchPreference("revanced_hide_general_ads"), + SwitchPreference("revanced_hide_end_screen_store_banner"), SwitchPreference("revanced_hide_fullscreen_ads"), SwitchPreference("revanced_hide_buttoned_ads"), SwitchPreference("revanced_hide_paid_promotion_label"), diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index ed53a0d5a..2abbdec8a 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -169,9 +169,9 @@ Tap the continue button and allow optimization changes." You will not be notified of any unexpected events." - Disable like / subscribe button glow - Like and subscribe button will not glow when mentioned - Like and subscribe button will glow when mentioned + Disable Like and Subscribe button glow + Like and Subscribe button will not glow when mentioned + Like and Subscribe button will glow when mentioned Hide album cards Album cards are hidden Album cards are shown @@ -224,9 +224,9 @@ You will not be notified of any unexpected events." Hide chips shelf Chips shelf is hidden Chips shelf is shown - Hide expandable chip under videos - Expandable chips are hidden - Expandable chips are shown + Hide expandable card under videos + Expandable cards are hidden + Expandable cards are shown Hide community posts Community posts are hidden Community posts are shown @@ -331,7 +331,7 @@ You will not be notified of any unexpected events." Hide preview comment Preview comment is hidden Preview comment is shown - Hide thanks button + Hide Thanks button Thanks button is hidden Thanks button is shown Hide timestamp and emoji buttons @@ -360,12 +360,12 @@ If a Doodle is currently showing in your region and this hide setting is on, the Hide home videos by keywords Videos in the home tab are filtered by keywords Videos in the home tab are not filtered by keywords - Hide subscription videos by keywords - Videos in the subscriptions tab are filtered by keywords - Videos in the subscriptions tab are not filtered by keywords Hide search results by keywords Search results are filtered by keywords Search results are not filtered by keywords + Hide subscription videos by keywords + Videos in the subscriptions tab are filtered by keywords + Videos in the subscriptions tab are not filtered by keywords Keywords to hide @@ -412,6 +412,9 @@ This feature is only available for older devices" Hide banner to view products Banner is hidden Banner is shown + Hide end screen store banner + Store banner is hidden + Store banner is shown Hide player shopping shelf Shopping shelf is hidden Shopping shelf is shown @@ -464,7 +467,7 @@ This feature is only available for older devices" Download button shown in player Download button not shown in player - Override download action button + Override Download action button Download button opens your external downloader Download button opens the native in-app downloader Downloader package name @@ -651,14 +654,14 @@ Note: Enabling this also forcibly hides video ads" Hide previous & next video buttons Buttons are hidden Buttons are shown - Hide cast button + Hide Cast button Cast button is hidden Cast button is shown - Hide captions button + Hide Captions button Captions button is hidden Captions button is shown - Hide autoplay button + Hide Autoplay button Autoplay button is hidden Autoplay button is shown @@ -668,7 +671,7 @@ Note: Enabling this also forcibly hides video ads" End screen cards are shown - Disable ambient mode in fullscreen + Disable Ambient mode in fullscreen Ambient mode disabled Ambient mode enabled @@ -708,38 +711,38 @@ Note: Enabling this also forcibly hides video ads" Hidden in watch history Shown in watch history - Hide join button + Hide Join button Join button is hidden Join button is shown - Hide subscribe button + Hide Subscribe button Subscribe button is hidden Subscribe button is shown Hide paused overlay buttons Paused overlay buttons are hidden Paused overlay buttons are shown - Hide shop button + Hide Shop button Shop button is hidden Shop button is shown - Hide super thanks button - Super thanks button is hidden - Super thanks button is shown + Hide Buy Super Thanks button + Super Thanks button is hidden + Super Thanks button is shown Hide tagged products Tagged products are hidden Tagged products are shown Hide location label Location label is hidden Location label is shown - Hide save music button + Hide Save music button Save music button is hidden Save music button is shown - Hide use template button + Hide Use template button Use template button is hidden Use template button is shown - Hide upcoming button + Hide Upcoming button Upcoming button is hidden Upcoming button is shown - Hide green screen button + Hide Green screen button Green screen button is hidden Green screen button is shown Hide hashtag button @@ -751,24 +754,24 @@ Note: Enabling this also forcibly hides video ads" Hide stickers Stickers are hidden Stickers are shown - Hide like fountain + Hide Like button fountain animation Like button fountain animation is hidden Like button fountain animation is shown - Hide like button + Hide Like button Like button is hidden Like button is shown - Hide dislike button + Hide Dislike button Dislike button is hidden Dislike button is shown - Hide comments button + Hide Comments button Comments button is hidden Comments button is shown - Hide remix button + Hide Remix button Remix button is hidden Remix button is shown - Hide share button + Hide Share button Share button is hidden Share button is shown Hide info panel @@ -847,7 +850,7 @@ Limitation: Dislikes may not appear in incognito mode" Dislikes shown as percentage Dislikes shown as number - Compact like button + Compact Like button Like button styled for minimum width Like button styled for best appearance Show a toast if API is not available @@ -897,7 +900,7 @@ This feature works best with a video quality of 720p or lower and when using a v SponsorBlock Enable SponsorBlock - SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos + SponsorBlock is a crowdsourced system for skipping annoying parts of YouTube videos Appearance Show voting button Segment voting button is shown @@ -962,7 +965,7 @@ Your user id is like a password and it should never be shared. Sponsor Paid promotion, paid referrals and direct advertisements. Not for self-promotion or free shout-outs to causes/creators/websites/products they like Unpaid/Self Promotion - Similar to \'Sponsor\' except for unpaid or self promotion. Includes sections about merchandise, donations, or information about who they collaborated with + Similar to Sponsor except for unpaid or self promotion. Includes sections about merchandise, donations, or information about who they collaborated with Interaction Reminder (Subscribe) A short reminder to like, subscribe or follow them in the middle of content. If it is long or about something specific, it should instead be under self promotion Highlight