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

feat(YouTube - Hide ads): Add option to hide the 'Visit store' button on channel pages #622

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
oSumAtrIX marked this conversation as resolved.
Show resolved Hide resolved
);

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 @@ -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
Loading