mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-03 01:02:55 +01:00
feat(youtube/general-ads): hide shorts in search
This commit is contained in:
parent
0a90289dc5
commit
d82b9898a8
@ -76,7 +76,8 @@ final class BlockRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Filter {
|
abstract class Filter {
|
||||||
final LithoBlockRegister register = new LithoBlockRegister();
|
final LithoBlockRegister pathRegister = new LithoBlockRegister();
|
||||||
|
final LithoBlockRegister identifierRegister = new LithoBlockRegister();
|
||||||
|
|
||||||
abstract boolean filter(final String path, final String identifier);
|
abstract boolean filter(final String path, final String identifier);
|
||||||
}
|
}
|
||||||
@ -140,7 +141,7 @@ final class CommentsPatch extends Filter {
|
|||||||
"comments_entry_point_simplebox"
|
"comments_entry_point_simplebox"
|
||||||
);
|
);
|
||||||
|
|
||||||
this.register.registerAll(
|
this.pathRegister.registerAll(
|
||||||
comments,
|
comments,
|
||||||
previewComment
|
previewComment
|
||||||
);
|
);
|
||||||
@ -148,7 +149,7 @@ final class CommentsPatch extends Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean filter(String path, String _identifier) {
|
boolean filter(String path, String _identifier) {
|
||||||
if (!Extensions.any(register, path)) return false;
|
if (!Extensions.any(pathRegister, path)) return false;
|
||||||
|
|
||||||
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
LogHelper.debug(CommentsPatch.class, "Blocked: " + path);
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ final class ButtonsPatch extends Filter {
|
|||||||
|
|
||||||
actionBarRule = new BlockRule(null, "video_action_bar");
|
actionBarRule = new BlockRule(null, "video_action_bar");
|
||||||
|
|
||||||
this.register.registerAll(
|
this.pathRegister.registerAll(
|
||||||
like,
|
like,
|
||||||
dislikeRule,
|
dislikeRule,
|
||||||
download,
|
download,
|
||||||
@ -201,7 +202,7 @@ final class ButtonsPatch extends Filter {
|
|||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || Extensions.any(register, path)) {
|
if ((currentIsActionButton && ActionButton.doNotBlockCounter <= 0 && actionButtonsRule.isEnabled()) || Extensions.any(pathRegister, path)) {
|
||||||
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
LogHelper.debug(ButtonsPatch.class, "Blocked: " + path);
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
} else return false;
|
||||||
@ -213,8 +214,6 @@ final class ButtonsPatch extends Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class GeneralBytecodeAdsPatch extends Filter {
|
final class GeneralBytecodeAdsPatch extends Filter {
|
||||||
private final BlockRule identifierBlock;
|
|
||||||
|
|
||||||
public GeneralBytecodeAdsPatch() {
|
public GeneralBytecodeAdsPatch() {
|
||||||
var communityPosts = new BlockRule(SettingsEnum.ADREMOVER_COMMUNITY_POSTS_REMOVAL, "post_base_wrapper");
|
var communityPosts = new BlockRule(SettingsEnum.ADREMOVER_COMMUNITY_POSTS_REMOVAL, "post_base_wrapper");
|
||||||
var communityGuidelines = new BlockRule(SettingsEnum.ADREMOVER_COMMUNITY_GUIDELINES_REMOVAL, "community_guidelines");
|
var communityGuidelines = new BlockRule(SettingsEnum.ADREMOVER_COMMUNITY_GUIDELINES_REMOVAL, "community_guidelines");
|
||||||
@ -223,7 +222,6 @@ final class GeneralBytecodeAdsPatch extends Filter {
|
|||||||
var medicalPanel = new BlockRule(SettingsEnum.ADREMOVER_MEDICAL_PANEL_REMOVAL, "medical_panel");
|
var medicalPanel = new BlockRule(SettingsEnum.ADREMOVER_MEDICAL_PANEL_REMOVAL, "medical_panel");
|
||||||
var paidContent = new BlockRule(SettingsEnum.ADREMOVER_PAID_CONTENT_REMOVAL, "paid_content_overlay");
|
var paidContent = new BlockRule(SettingsEnum.ADREMOVER_PAID_CONTENT_REMOVAL, "paid_content_overlay");
|
||||||
var merchandise = new BlockRule(SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL, "product_carousel");
|
var merchandise = new BlockRule(SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL, "product_carousel");
|
||||||
var shorts = new BlockRule(SettingsEnum.ADREMOVER_SHORTS_SHELF_REMOVAL, "shorts_shelf");
|
|
||||||
var infoPanel = new BlockRule(SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL, "publisher_transparency_panel", "single_item_information_panel");
|
var infoPanel = new BlockRule(SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL, "publisher_transparency_panel", "single_item_information_panel");
|
||||||
var suggestions = new BlockRule(SettingsEnum.ADREMOVER_SUGGESTIONS_REMOVAL, "horizontal_video_shelf");
|
var suggestions = new BlockRule(SettingsEnum.ADREMOVER_SUGGESTIONS_REMOVAL, "horizontal_video_shelf");
|
||||||
var latestPosts = new BlockRule(SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS, "post_shelf");
|
var latestPosts = new BlockRule(SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS, "post_shelf");
|
||||||
@ -241,7 +239,6 @@ final class GeneralBytecodeAdsPatch extends Filter {
|
|||||||
"banner_text_icon",
|
"banner_text_icon",
|
||||||
"cell_divider",
|
"cell_divider",
|
||||||
"reels_player_overlay",
|
"reels_player_overlay",
|
||||||
"shelf_header",
|
|
||||||
"watch_metadata_app_promo",
|
"watch_metadata_app_promo",
|
||||||
"video_display_full_layout"
|
"video_display_full_layout"
|
||||||
);
|
);
|
||||||
@ -253,11 +250,10 @@ final class GeneralBytecodeAdsPatch extends Filter {
|
|||||||
"movie_and_show_upsell_card"
|
"movie_and_show_upsell_card"
|
||||||
);
|
);
|
||||||
|
|
||||||
this.register.registerAll(
|
this.pathRegister.registerAll(
|
||||||
generalAds,
|
generalAds,
|
||||||
communityPosts,
|
communityPosts,
|
||||||
paidContent,
|
paidContent,
|
||||||
shorts,
|
|
||||||
suggestions,
|
suggestions,
|
||||||
latestPosts,
|
latestPosts,
|
||||||
movieAds,
|
movieAds,
|
||||||
@ -272,8 +268,13 @@ final class GeneralBytecodeAdsPatch extends Filter {
|
|||||||
selfSponsor
|
selfSponsor
|
||||||
);
|
);
|
||||||
|
|
||||||
// Block for the ComponentContext.identifier field
|
var carouselAd = new BlockRule(SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL, "carousel_ad");
|
||||||
identifierBlock = new BlockRule(SettingsEnum.ADREMOVER_GENERAL_ADS_REMOVAL, "carousel_ad");
|
var shorts = new BlockRule(SettingsEnum.ADREMOVER_SHORTS_REMOVAL, "shorts_shelf", "inline_shorts");
|
||||||
|
|
||||||
|
this.identifierRegister.registerAll(
|
||||||
|
shorts,
|
||||||
|
carouselAd
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean filter(final String path, final String identifier) {
|
public boolean filter(final String path, final String identifier) {
|
||||||
@ -293,10 +294,10 @@ final class GeneralBytecodeAdsPatch extends Filter {
|
|||||||
"playlist_add_to_option_wrapper" // do not block on "add to playlist" flyout menu
|
"playlist_add_to_option_wrapper" // do not block on "add to playlist" flyout menu
|
||||||
)) return false;
|
)) return false;
|
||||||
|
|
||||||
if (!Extensions.any(register, path) && !identifierBlock.check(identifier).isBlocked())
|
if (!(Extensions.any(pathRegister, path) || Extensions.any(identifierRegister, identifier)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocked: " + path);
|
LogHelper.debug(GeneralBytecodeAdsPatch.class, String.format("Blocked (ID: %s): %s", identifier, path));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public enum SettingsEnum {
|
|||||||
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN),
|
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_MOVIE_REMOVAL("revanced_adremover_movie", true, ReturnType.BOOLEAN),
|
ADREMOVER_MOVIE_REMOVAL("revanced_adremover_movie", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_FEED_SURVEY_REMOVAL("revanced_adremover_feed_survey", true, ReturnType.BOOLEAN),
|
ADREMOVER_FEED_SURVEY_REMOVAL("revanced_adremover_feed_survey", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_SHORTS_SHELF_REMOVAL("revanced_adremover_shorts_shelf", true, ReturnType.BOOLEAN),
|
ADREMOVER_SHORTS_REMOVAL("revanced_adremover_shorts", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_COMMUNITY_GUIDELINES_REMOVAL("revanced_adremover_community_guidelines", true, ReturnType.BOOLEAN),
|
ADREMOVER_COMMUNITY_GUIDELINES_REMOVAL("revanced_adremover_community_guidelines", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_EMERGENCY_BOX_REMOVAL("revanced_adremover_emergency_box_removal", true, ReturnType.BOOLEAN),
|
ADREMOVER_EMERGENCY_BOX_REMOVAL("revanced_adremover_emergency_box_removal", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN),
|
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN),
|
||||||
|
Loading…
Reference in New Issue
Block a user