fix(YouTube - Hide layout components): Replace "Hide AI comments summary" with "Sanitize category bar"
Co-Authored-By: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
parent
e7196e54b0
commit
23676746a6
4 changed files with 39 additions and 26 deletions
|
|
@ -1,5 +1,10 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
|
@ -8,11 +13,10 @@ import app.revanced.extension.youtube.shared.PlayerType;
|
|||
@SuppressWarnings("unused")
|
||||
public final class CommentsFilter extends Filter {
|
||||
|
||||
private static final String CHIP_BAR_PATH_PREFIX = "chip_bar.e";
|
||||
private static final String COMMENT_COMPOSER_PATH = "comment_composer.e";
|
||||
private static final String VIDEO_LOCKUP_WITH_ATTACHMENT_PATH = "video_lockup_with_attachment.e";
|
||||
|
||||
private final StringFilterGroup chipBar;
|
||||
private final ByteArrayFilterGroup aiCommentsSummary;
|
||||
private final StringFilterGroup comments;
|
||||
private final StringFilterGroup emojiAndTimestampButtons;
|
||||
|
||||
|
|
@ -22,16 +26,6 @@ public final class CommentsFilter extends Filter {
|
|||
"live_chat_summary_banner.e"
|
||||
);
|
||||
|
||||
chipBar = new StringFilterGroup(
|
||||
Settings.HIDE_COMMENTS_AI_SUMMARY,
|
||||
"chip_bar.e"
|
||||
);
|
||||
|
||||
aiCommentsSummary = new ByteArrayFilterGroup(
|
||||
null,
|
||||
"yt_fill_spark_"
|
||||
);
|
||||
|
||||
var channelGuidelines = new StringFilterGroup(
|
||||
Settings.HIDE_COMMENTS_CHANNEL_GUIDELINES,
|
||||
"channel_guidelines_entry_banner"
|
||||
|
|
@ -79,7 +73,6 @@ public final class CommentsFilter extends Filter {
|
|||
addPathCallbacks(
|
||||
channelGuidelines,
|
||||
chatSummary,
|
||||
chipBar,
|
||||
commentsByMembers,
|
||||
comments,
|
||||
communityGuidelines,
|
||||
|
|
@ -94,23 +87,36 @@ public final class CommentsFilter extends Filter {
|
|||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
if (matchedGroup == chipBar) {
|
||||
// Playlist sort button uses same components and must only filter if the player is opened.
|
||||
return PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||
&& aiCommentsSummary.check(buffer).isFiltered();
|
||||
}
|
||||
|
||||
if (matchedGroup == comments) {
|
||||
if (path.startsWith(VIDEO_LOCKUP_WITH_ATTACHMENT_PATH)) {
|
||||
return Settings.HIDE_COMMENTS_SECTION_IN_HOME_FEED.get();
|
||||
}
|
||||
return Settings.HIDE_COMMENTS_SECTION.get();
|
||||
}
|
||||
|
||||
if (matchedGroup == emojiAndTimestampButtons) {
|
||||
} else if (matchedGroup == emojiAndTimestampButtons) {
|
||||
return path.startsWith(COMMENT_COMPOSER_PATH);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void sanitizeCommentsCategoryBar(@NonNull String identifier,
|
||||
@NonNull List<Object> treeNodeResultList) {
|
||||
try {
|
||||
if (Settings.SANITIZE_COMMENTS_CATEGORY_BAR.get()
|
||||
&& identifier.startsWith(CHIP_BAR_PATH_PREFIX)
|
||||
// Playlist sort button uses same components and must only filter if the player is opened.
|
||||
&& PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||
) {
|
||||
int treeNodeResultListSize = treeNodeResultList.size();
|
||||
if (treeNodeResultListSize > 2) {
|
||||
treeNodeResultList.subList(1, treeNodeResultListSize - 1).clear();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "Failed to sanitize comment category bar", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ public class Settings extends YouTubeAndMusicSettings {
|
|||
public static final BooleanSetting HIDE_COMMENTS_SECTION = new BooleanSetting("revanced_hide_comments_section", FALSE);
|
||||
public static final BooleanSetting HIDE_COMMENTS_SECTION_IN_HOME_FEED = new BooleanSetting("revanced_hide_comments_section_in_home_feed", FALSE, parentNot(HIDE_COMMENTS_SECTION));
|
||||
public static final BooleanSetting HIDE_COMMENTS_THANKS_BUTTON = new BooleanSetting("revanced_hide_comments_thanks_button", TRUE);
|
||||
public static final BooleanSetting SANITIZE_COMMENTS_CATEGORY_BAR = new BooleanSetting("revanced_sanitize_comments_category_bar", FALSE);
|
||||
|
||||
// Description
|
||||
public static final BooleanSetting HIDE_AI_GENERATED_VIDEO_SUMMARY_SECTION = new BooleanSetting("revanced_hide_ai_generated_video_summary_section", FALSE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue