feat: app promo banner removal setting

This commit is contained in:
oSumAtrIX 2022-06-04 17:01:57 +02:00
parent 4fd2abc409
commit a96bbe6469
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -14,24 +14,12 @@ 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", true);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_merchandise", false);
}
public static boolean isExperimentalCommunityPostRemoval() {
@ -46,8 +34,8 @@ public class LithoAdRemoval {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_banner", false);
}
public static boolean isExperimentalPaidContentRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_paid_content", true);
public static boolean isExperimentalAppPromoBannerRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_app_promo_banner", false);
}
public static boolean isExperimentalCommentsRemoval() {
@ -67,16 +55,73 @@ public class LithoAdRemoval {
}
public static boolean isShortsShelf() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", true);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", false);
}
public static boolean isCommunityGuidelines() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", true);
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", false);
}
public static boolean containsAd(String value) {
if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalAppPromoBannerRemoval() || 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");
}
if (isExperimentalMerchandiseRemoval()) {
blockList.add("product_carousel");
}
if (isExperimentalCommunityPostRemoval()) {
blockList.add("post_base_wrapper");
}
if (isExperimentalMovieUpsellRemoval()) {
blockList.add("movie_and_show_upsell_card");
}
if (isExperimentalAppPromoBannerRemoval()) {
blockList.add("watch_metadata_app_promo");
}
if (isExperimentalCompactBannerRemoval()) {
blockList.add("compact_banner");
}
if (isExperimentalCommentsRemoval()) {
blockList.add("comments_composite_entry_point");
}
if (isExperimentalCompactMovieRemoval()) {
blockList.add("compact_movie");
}
if (isExperimentalHorizontalMovieShelfRemoval()) {
blockList.add("horizontal_movie_shelf");
}
if (isInFeedSurvey()) {
blockList.add("in_feed_survey");
}
if (isShortsShelf()) {
blockList.add("shorts_shelf");
}
if (isCommunityGuidelines()) {
blockList.add("community_guidelines");
}
for (String s : blockList) {
if (value.contains(s)) {
if (XGlobals.debug) {
Log.d("TemplateBlocked", value);
}
return true;
}
}
if (!XGlobals.debug) {
return false;
}
Log.d("Template", value);
return false;
}
public static boolean containsAd(String value, ByteBuffer buffer) {
try {
if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalPaidContentRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
if (!(isExperimentalAdRemoval() || isExperimentalMerchandiseRemoval() || isExperimentalAppPromoBannerRemoval() || isExperimentalCommunityPostRemoval() || isExperimentalMovieUpsellRemoval() || isExperimentalCompactBannerRemoval() || isExperimentalCommentsRemoval() || isExperimentalCompactMovieRemoval() || isExperimentalHorizontalMovieShelfRemoval() || isInFeedSurvey() || isShortsShelf() || isCommunityGuidelines()) || value == null || value.isEmpty()) {
return false;
}
List<String> blockList = new ArrayList<>();
@ -84,10 +129,6 @@ public class LithoAdRemoval {
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");
@ -98,17 +139,8 @@ public class LithoAdRemoval {
if (isExperimentalMovieUpsellRemoval()) {
blockList.add("movie_and_show_upsell_card");
}
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 (isExperimentalAppPromoBannerRemoval()) {
blockList.add("watch_metadata_app_promo");
}
if (isExperimentalCompactBannerRemoval()) {
blockList.add("compact_banner");
@ -160,6 +192,7 @@ public class LithoAdRemoval {
}
}
public static int indexOf(byte[] array, byte[] target) {
if (target.length == 0) {
return 0;