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);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPref
|
|||
import app.revanced.patches.youtube.layout.hide.shelves.hideHorizontalShelvesPatch
|
||||
import app.revanced.patches.youtube.misc.engagement.engagementPanelHookPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.litho.lazily.hookTreeNodeResult
|
||||
import app.revanced.patches.youtube.misc.litho.lazily.lazilyConvertedElementHookPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_21_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
|
|
@ -86,6 +88,7 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
|||
engagementPanelHookPatch,
|
||||
resourceMappingPatch,
|
||||
hideHorizontalShelvesPatch,
|
||||
lazilyConvertedElementHookPatch
|
||||
),
|
||||
filterClasses = setOf(
|
||||
LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR,
|
||||
|
|
@ -154,7 +157,8 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
|||
SwitchPreference("revanced_hide_comments_emoji_and_timestamp_buttons"),
|
||||
SwitchPreference("revanced_hide_comments_preview_comment"),
|
||||
SwitchPreference("revanced_hide_comments_thanks_button"),
|
||||
),
|
||||
SwitchPreference("revanced_sanitize_comments_category_bar"),
|
||||
),
|
||||
sorting = Sorting.UNSORTED,
|
||||
),
|
||||
SwitchPreference("revanced_hide_channel_bar"),
|
||||
|
|
@ -272,6 +276,8 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
|||
)
|
||||
}
|
||||
|
||||
hookTreeNodeResult("$COMMENTS_FILTER_CLASS_NAME->sanitizeCommentsCategoryBar")
|
||||
|
||||
// region Hide mix playlists
|
||||
|
||||
parseElementFromBufferMethodMatch.let {
|
||||
|
|
|
|||
|
|
@ -493,9 +493,6 @@ However, enabling this will also log some user data such as your IP address."</s
|
|||
<string name="revanced_hide_comments_ai_chat_summary_title">Hide AI chat summary</string>
|
||||
<string name="revanced_hide_comments_ai_chat_summary_summary_on">AI chat summary is hidden</string>
|
||||
<string name="revanced_hide_comments_ai_chat_summary_summary_off">AI chat summary is shown</string>
|
||||
<string name="revanced_hide_comments_ai_summary_title">Hide AI comments summary</string>
|
||||
<string name="revanced_hide_comments_ai_summary_summary_on">AI comments summary is hidden</string>
|
||||
<string name="revanced_hide_comments_ai_summary_summary_off">AI comments summary is shown</string>
|
||||
<string name="revanced_hide_comments_channel_guidelines_title">Hide channel guidelines</string>
|
||||
<string name="revanced_hide_comments_channel_guidelines_summary_on">Channel guidelines are hidden</string>
|
||||
<string name="revanced_hide_comments_channel_guidelines_summary_off">Channel guidelines are shown</string>
|
||||
|
|
@ -520,6 +517,9 @@ However, enabling this will also log some user data such as your IP address."</s
|
|||
<string name="revanced_hide_comments_thanks_button_title">Hide Thanks button</string>
|
||||
<string name="revanced_hide_comments_thanks_button_summary_on">Thanks button is hidden</string>
|
||||
<string name="revanced_hide_comments_thanks_button_summary_off">Thanks button is shown</string>
|
||||
<string name="revanced_sanitize_comments_category_bar_title">Sanitize category bar</string>
|
||||
<string name="revanced_sanitize_comments_category_bar_summary_on">Category buttons except \'Top\' and \'Newest\' are hidden in the comment category bar</string>
|
||||
<string name="revanced_sanitize_comments_category_bar_summary_off">Category buttons are shown in the comment category bar</string>
|
||||
<string name="revanced_hide_view_count_title">Hide view count</string>
|
||||
<string name="revanced_hide_view_count_summary_on">View count is hidden in feed and search results</string>
|
||||
<string name="revanced_hide_view_count_summary_off">View count is shown in feed and search results</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue