Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

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
  • Loading branch information
oSumAtrIX committed Apr 23, 2024
1 parent e86d73c commit 801ec76
Show file tree
Hide file tree
Showing 2 changed files with 20 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,10 @@ 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 && visitStoreButton.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}

// 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 @@ -54,6 +54,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);

// Layout
Expand Down

0 comments on commit 801ec76

Please sign in to comment.