mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-28 21:00:19 +02:00
refactor(YouTube - Hide feed components): Do not search path or buffer unless Hide mix playlists
setting is enabled
This commit is contained in:
parent
481b1537e0
commit
9f2276813c
@ -6,6 +6,7 @@ import app.revanced.extension.shared.patches.components.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.components.Filter;
|
||||
import app.revanced.extension.shared.patches.components.StringFilterGroup;
|
||||
import app.revanced.extension.shared.patches.components.StringFilterGroupList;
|
||||
import app.revanced.extension.shared.utils.Logger;
|
||||
import app.revanced.extension.shared.utils.StringTrieSearch;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
|
||||
@ -26,7 +27,7 @@ public final class FeedComponentsFilter extends Filter {
|
||||
|
||||
private static final ByteArrayFilterGroup mixPlaylists =
|
||||
new ByteArrayFilterGroup(
|
||||
Settings.HIDE_MIX_PLAYLISTS,
|
||||
null,
|
||||
"&list="
|
||||
);
|
||||
private static final ByteArrayFilterGroup mixPlaylistsBufferExceptions =
|
||||
@ -229,11 +230,20 @@ public final class FeedComponentsFilter extends Filter {
|
||||
* <p>
|
||||
* Called from a different place then the other filters.
|
||||
*/
|
||||
public static boolean filterMixPlaylists(final Object conversionContext, final byte[] bytes) {
|
||||
public static boolean filterMixPlaylists(final Object conversionContext, @Nullable final byte[] bytes) {
|
||||
try {
|
||||
if (!Settings.HIDE_MIX_PLAYLISTS.get()) {
|
||||
return false;
|
||||
}
|
||||
return bytes != null
|
||||
&& mixPlaylists.check(bytes).isFiltered()
|
||||
&& !mixPlaylistsBufferExceptions.check(bytes).isFiltered()
|
||||
&& !mixPlaylistsContextExceptions.matches(conversionContext.toString());
|
||||
} catch (Exception ex) {
|
||||
Logger.printException(() -> "filterMixPlaylists failure", ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user