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

Commit 26c208e

Browse files
committed
feat(general-ads): block carousel ad
1 parent c548f16 commit 26c208e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package app.revanced.integrations.patches;
22

3+
import android.util.Log;
4+
35
import java.nio.ByteBuffer;
46
import java.util.ArrayList;
57

@@ -57,6 +59,7 @@ public boolean isBlocked(final String value) {
5759

5860
public class GeneralBytecodeAdsPatch {
5961
private final static LithoBlockRegister pathBlockRegister = new LithoBlockRegister();
62+
private final static ComponentRule identifierBlock;
6063

6164
static {
6265
var comments = new ComponentRule(SettingsEnum.ADREMOVER_COMMENTS_REMOVAL, "comments_");
@@ -80,7 +83,6 @@ public class GeneralBytecodeAdsPatch {
8083
"_ad",
8184
"ad_",
8285
"ads_video_with_context",
83-
"carousel_ad_with_detailed_metadata",
8486
"cell_divider",
8587
"reels_player_overlay",
8688
"shelf_header",
@@ -114,14 +116,17 @@ public class GeneralBytecodeAdsPatch {
114116
channelGuidelines
115117
};
116118
for (var block : blocks) pathBlockRegister.addBlock(block);
119+
120+
// Block for the ComponentContext.identifier field
121+
identifierBlock = new ComponentRule(SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL, "carousel_ad");
117122
}
118123

119124
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
120-
public static boolean isAdComponent(StringBuilder pathBuilder) {
125+
public static boolean isAdComponent(StringBuilder pathBuilder, String identifier) {
121126
var path = pathBuilder.toString();
122127
if (path.isEmpty()) return false;
123128

124-
LogHelper.debug(GeneralBytecodeAdsPatch.class, String.format("Searching: %s", path));
129+
LogHelper.debug(GeneralBytecodeAdsPatch.class, String.format("Searching (ID: %s): %s", identifier, path));
125130
// Do not block on these
126131
if (Extensions.containsAny(path,
127132
"home_video_with_context",
@@ -141,6 +146,11 @@ public static boolean isAdComponent(StringBuilder pathBuilder) {
141146
return true;
142147
}
143148

149+
if (identifierBlock.isBlocked(identifier)){
150+
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocked: " + identifier);
151+
return true;
152+
}
153+
144154
return false;
145155
}
146156
}

0 commit comments

Comments
 (0)