Skip to content

Commit

Permalink
feat(YouTube - Hide ads): Add option to hide the 'Visit store' button…
Browse files Browse the repository at this point in the history
… on channel pages (ReVanced#622)
  • Loading branch information
oSumAtrIX authored Apr 23, 2024
1 parent a9da299 commit 9de566c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -100,6 +104,16 @@ public AdsFilter() {
"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"
Expand All @@ -122,6 +136,7 @@ public AdsFilter() {
viewProducts,
selfSponsor,
fullscreenAd,
channelProfile,
webLinkPanel,
shoppingLinks,
movieAds
Expand All @@ -140,6 +155,13 @@ boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBuff
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9de566c

Please sign in to comment.