fix(YouTube - Hide layout components): Resolve "Hide community posts" not working when selecting a channel from subscribed channels bar in Subscriptions tab
Co-authored-by: ILoveOpenSourceApplications <117499019+iloveopensourceapplications@users.noreply.github.com>
This commit is contained in:
parent
136cecc290
commit
009cf71462
14 changed files with 175 additions and 53 deletions
|
|
@ -12,6 +12,8 @@ import java.util.Map;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
|
@ -172,14 +174,21 @@ public final class CustomFilter extends Filter {
|
|||
|
||||
if (!groups.isEmpty()) {
|
||||
CustomFilterGroup[] groupsArray = groups.toArray(new CustomFilterGroup[0]);
|
||||
Logger.printDebug(()-> "Using Custom filters: " + Arrays.toString(groupsArray));
|
||||
Logger.printDebug(() -> "Using Custom filters: " + Arrays.toString(groupsArray));
|
||||
addPathCallbacks(groupsArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(
|
||||
ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
// All callbacks are custom filter groups.
|
||||
CustomFilterGroup custom = (CustomFilterGroup) matchedGroup;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.shared.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
||||
|
|
@ -9,27 +11,33 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Filters litho based components.
|
||||
*
|
||||
* <p>
|
||||
* Callbacks to filter content are added using {@link #addIdentifierCallbacks(StringFilterGroup...)}
|
||||
* and {@link #addPathCallbacks(StringFilterGroup...)}.
|
||||
*
|
||||
* <p>
|
||||
* To filter {@link FilterContentType#PROTOBUFFER} or {@link FilterContentType#ACCESSIBILITY}, first add a callback to
|
||||
* either an identifier or a path.
|
||||
* Then inside {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Then inside {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* search for the buffer content using either a {@link ByteArrayFilterGroup} (if searching for 1 pattern)
|
||||
* or a {@link FilterGroupList.ByteArrayFilterGroupList} (if searching for more than 1 pattern).
|
||||
*
|
||||
* <p>
|
||||
* All callbacks must be registered before the constructor completes.
|
||||
*/
|
||||
public abstract class Filter {
|
||||
|
||||
public enum FilterContentType {
|
||||
CONTEXT,
|
||||
IDENTIFIER,
|
||||
PATH,
|
||||
ACCESSIBILITY,
|
||||
PROTOBUFFER
|
||||
}
|
||||
|
||||
/**
|
||||
* Context callbacks. Do not add to this instance,
|
||||
* and instead use {@link #addContextCallbacks(StringFilterGroup...)}.
|
||||
*/
|
||||
protected final List<StringFilterGroup> contextCallbacks = new ArrayList<>();
|
||||
/**
|
||||
* Identifier callbacks. Do not add to this instance,
|
||||
* and instead use {@link #addIdentifierCallbacks(StringFilterGroup...)}.
|
||||
|
|
@ -42,7 +50,15 @@ public abstract class Filter {
|
|||
public final List<StringFilterGroup> pathCallbacks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addContextCallbacks(StringFilterGroup... groups) {
|
||||
contextCallbacks.addAll(Arrays.asList(groups));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addIdentifierCallbacks(StringFilterGroup... groups) {
|
||||
|
|
@ -50,7 +66,7 @@ public abstract class Filter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds callbacks to {@link #isFiltered(String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* Adds callbacks to {@link #isFiltered(ContextInterface, String, String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||
* if any of the groups are found.
|
||||
*/
|
||||
protected final void addPathCallbacks(StringFilterGroup... groups) {
|
||||
|
|
@ -64,6 +80,7 @@ public abstract class Filter {
|
|||
* <p>
|
||||
* Method is called off the main thread.
|
||||
*
|
||||
* @param contextInterface The interface to get the Litho conversion context.
|
||||
* @param identifier Litho identifier.
|
||||
* @param accessibility Accessibility string, or an empty string if not present for the component.
|
||||
* @param buffer Protocol buffer.
|
||||
|
|
@ -72,8 +89,8 @@ public abstract class Filter {
|
|||
* @param contentIndex Matched index of the identifier or path.
|
||||
* @return True if the litho component should be filtered out.
|
||||
*/
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface, String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
|
@ -167,8 +168,14 @@ public final class AdsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (matchedGroup == buyMovieAd) {
|
||||
return contentIndex == 0 && buyMovieAdBuffer.check(buffer).isFiltered();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
import app.revanced.extension.youtube.patches.playback.quality.AdvancedVideoQualityMenuPatch;
|
||||
|
|
@ -21,8 +23,14 @@ public final class AdvancedVideoQualityMenuFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
isVideoQualityMenuVisible = true;
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
|
|
@ -85,8 +86,14 @@ public final class CommentsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (matchedGroup == comments) {
|
||||
if (path.startsWith(VIDEO_LOCKUP_WITH_ATTACHMENT_PATH)) {
|
||||
return Settings.HIDE_COMMENTS_SECTION_IN_HOME_FEED.get();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
|
|
@ -133,8 +134,14 @@ public final class DescriptionComponentsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
// The description panel can be opened in both the regular player and Shorts.
|
||||
// If the description panel is opened in a Shorts, PlayerType is 'HIDDEN',
|
||||
// so 'PlayerType.getCurrent().isMaximizedOrFullscreen()' does not guarantee that the description panel is open.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package app.revanced.extension.youtube.patches.litho;
|
|||
|
||||
import static app.revanced.extension.youtube.patches.LayoutReloadObserverPatch.isActionBarVisible;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
|
@ -80,8 +81,14 @@ public final class HorizontalShelvesFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (contentIndex != 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
import app.revanced.extension.shared.ByteTrieSearch;
|
||||
|
|
@ -47,7 +49,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
|
||||
/**
|
||||
* Strings found in the buffer for every video. Full strings should be specified.
|
||||
*
|
||||
* <p>
|
||||
* This list does not include every common buffer string, and this can be added/changed as needed.
|
||||
* Words must be entered with the exact casing as found in the buffer.
|
||||
*/
|
||||
|
|
@ -122,7 +124,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
/**
|
||||
* Path components to not filter. Cannot filter the buffer when these are present,
|
||||
* otherwise text in UI controls can be filtered as a keyword (such as using "Playlist" as a keyword).
|
||||
*
|
||||
* <p>
|
||||
* This is also a small performance improvement since
|
||||
* the buffer of the parent component was already searched and passed.
|
||||
*/
|
||||
|
|
@ -156,10 +158,10 @@ public final class KeywordContentFilter extends Filter {
|
|||
* Rolling average of how many videos were filtered by a keyword.
|
||||
* Used to detect if a keyword passes the initial check against {@link #STRINGS_IN_EVERY_BUFFER}
|
||||
* but a keyword is still hiding all videos.
|
||||
*
|
||||
* <p>
|
||||
* This check can still fail if some extra UI elements pass the keywords,
|
||||
* such as the video chapter preview or any other elements.
|
||||
*
|
||||
* <p>
|
||||
* To test this, add a filter that appears in all videos (such as 'ovd='),
|
||||
* and open the subscription feed. In practice this does not always identify problems
|
||||
* in the home feed and search, because the home feed has a finite amount of content and
|
||||
|
|
@ -226,7 +228,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
* @return If the string contains any characters from languages that do not use spaces between words.
|
||||
*/
|
||||
private static boolean isLanguageWithNoSpaces(String text) {
|
||||
for (int i = 0, length = text.length(); i < length;) {
|
||||
for (int i = 0, length = text.length(); i < length; ) {
|
||||
final int codePoint = text.codePointAt(i);
|
||||
|
||||
Character.UnicodeBlock block = Character.UnicodeBlock.of(codePoint);
|
||||
|
|
@ -277,7 +279,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
|
||||
/**
|
||||
* @return If the start and end indexes are not surrounded by other letters.
|
||||
* If the indexes are surrounded by numbers/symbols/punctuation it is considered a whole word.
|
||||
* If the indexes are surrounded by numbers/symbols/punctuation it is considered a whole word.
|
||||
*/
|
||||
private static boolean keywordMatchIsWholeWord(byte[] text, int keywordStartIndex, int keywordLength) {
|
||||
final Integer codePointBefore = getUtf8CodePointBefore(text, keywordStartIndex);
|
||||
|
|
@ -296,7 +298,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
|
||||
/**
|
||||
* @return The UTF8 character point immediately before the index,
|
||||
* or null if the bytes before the index is not a valid UTF8 character.
|
||||
* or null if the bytes before the index is not a valid UTF8 character.
|
||||
*/
|
||||
@Nullable
|
||||
private static Integer getUtf8CodePointBefore(byte[] data, int index) {
|
||||
|
|
@ -312,7 +314,7 @@ public final class KeywordContentFilter extends Filter {
|
|||
|
||||
/**
|
||||
* @return The UTF8 character point at the index,
|
||||
* or null if the index holds no valid UTF8 character.
|
||||
* or null if the index holds no valid UTF8 character.
|
||||
*/
|
||||
@Nullable
|
||||
private static Integer getUtf8CodePointAt(byte[] data, int index) {
|
||||
|
|
@ -556,8 +558,14 @@ public final class KeywordContentFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (contentIndex != 0 && matchedGroup == startsWithFilter) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import androidx.annotation.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.StringTrieSearch;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
|
@ -75,6 +76,7 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
private final StringFilterGroup chipBar;
|
||||
private final StringFilterGroup channelProfile;
|
||||
private final StringFilterGroupList channelProfileGroupList;
|
||||
private final StringFilterGroupList communityPostStringFilterGroup;
|
||||
|
||||
public LayoutComponentsFilter() {
|
||||
exceptions.addPatterns(
|
||||
|
|
@ -140,6 +142,16 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
"poll_post_responsive_root.e",
|
||||
"shared_post_root.e"
|
||||
);
|
||||
communityPostStringFilterGroup = new StringFilterGroupList();
|
||||
communityPostStringFilterGroup.addAll(
|
||||
new StringFilterGroup(
|
||||
null,
|
||||
// home
|
||||
"horizontalCollectionSwipeProtector=null",
|
||||
// subscriptions
|
||||
"heightConstraint=null"
|
||||
)
|
||||
);
|
||||
|
||||
final var subscribersCommunityGuidelines = new StringFilterGroup(
|
||||
Settings.HIDE_SUBSCRIBERS_COMMUNITY_GUIDELINES,
|
||||
|
|
@ -379,8 +391,14 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
// This identifier is used not only in players but also in search results:
|
||||
// https://github.com/ReVanced/revanced-patches/issues/3245
|
||||
// Until 2024, medical information panels such as Covid-19 also used this identifier and were shown in the search results.
|
||||
|
|
@ -400,13 +418,8 @@ public final class LayoutComponentsFilter extends Filter {
|
|||
return channelProfileGroupList.check(accessibility).isFiltered();
|
||||
}
|
||||
|
||||
if (matchedGroup == communityPosts
|
||||
&& NavigationBar.isBackButtonVisible()
|
||||
&& !NavigationBar.isSearchBarActive()
|
||||
&& PlayerType.getCurrent() != PlayerType.WATCH_WHILE_MAXIMIZED) {
|
||||
// Allow community posts on channel profile page,
|
||||
// or if viewing an individual channel in the feed.
|
||||
return false;
|
||||
if (matchedGroup == communityPosts) {
|
||||
return communityPostStringFilterGroup.check(contextInterface.toString()).isFiltered();
|
||||
}
|
||||
|
||||
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.youtube.patches.playback.speed.CustomPlaybackSpeedPatch;
|
||||
|
|
@ -38,8 +39,14 @@ public final class PlaybackSpeedMenuFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (matchedGroup == oldPlaybackMenuGroup) {
|
||||
isOldPlaybackSpeedMenuVisible = true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
|
@ -112,8 +113,14 @@ public final class PlayerFlyoutMenuItemsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (matchedGroup == videoQualityMenuFooter) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import androidx.annotation.Nullable;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.Logger;
|
||||
import app.revanced.extension.shared.TrieSearch;
|
||||
import app.revanced.extension.shared.Utils;
|
||||
|
|
@ -19,14 +21,14 @@ import app.revanced.extension.youtube.settings.Settings;
|
|||
|
||||
/**
|
||||
* Searches for video IDs in the proto buffer of Shorts dislike.
|
||||
*
|
||||
* <p>
|
||||
* Because multiple litho dislike spans are created in the background
|
||||
* (and also anytime litho refreshes the components, which is somewhat arbitrary),
|
||||
* that makes the value of {@link VideoInformation#getVideoId()} and {@link VideoInformation#getPlayerResponseVideoId()}
|
||||
* unreliable to determine which video ID a Shorts litho span belongs to.
|
||||
*
|
||||
* <p>
|
||||
* But the correct video ID does appear in the protobuffer just before a Shorts litho span is created.
|
||||
*
|
||||
* <p>
|
||||
* Once a way to asynchronously update litho text is found, this strategy will no longer be needed.
|
||||
*/
|
||||
public final class ReturnYouTubeDislikeFilter extends Filter {
|
||||
|
|
@ -88,8 +90,14 @@ public final class ReturnYouTubeDislikeFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (!Settings.RYD_ENABLED.get() || !Settings.RYD_SHORTS.get()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import static app.revanced.extension.shared.ConversionContext.*;
|
||||
import static app.revanced.extension.youtube.patches.LayoutReloadObserverPatch.isActionBarVisible;
|
||||
import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.*;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.ByteArrayFilterGroupList;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroupList.StringFilterGroupList;
|
||||
|
||||
import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
|
@ -394,8 +397,14 @@ public final class ShortsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (contentType == FilterContentType.IDENTIFIER) {
|
||||
if (matchedGroup == shelfHeaderIdentifier) {
|
||||
// Shelf header reused in history/channel/etc.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package app.revanced.extension.youtube.patches.litho;
|
||||
|
||||
import app.revanced.extension.shared.ConversionContext;
|
||||
import app.revanced.extension.shared.ConversionContext.ContextInterface;
|
||||
import app.revanced.extension.shared.patches.litho.Filter;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.ByteArrayFilterGroup;
|
||||
import app.revanced.extension.shared.patches.litho.FilterGroup.StringFilterGroup;
|
||||
|
|
@ -158,8 +160,14 @@ public final class VideoActionButtonsFilter extends Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isFiltered(String identifier, String accessibility, String path, byte[] buffer,
|
||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||
public boolean isFiltered(ContextInterface contextInterface,
|
||||
String identifier,
|
||||
String accessibility,
|
||||
String path,
|
||||
byte[] buffer,
|
||||
StringFilterGroup matchedGroup,
|
||||
FilterContentType contentType,
|
||||
int contentIndex) {
|
||||
if (matchedGroup == likeSubscribeGlow) {
|
||||
return path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX) || path.startsWith(COMPACT_CHANNEL_BAR_PATH_PREFIX)
|
||||
|| path.startsWith(COMPACTIFY_VIDEO_ACTION_BAR_PATH);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue