Skip to content

Commit

Permalink
feat(YouTube/Hide layout components): add `Hide videos with gray desc…
Browse files Browse the repository at this point in the history
…ription` settings
  • Loading branch information
inotia00 committed Dec 20, 2023
1 parent b6f17dd commit afd7ab6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
*/
@SuppressWarnings("unused")
public final class LayoutComponentsFilter extends Filter {
private static final String ENDORSEMENT_HEADER_FOOTER_PATH = "endorsement_header_footer";
private static final ByteArrayAsStringFilterGroup grayDescriptionIdentifier =
new ByteArrayAsStringFilterGroup(
SettingsEnum.HIDE_VIDEO_WITH_GRAY_DESCRIPTION,
ENDORSEMENT_HEADER_FOOTER_PATH
);
private static final ByteArrayAsStringFilterGroup lowViewsVideoIdentifier =
new ByteArrayAsStringFilterGroup(
SettingsEnum.HIDE_VIDEO_WITH_LOW_VIEW,
"g-highZ"
);

private final StringFilterGroup communityPosts;
private final StringFilterGroupList communityPostsGroupList = new StringFilterGroupList();
private final StringFilterGroup videoWithLowLevelView;
private final StringFilterGroup homeVideoWithContext;
private final StringFilterGroup searchVideoWithContext;

public LayoutComponentsFilter() {
// Identifiers.
Expand Down Expand Up @@ -81,7 +87,12 @@ public LayoutComponentsFilter() {

final StringFilterGroup grayDescription = new StringFilterGroup(
SettingsEnum.HIDE_GRAY_DESCRIPTION,
"endorsement_header_footer"
ENDORSEMENT_HEADER_FOOTER_PATH
);

homeVideoWithContext = new StringFilterGroup(
SettingsEnum.HIDE_VIDEO_WITH_LOW_VIEW,
"home_video_with_context.eml"
);

final StringFilterGroup infoPanel = new StringFilterGroup(
Expand Down Expand Up @@ -121,6 +132,11 @@ public LayoutComponentsFilter() {
"set_reminder_button"
);

searchVideoWithContext = new StringFilterGroup(
SettingsEnum.HIDE_VIDEO_WITH_GRAY_DESCRIPTION,
"search_video_with_context.eml"
);

final StringFilterGroup startTrial = new StringFilterGroup(
SettingsEnum.HIDE_START_TRIAL_BUTTON,
"channel_purchase_button"
Expand All @@ -138,11 +154,6 @@ public LayoutComponentsFilter() {
"timed_reaction"
);

videoWithLowLevelView = new StringFilterGroup(
null,
"home_video_with_context.eml"
);

pathFilterGroupList.addAll(
albumCard,
audioTrackButton,
Expand All @@ -151,16 +162,17 @@ public LayoutComponentsFilter() {
expandableMetadata,
feedSurvey,
grayDescription,
homeVideoWithContext,
infoPanel,
joinMembership,
latestPosts,
medicalPanel,
movieShelf,
notifyMe,
searchVideoWithContext,
startTrial,
ticketShelf,
timedReactions,
videoWithLowLevelView
timedReactions
);

communityPostsGroupList.addAll(
Expand All @@ -178,8 +190,10 @@ public LayoutComponentsFilter() {
@Override
boolean isFiltered(String path, @Nullable String identifier, String allValue, byte[] protobufBufferArray,
FilterGroupList matchedList, FilterGroup matchedGroup, int matchedIndex) {
if (matchedGroup == videoWithLowLevelView) {
if (matchedGroup == homeVideoWithContext) {
return lowViewsVideoIdentifier.check(protobufBufferArray).isFiltered();
} else if (matchedGroup == searchVideoWithContext) {
return grayDescriptionIdentifier.check(protobufBufferArray).isFiltered();
} else if (matchedGroup == communityPosts) {
return communityPostsGroupList.check(allValue).isFiltered();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public enum SettingsEnum {
// Experimental Flags
HIDE_SUGGESTIONS_SHELF("revanced_hide_suggestions_shelf", BOOLEAN, FALSE, true),
HIDE_SUGGESTIONS_SHELF_METHOD("revanced_hide_suggestions_shelf_method", BOOLEAN, FALSE, true),
HIDE_VIDEO_WITH_GRAY_DESCRIPTION("revanced_hide_video_with_gray_description", BOOLEAN, FALSE, true),
HIDE_VIDEO_WITH_LOW_VIEW("revanced_hide_video_with_low_view", BOOLEAN, FALSE, true),

// Channel Profile
Expand Down

0 comments on commit afd7ab6

Please sign in to comment.