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

Commit

Permalink
feat: additional annoyance removal options
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 5, 2022
1 parent 8fb1a25 commit a27ec45
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions app/src/main/java/fi/razerman/youtube/litho/LithoAdRemoval.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@ public class LithoAdRemoval {
private static final byte[] endRelatedPageAd = {112, 97, 103, 101, 97, 100};
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();

private static boolean isExperimentalInfoPanelRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_info_panel", true);
}

private static boolean isExperimentalMedicalPanelRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_medical_panel", true);
}

private static boolean isExperimentalEmergencyBoxRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_emergency_box", true);
}

public static boolean isExperimentalAdRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_ad_removal", true);
}

public static boolean isExperimentalMerchandiseRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_merchandise", false);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_merchandise", true);
}

public static boolean isExperimentalCommunityPostRemoval() {
Expand All @@ -34,8 +46,8 @@ public static boolean isExperimentalCompactBannerRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_banner", false);
}

public static boolean isExperimentalAppPromoBannerRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_app_promo_banner", false);
public static boolean isExperimentalPaidContentRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_paid_content", true);
}

public static boolean isExperimentalCommentsRemoval() {
Expand All @@ -55,23 +67,27 @@ public static boolean isInFeedSurvey() {
}

public static boolean isShortsShelf() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", false);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", true);
}

public static boolean isCommunityGuidelines() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", false);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", true);
}

public static boolean containsAd(String value, ByteBuffer buffer) {
try {
if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalAppPromoBannerRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalPaidContentRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
return false;
}
List<String> blockList = new ArrayList<>();
if (isExperimentalAdRemoval()) {
blockList.add("_ad");
blockList.add("ad_badge");
blockList.add("ads_video_with_context");
blockList.add("text_search_ad_with_description_first");
blockList.add("shelf_header");
blockList.add("cell_divider");
blockList.add("watch_metadata_app_promo");
}
if (isExperimentalMerchandiseRemoval()) {
blockList.add("product_carousel");
Expand All @@ -82,8 +98,17 @@ public static boolean containsAd(String value, ByteBuffer buffer) {
if (isExperimentalMovieUpsellRemoval()) {
blockList.add("movie_and_show_upsell_card");
}
if (isExperimentalAppPromoBannerRemoval()) {
blockList.add("watch_metadata_app_promo");
if (isExperimentalPaidContentRemoval()) {
blockList.add("paid_content_overlay");
}
if (isExperimentalEmergencyBoxRemoval()) {
blockList.add("emergency_onebox");
}
if (isExperimentalMedicalPanelRemoval()) {
blockList.add("medical_panel");
}
if (isExperimentalInfoPanelRemoval()) {
blockList.add("single_item_information_panel");
}
if (isExperimentalCompactBannerRemoval()) {
blockList.add("compact_banner");
Expand Down Expand Up @@ -135,7 +160,6 @@ public static boolean containsAd(String value, ByteBuffer buffer) {
}
}


public static int indexOf(byte[] array, byte[] target) {
if (target.length == 0) {
return 0;
Expand Down

0 comments on commit a27ec45

Please sign in to comment.