From 269493cd198604f1438ea2850fb68fe900d0e56f Mon Sep 17 00:00:00 2001
From: ILoveOpenSourceApplications
<117499019+ILoveOpenSourceApplications@users.noreply.github.com>
Date: Fri, 13 Dec 2024 00:09:08 +0530
Subject: [PATCH] feat(YouTube - Comments): Add `Hide 'Chat summary'` (#4110)
---
.../youtube/patches/components/CommentsFilter.java | 6 ++++++
.../app/revanced/extension/youtube/settings/Settings.java | 1 +
.../layout/hide/general/HideLayoutComponentsPatch.kt | 1 +
patches/src/main/resources/addresources/values/strings.xml | 3 +++
4 files changed, 11 insertions(+)
diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/CommentsFilter.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/CommentsFilter.java
index 0e7ebc4407..5c76d5606a 100644
--- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/CommentsFilter.java
+++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/components/CommentsFilter.java
@@ -14,6 +14,11 @@ final class CommentsFilter extends Filter {
private final ByteArrayFilterGroup emojiPickerBufferGroup;
public CommentsFilter() {
+ var chatSummary = new StringFilterGroup(
+ Settings.HIDE_COMMENTS_CHAT_SUMMARY,
+ "live_chat_summary_banner.eml"
+ );
+
var commentsByMembers = new StringFilterGroup(
Settings.HIDE_COMMENTS_BY_MEMBERS_HEADER,
"sponsorships_comments_header.eml",
@@ -54,6 +59,7 @@ public CommentsFilter() {
);
addPathCallbacks(
+ chatSummary,
commentsByMembers,
comments,
createAShort,
diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
index dd116ec117..950f34be4d 100644
--- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
+++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java
@@ -159,6 +159,7 @@ public class Settings extends BaseSettings {
public static final StringSetting EXTERNAL_DOWNLOADER_PACKAGE_NAME = new StringSetting("revanced_external_downloader_name",
"org.schabi.newpipe" /* NewPipe */, parentsAny(EXTERNAL_DOWNLOADER, EXTERNAL_DOWNLOADER_ACTION_BUTTON));
// Comments
+ public static final BooleanSetting HIDE_COMMENTS_CHAT_SUMMARY = new BooleanSetting("revanced_hide_comments_chat_summary", FALSE);
public static final BooleanSetting HIDE_COMMENTS_BY_MEMBERS_HEADER = new BooleanSetting("revanced_hide_comments_by_members_header", FALSE);
public static final BooleanSetting HIDE_COMMENTS_CREATE_A_SHORT_BUTTON = new BooleanSetting("revanced_hide_comments_create_a_short_button", TRUE);
public static final BooleanSetting HIDE_COMMENTS_PREVIEW_COMMENT = new BooleanSetting("revanced_hide_comments_preview_comment", FALSE);
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt
index 0a03da6d90..a52fc5ff00 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt
@@ -154,6 +154,7 @@ val hideLayoutComponentsPatch = bytecodePatch(
PreferenceScreenPreference(
"revanced_comments_screen",
preferences = setOf(
+ SwitchPreference("revanced_hide_comments_chat_summary"),
SwitchPreference("revanced_hide_comments_by_members_header"),
SwitchPreference("revanced_hide_comments_section"),
SwitchPreference("revanced_hide_comments_create_a_short_button"),
diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml
index ec8fdd6b54..56db255896 100644
--- a/patches/src/main/resources/addresources/values/strings.xml
+++ b/patches/src/main/resources/addresources/values/strings.xml
@@ -259,6 +259,9 @@ You will not be notified of any unexpected events."
Comments
Hide or show comments section components
+ Hide \'Chat summary\'
+ \'Chat summary\' is hidden
+ \'Chat summary\' is shown
Hide \'Comments by members\' header
\'Comments by members\' header is hidden
\'Comments by members\' header is shown