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

Commit 18a749f

Browse files
committed
fix(general-ads): block remaining ads
1 parent c3e302d commit 18a749f

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

app/src/main/java/app/revanced/integrations/patches/GeneralBytecodeAdsPatch.java

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,47 @@
77
import app.revanced.integrations.utils.LogHelper;
88

99
public class GeneralBytecodeAdsPatch {
10-
1110
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
12-
public static boolean isAdComponent(StringBuilder pathBuilder) {
11+
public static boolean isAdComponent(StringBuilder pathBuilder, String identifier) {
1312
var path = pathBuilder.toString();
1413
if (path.isEmpty()) return false;
1514

16-
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Searching for an ad in: " + path);
15+
LogHelper.debug(GeneralBytecodeAdsPatch.class, String.format("Searching (ID: %s): %s", identifier, path));
16+
17+
if (containsAny(path,
18+
"home_video_with_context",
19+
"related_video_with_context",
20+
"search_video_with_context",
21+
"menu",
22+
"root",
23+
"-count",
24+
"-space",
25+
"-button",
26+
"library_recent_shelf",
27+
"download_button"
28+
)) return false;
1729

1830
List<String> blockList = new ArrayList<>();
1931

20-
if (SettingsEnum.ADREMOVER_AD_REMOVAL.getBoolean()) {
32+
for (var ad : SettingsEnum.ADREMOVER_CUSTOM.getString().split(",")) {
33+
if (ad.isEmpty()) continue;
34+
blockList.add(ad);
35+
}
36+
37+
if (SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL.getBoolean()) {
38+
if (identifier != null && identifier.contains("carousel_ad")) {
39+
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking: " + identifier);
40+
return true;
41+
}
42+
2143
blockList.add("video_display_full_buttoned_layout");
44+
blockList.add("_ad");
2245
blockList.add("ad_");
2346
blockList.add("ads_video_with_context");
2447
blockList.add("cell_divider");
2548
blockList.add("reels_player_overlay");
49+
// could be required
50+
// blockList.add("full_width_square_image_layout");
2651
blockList.add("shelf_header");
2752
blockList.add("watch_metadata_app_promo");
2853
blockList.add("video_display_full_layout");
@@ -79,19 +104,8 @@ public static boolean isAdComponent(StringBuilder pathBuilder) {
79104
blockList.add("channel_guidelines_entry_banner");
80105
}
81106

82-
if (containsAny(path,
83-
"home_video_with_context",
84-
"related_video_with_context",
85-
"search_video_with_context",
86-
"menu",
87-
"root",
88-
"-count",
89-
"-space",
90-
"-button"
91-
)) return false;
92-
93107
if (anyMatch(blockList, path::contains)) {
94-
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking ad: " + path);
108+
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking: " + path);
95109
return true;
96110
}
97111

app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ public enum SettingsEnum {
2626
ENABLE_WHITELIST("revanced_whitelist_ads_enabled", false, ReturnType.BOOLEAN),
2727

2828
//Ad settings
29+
ADREMOVER_CUSTOM("revanced_adremover_custom_removal", "", ReturnType.STRING, false),
2930
HOME_ADS_REMOVAL("revanced_home_ads_removal", true, ReturnType.BOOLEAN, true),
3031
VIDEO_ADS_REMOVAL("revanced_video_ads_removal", true, ReturnType.BOOLEAN, true),
31-
ADREMOVER_AD_REMOVAL("revanced_adremover_ad_removal", true, ReturnType.BOOLEAN, true),
32+
ADREMOVER_GENERAL_ADS_REMOVAL("revanced_adremover_ad_removal", true, ReturnType.BOOLEAN, true),
3233
ADREMOVER_MERCHANDISE_REMOVAL("revanced_adremover_merchandise", true, ReturnType.BOOLEAN, true),
3334
ADREMOVER_COMMUNITY_POSTS_REMOVAL("revanced_adremover_community_posts_removal", true, ReturnType.BOOLEAN, true),
3435
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN, true),

0 commit comments

Comments
 (0)