Skip to content

Commit

Permalink
feat(YouTube - Hide ads): Hide shopping links in video description
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 23, 2023
1 parent 2613e10 commit 11e7c04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -12,6 +12,7 @@

public final class AdsFilter extends Filter {
private final StringTrieSearch exceptions = new StringTrieSearch();
private final StringFilterGroup shoppingLinks;

public AdsFilter() {
exceptions.addPatterns(
Expand Down Expand Up @@ -71,6 +72,11 @@ public AdsFilter() {
"products_in_video"
);

shoppingLinks = new StringFilterGroup(
SettingsEnum.HIDE_SHOPPING_LINKS,
"expandable_list"
);

final var webLinkPanel = new StringFilterGroup(
SettingsEnum.HIDE_WEB_SEARCH_RESULTS,
"web_link_panel"
Expand All @@ -93,6 +99,7 @@ public AdsFilter() {
viewProducts,
selfSponsor,
webLinkPanel,
shoppingLinks,
movieAds
);
this.identifierFilterGroupList.addAll(carouselAd);
Expand All @@ -104,6 +111,10 @@ public boolean isFiltered(@Nullable String identifier, String path, byte[] proto
if (exceptions.matches(path))
return false;

// Check for the index because of likelihood of false positives.
if (matchedGroup == shoppingLinks && matchedIndex != 0)
return false;

return super.isFiltered(identifier, path, protobufBufferArray, matchedList, matchedGroup, matchedIndex);
}

Expand Down
Expand Up @@ -50,6 +50,7 @@ public enum SettingsEnum {
HIDE_MERCHANDISE_BANNERS("revanced_hide_merchandise_banners", BOOLEAN, TRUE),
HIDE_PAID_CONTENT("revanced_hide_paid_content_ads", BOOLEAN, TRUE),
HIDE_PRODUCTS_BANNER("revanced_hide_products_banner", BOOLEAN, TRUE),
HIDE_SHOPPING_LINKS("revanced_hide_shopping_links", BOOLEAN, TRUE),
HIDE_SELF_SPONSOR("revanced_hide_self_sponsor_ads", BOOLEAN, TRUE),
HIDE_VIDEO_ADS("revanced_hide_video_ads", BOOLEAN, TRUE, true),
HIDE_WEB_SEARCH_RESULTS("revanced_hide_web_search_results", BOOLEAN, TRUE),
Expand Down

0 comments on commit 11e7c04

Please sign in to comment.