Skip to content

Commit

Permalink
feat(YouTube - Comments): Add option to hide timestamp and emoji butt…
Browse files Browse the repository at this point in the history
…ons (#621)
  • Loading branch information
LisoUseInAIKyrios authored Apr 23, 2024
1 parent e86d73c commit 6e9e122
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import app.revanced.integrations.youtube.settings.Settings;

/**
* Patch is obsolete and will be deleted in a future release
*/
@SuppressWarnings("unused")
@Deprecated()
public class HideEmailAddressPatch {
//Used by app.revanced.patches.youtube.layout.personalinformation.patch.HideEmailAddressPatch
public static int hideEmailAddress(int originalValue) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package app.revanced.integrations.youtube.patches.components;

import androidx.annotation.Nullable;

import app.revanced.integrations.youtube.settings.Settings;

@SuppressWarnings("unused")
final class CommentsFilter extends Filter {

private static final String TIMESTAMP_OR_EMOJI_BUTTONS_ENDS_WITH_PATH
= "|CellType|ContainerType|ContainerType|ContainerType|ContainerType|ContainerType|";

private final StringFilterGroup commentComposer;
private final ByteArrayFilterGroup emojiPickerBufferGroup;

public CommentsFilter() {
var comments = new StringFilterGroup(
Settings.HIDE_COMMENTS_SECTION,
Expand All @@ -19,9 +27,38 @@ public CommentsFilter() {
"comments_entry_point_simplebox"
);

commentComposer = new StringFilterGroup(
Settings.HIDE_COMMENT_TIMESTAMP_AND_EMOJI_BUTTONS,
"comment_composer.eml"
);

emojiPickerBufferGroup = new ByteArrayFilterGroup(
null,
"id.comment.quick_emoji.button"
);

addPathCallbacks(
comments,
previewComment
previewComment,
commentComposer
);
}

@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (matchedGroup == commentComposer) {
// To completely hide the emoji buttons (and leave no empty space), the timestamp button is
// also hidden because the buffer is exactly the same and there's no way selectively hide.
if (contentIndex == 0
&& path.endsWith(TIMESTAMP_OR_EMOJI_BUTTONS_ENDS_WITH_PATH)
&& emojiPickerBufferGroup.check(protobufBufferArray).isFiltered()) {
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}

return false;
}

return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DescriptionComponentsFilter() {
);

final StringFilterGroup transcriptSection = new StringFilterGroup(
Settings.HIDE_TRANSCIPT_SECTION,
Settings.HIDE_TRANSCRIPT_SECTION,
"transcript_section"
);

Expand Down
Loading

0 comments on commit 6e9e122

Please sign in to comment.