|
7 | 7 | import app.revanced.integrations.utils.LogHelper; |
8 | 8 |
|
9 | 9 | public class GeneralBytecodeAdsPatch { |
10 | | - |
11 | 10 | //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) { |
13 | 12 | var path = pathBuilder.toString(); |
14 | 13 | if (path.isEmpty()) return false; |
15 | 14 |
|
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; |
17 | 29 |
|
18 | 30 | List<String> blockList = new ArrayList<>(); |
19 | 31 |
|
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 | + |
21 | 43 | blockList.add("video_display_full_buttoned_layout"); |
| 44 | + blockList.add("_ad"); |
22 | 45 | blockList.add("ad_"); |
23 | 46 | blockList.add("ads_video_with_context"); |
24 | 47 | blockList.add("cell_divider"); |
25 | 48 | blockList.add("reels_player_overlay"); |
| 49 | + // could be required |
| 50 | + // blockList.add("full_width_square_image_layout"); |
26 | 51 | blockList.add("shelf_header"); |
27 | 52 | blockList.add("watch_metadata_app_promo"); |
28 | 53 | blockList.add("video_display_full_layout"); |
@@ -79,19 +104,8 @@ public static boolean isAdComponent(StringBuilder pathBuilder) { |
79 | 104 | blockList.add("channel_guidelines_entry_banner"); |
80 | 105 | } |
81 | 106 |
|
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 | | - |
93 | 107 | if (anyMatch(blockList, path::contains)) { |
94 | | - LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking ad: " + path); |
| 108 | + LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking: " + path); |
95 | 109 | return true; |
96 | 110 | } |
97 | 111 |
|
|
0 commit comments