perf(YouTube): Filter identifier callback only on root component creation (#5558)
This commit is contained in:
parent
98114e5bde
commit
5d08fdddb8
15 changed files with 55 additions and 73 deletions
|
|
@ -6,8 +6,6 @@ import android.app.Instrumentation;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.revanced.extension.shared.Logger;
|
import app.revanced.extension.shared.Logger;
|
||||||
|
|
@ -155,10 +153,10 @@ public final class AdsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (matchedGroup == playerShoppingShelf) {
|
if (matchedGroup == playerShoppingShelf) {
|
||||||
return contentIndex == 0 && playerShoppingShelfBuffer.check(protobufBufferArray).isFiltered();
|
return contentIndex == 0 && playerShoppingShelfBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exceptions.matches(path)) {
|
if (exceptions.matches(path)) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.youtube.patches.playback.quality.AdvancedVideoQualityMenuPatch;
|
import app.revanced.extension.youtube.patches.playback.quality.AdvancedVideoQualityMenuPatch;
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
|
|
||||||
|
|
@ -21,7 +19,7 @@ public final class AdvancedVideoQualityMenuFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
isVideoQualityMenuVisible = true;
|
isVideoQualityMenuVisible = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
@ -100,7 +98,7 @@ final class ButtonsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (matchedGroup == likeSubscribeGlow) {
|
if (matchedGroup == likeSubscribeGlow) {
|
||||||
return (path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX) || path.startsWith(COMPACT_CHANNEL_BAR_PATH_PREFIX))
|
return (path.startsWith(VIDEO_ACTION_BAR_PATH_PREFIX) || path.startsWith(COMPACT_CHANNEL_BAR_PATH_PREFIX))
|
||||||
|
|
@ -117,7 +115,7 @@ final class ButtonsFilter extends Filter {
|
||||||
// Make sure the current path is the right one
|
// Make sure the current path is the right one
|
||||||
// to avoid false positives.
|
// to avoid false positives.
|
||||||
return path.startsWith(VIDEO_ACTION_BAR_PATH)
|
return path.startsWith(VIDEO_ACTION_BAR_PATH)
|
||||||
&& bufferButtonsGroupList.check(protobufBufferArray).isFiltered();
|
&& bufferButtonsGroupList.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
import app.revanced.extension.youtube.shared.PlayerType;
|
import app.revanced.extension.youtube.shared.PlayerType;
|
||||||
|
|
||||||
|
|
@ -87,12 +85,12 @@ final class CommentsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (matchedGroup == chipBar) {
|
if (matchedGroup == chipBar) {
|
||||||
// Playlist sort button uses same components and must only filter if the player is opened.
|
// Playlist sort button uses same components and must only filter if the player is opened.
|
||||||
return PlayerType.getCurrent().isMaximizedOrFullscreen()
|
return PlayerType.getCurrent().isMaximizedOrFullscreen()
|
||||||
&& aiCommentsSummary.check(protobufBufferArray).isFiltered();
|
&& aiCommentsSummary.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package app.revanced.extension.youtube.patches.components;
|
||||||
import static app.revanced.extension.shared.StringRef.str;
|
import static app.revanced.extension.shared.StringRef.str;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
@ -146,7 +145,7 @@ final class CustomFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
// All callbacks are custom filter groups.
|
// All callbacks are custom filter groups.
|
||||||
CustomFilterGroup custom = (CustomFilterGroup) matchedGroup;
|
CustomFilterGroup custom = (CustomFilterGroup) matchedGroup;
|
||||||
|
|
@ -158,6 +157,6 @@ final class CustomFilter extends Filter {
|
||||||
return true; // No buffer filter, only path filtering.
|
return true; // No buffer filter, only path filtering.
|
||||||
}
|
}
|
||||||
|
|
||||||
return custom.bufferSearch.matches(protobufBufferArray);
|
return custom.bufferSearch.matches(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.youtube.StringTrieSearch;
|
import app.revanced.extension.youtube.StringTrieSearch;
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
import app.revanced.extension.youtube.shared.PlayerType;
|
import app.revanced.extension.youtube.shared.PlayerType;
|
||||||
|
|
@ -105,7 +103,7 @@ final class DescriptionComponentsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
|
|
||||||
if (matchedGroup == aiGeneratedVideoSummarySection) {
|
if (matchedGroup == aiGeneratedVideoSummarySection) {
|
||||||
|
|
@ -116,11 +114,11 @@ final class DescriptionComponentsFilter extends Filter {
|
||||||
if (exceptions.matches(path)) return false;
|
if (exceptions.matches(path)) return false;
|
||||||
|
|
||||||
if (matchedGroup == macroMarkersCarousel) {
|
if (matchedGroup == macroMarkersCarousel) {
|
||||||
return contentIndex == 0 && macroMarkersCarouselGroupList.check(protobufBufferArray).isFiltered();
|
return contentIndex == 0 && macroMarkersCarouselGroupList.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == horizontalShelf) {
|
if (matchedGroup == horizontalShelf) {
|
||||||
return cellVideoAttribute.check(protobufBufferArray).isFiltered();
|
return cellVideoAttribute.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -42,6 +40,9 @@ abstract class Filter {
|
||||||
/**
|
/**
|
||||||
* Adds callbacks to {@link #isFiltered(String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
* Adds callbacks to {@link #isFiltered(String, String, byte[], StringFilterGroup, FilterContentType, int)}
|
||||||
* if any of the groups are found.
|
* if any of the groups are found.
|
||||||
|
* <p>
|
||||||
|
* Note: This callback is done only during the initial component creation,
|
||||||
|
* and the path will always be an empty string.
|
||||||
*/
|
*/
|
||||||
protected final void addIdentifierCallbacks(StringFilterGroup... groups) {
|
protected final void addIdentifierCallbacks(StringFilterGroup... groups) {
|
||||||
identifierCallbacks.addAll(Arrays.asList(groups));
|
identifierCallbacks.addAll(Arrays.asList(groups));
|
||||||
|
|
@ -68,7 +69,7 @@ abstract class Filter {
|
||||||
* @param contentIndex Matched index of the identifier or path.
|
* @param contentIndex Matched index of the identifier or path.
|
||||||
* @return True if the litho component should be filtered out.
|
* @return True if the litho component should be filtered out.
|
||||||
*/
|
*/
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -554,7 +554,7 @@ final class KeywordContentFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (contentIndex != 0 && matchedGroup == startsWithFilter) {
|
if (contentIndex != 0 && matchedGroup == startsWithFilter) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -574,7 +574,7 @@ final class KeywordContentFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
MutableReference<String> matchRef = new MutableReference<>();
|
MutableReference<String> matchRef = new MutableReference<>();
|
||||||
if (bufferSearch.matches(protobufBufferArray, matchRef)) {
|
if (bufferSearch.matches(buffer, matchRef)) {
|
||||||
updateStats(true, matchRef.value);
|
updateStats(true, matchRef.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ public final class LayoutComponentsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
// This identifier is used not only in players but also in search results:
|
// This identifier is used not only in players but also in search results:
|
||||||
// https://github.com/ReVanced/revanced-patches/issues/3245
|
// https://github.com/ReVanced/revanced-patches/issues/3245
|
||||||
|
|
@ -322,7 +322,7 @@ public final class LayoutComponentsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == channelProfile) {
|
if (matchedGroup == channelProfile) {
|
||||||
return channelProfileBuffer.check(protobufBufferArray).isFiltered();
|
return channelProfileBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
if (exceptions.matches(path)) return false; // Exceptions are not filtered.
|
||||||
|
|
@ -331,11 +331,11 @@ public final class LayoutComponentsFilter extends Filter {
|
||||||
return compactChannelBarInnerButton.check(path).isFiltered()
|
return compactChannelBarInnerButton.check(path).isFiltered()
|
||||||
// The filter may be broad, but in the context of a compactChannelBarInnerButton,
|
// The filter may be broad, but in the context of a compactChannelBarInnerButton,
|
||||||
// it's safe to assume that the button is the only thing that should be hidden.
|
// it's safe to assume that the button is the only thing that should be hidden.
|
||||||
&& joinMembershipButton.check(protobufBufferArray).isFiltered();
|
&& joinMembershipButton.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == horizontalShelves) {
|
if (matchedGroup == horizontalShelves) {
|
||||||
return contentIndex == 0 && (hideShelves() || ticketShelf.check(protobufBufferArray).isFiltered());
|
return contentIndex == 0 && (hideShelves() || ticketShelf.check(buffer).isFiltered());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == chipBar) {
|
if (matchedGroup == chipBar) {
|
||||||
|
|
|
||||||
|
|
@ -17,29 +17,28 @@ public final class LithoFilterPatch {
|
||||||
* Simple wrapper to pass the litho parameters through the prefix search.
|
* Simple wrapper to pass the litho parameters through the prefix search.
|
||||||
*/
|
*/
|
||||||
private static final class LithoFilterParameters {
|
private static final class LithoFilterParameters {
|
||||||
@Nullable
|
|
||||||
final String identifier;
|
final String identifier;
|
||||||
final String path;
|
final String path;
|
||||||
final byte[] protoBuffer;
|
final byte[] buffer;
|
||||||
|
|
||||||
LithoFilterParameters(@Nullable String lithoIdentifier, String lithoPath, byte[] protoBuffer) {
|
LithoFilterParameters(String lithoIdentifier, String lithoPath, byte[] buffer) {
|
||||||
this.identifier = lithoIdentifier;
|
this.identifier = lithoIdentifier;
|
||||||
this.path = lithoPath;
|
this.path = lithoPath;
|
||||||
this.protoBuffer = protoBuffer;
|
this.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// Estimate the percentage of the buffer that are Strings.
|
// Estimate the percentage of the buffer that are Strings.
|
||||||
StringBuilder builder = new StringBuilder(Math.max(100, protoBuffer.length / 2));
|
StringBuilder builder = new StringBuilder(Math.max(100, buffer.length / 2));
|
||||||
builder.append( "ID: ");
|
builder.append( "ID: ");
|
||||||
builder.append(identifier);
|
builder.append(identifier);
|
||||||
builder.append(" Path: ");
|
builder.append(" Path: ");
|
||||||
builder.append(path);
|
builder.append(path);
|
||||||
if (Settings.DEBUG_PROTOBUFFER.get()) {
|
if (Settings.DEBUG_PROTOBUFFER.get()) {
|
||||||
builder.append(" BufferStrings: ");
|
builder.append(" BufferStrings: ");
|
||||||
findAsciiStrings(builder, protoBuffer);
|
findAsciiStrings(builder, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
@ -142,7 +141,7 @@ public final class LithoFilterPatch {
|
||||||
|
|
||||||
LithoFilterParameters parameters = (LithoFilterParameters) callbackParameter;
|
LithoFilterParameters parameters = (LithoFilterParameters) callbackParameter;
|
||||||
final boolean isFiltered = filter.isFiltered(parameters.identifier,
|
final boolean isFiltered = filter.isFiltered(parameters.identifier,
|
||||||
parameters.path, parameters.protoBuffer, group, type, matchedStartIndex);
|
parameters.path, parameters.buffer, group, type, matchedStartIndex);
|
||||||
|
|
||||||
if (isFiltered && BaseSettings.DEBUG.get()) {
|
if (isFiltered && BaseSettings.DEBUG.get()) {
|
||||||
if (type == Filter.FilterContentType.IDENTIFIER) {
|
if (type == Filter.FilterContentType.IDENTIFIER) {
|
||||||
|
|
@ -193,12 +192,8 @@ public final class LithoFilterPatch {
|
||||||
/**
|
/**
|
||||||
* Injection point.
|
* Injection point.
|
||||||
*/
|
*/
|
||||||
public static boolean shouldFilter(@Nullable String lithoIdentifier, StringBuilder pathBuilder) {
|
public static boolean isFiltered(String lithoIdentifier, StringBuilder pathBuilder) {
|
||||||
try {
|
try {
|
||||||
if (pathBuilder.length() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] buffer = bufferThreadLocal.get();
|
byte[] buffer = bufferThreadLocal.get();
|
||||||
// Potentially the buffer may have been null or never set up until now.
|
// Potentially the buffer may have been null or never set up until now.
|
||||||
// Use an empty buffer so the litho id/path filters still work correctly.
|
// Use an empty buffer so the litho id/path filters still work correctly.
|
||||||
|
|
@ -206,16 +201,20 @@ public final class LithoFilterPatch {
|
||||||
buffer = EMPTY_BYTE_ARRAY;
|
buffer = EMPTY_BYTE_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
LithoFilterParameters parameter = new LithoFilterParameters(
|
String path = pathBuilder.toString();
|
||||||
lithoIdentifier, pathBuilder.toString(), buffer);
|
LithoFilterParameters parameter = new LithoFilterParameters(lithoIdentifier, path, buffer);
|
||||||
Logger.printDebug(() -> "Searching " + parameter);
|
Logger.printDebug(() -> "Searching " + parameter);
|
||||||
|
|
||||||
if (parameter.identifier != null && identifierSearchTree.matches(parameter.identifier, parameter)) {
|
if (path.isEmpty()) {
|
||||||
return true;
|
// Identifier is filtered only if there is no path,
|
||||||
}
|
// meaning no component or sub components have been created yet.
|
||||||
|
if (identifierSearchTree.matches(parameter.identifier, parameter)) {
|
||||||
if (pathSearchTree.matches(parameter.path, parameter)) {
|
return true;
|
||||||
return true;
|
}
|
||||||
|
} else {
|
||||||
|
if (pathSearchTree.matches(parameter.path, parameter)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.printException(() -> "Litho filter failure", ex);
|
Logger.printException(() -> "Litho filter failure", ex);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.youtube.patches.playback.speed.CustomPlaybackSpeedPatch;
|
import app.revanced.extension.youtube.patches.playback.speed.CustomPlaybackSpeedPatch;
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
|
|
||||||
|
|
@ -38,7 +36,7 @@ public final class PlaybackSpeedMenuFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (matchedGroup == oldPlaybackMenuGroup) {
|
if (matchedGroup == oldPlaybackMenuGroup) {
|
||||||
isOldPlaybackSpeedMenuVisible = true;
|
isOldPlaybackSpeedMenuVisible = true;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package app.revanced.extension.youtube.patches.components;
|
package app.revanced.extension.youtube.patches.components;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import app.revanced.extension.shared.settings.Setting;
|
import app.revanced.extension.shared.settings.Setting;
|
||||||
import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch;
|
import app.revanced.extension.shared.spoof.SpoofVideoStreamsPatch;
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
|
|
@ -96,7 +94,7 @@ public class PlayerFlyoutMenuItemsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (matchedGroup == videoQualityMenuFooter) {
|
if (matchedGroup == videoQualityMenuFooter) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -107,10 +105,10 @@ public class PlayerFlyoutMenuItemsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shorts also use this player flyout panel
|
// Shorts also use this player flyout panel
|
||||||
if (PlayerType.getCurrent().isNoneOrHidden() || exception.check(protobufBufferArray).isFiltered()) {
|
if (PlayerType.getCurrent().isNoneOrHidden() || exception.check(buffer).isFiltered()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flyoutFilterGroupList.check(protobufBufferArray).isFiltered();
|
return flyoutFilterGroupList.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,15 +84,15 @@ public final class ReturnYouTubeDislikeFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (!Settings.RYD_ENABLED.get() || !Settings.RYD_SHORTS.get()) {
|
if (!Settings.RYD_ENABLED.get() || !Settings.RYD_SHORTS.get()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterGroup.FilterGroupResult result = videoIdFilterGroup.check(protobufBufferArray);
|
FilterGroup.FilterGroupResult result = videoIdFilterGroup.check(buffer);
|
||||||
if (result.isFiltered()) {
|
if (result.isFiltered()) {
|
||||||
String matchedVideoId = findVideoId(protobufBufferArray);
|
String matchedVideoId = findVideoId(buffer);
|
||||||
// Matched video will be null if in incognito mode.
|
// Matched video will be null if in incognito mode.
|
||||||
// Must pass a null id to correctly clear out the current video data.
|
// Must pass a null id to correctly clear out the current video data.
|
||||||
// Otherwise if a Short is opened in non-incognito, then incognito is enabled and another Short is opened,
|
// Otherwise if a Short is opened in non-incognito, then incognito is enabled and another Short is opened,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButt
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar;
|
import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
@ -13,7 +11,6 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import app.revanced.extension.shared.Logger;
|
import app.revanced.extension.shared.Logger;
|
||||||
import app.revanced.extension.shared.Utils;
|
|
||||||
import app.revanced.extension.youtube.settings.Settings;
|
import app.revanced.extension.youtube.settings.Settings;
|
||||||
import app.revanced.extension.youtube.shared.NavigationBar;
|
import app.revanced.extension.youtube.shared.NavigationBar;
|
||||||
import app.revanced.extension.youtube.shared.PlayerType;
|
import app.revanced.extension.youtube.shared.PlayerType;
|
||||||
|
|
@ -321,7 +318,7 @@ public final class ShortsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
|
boolean isFiltered(String identifier, String path, byte[] buffer,
|
||||||
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
|
||||||
if (contentType == FilterContentType.PATH) {
|
if (contentType == FilterContentType.PATH) {
|
||||||
if (matchedGroup == subscribeButton || matchedGroup == joinButton || matchedGroup == paidPromotionButton) {
|
if (matchedGroup == subscribeButton || matchedGroup == joinButton || matchedGroup == paidPromotionButton) {
|
||||||
|
|
@ -330,22 +327,22 @@ public final class ShortsFilter extends Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == useSoundButton) {
|
if (matchedGroup == useSoundButton) {
|
||||||
return useSoundButtonBuffer.check(protobufBufferArray).isFiltered();
|
return useSoundButtonBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == useTemplateButton) {
|
if (matchedGroup == useTemplateButton) {
|
||||||
return useTemplateButtonBuffer.check(protobufBufferArray).isFiltered();
|
return useTemplateButtonBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == shortsCompactFeedVideo) {
|
if (matchedGroup == shortsCompactFeedVideo) {
|
||||||
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(protobufBufferArray).isFiltered();
|
return shouldHideShortsFeedItems() && shortsCompactFeedVideoBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video action buttons (comment, share, remix) have the same path.
|
// Video action buttons (comment, share, remix) have the same path.
|
||||||
// Like and dislike are separate path filters and don't require buffer searching.
|
// Like and dislike are separate path filters and don't require buffer searching.
|
||||||
if (matchedGroup == shortsActionBar) {
|
if (matchedGroup == shortsActionBar) {
|
||||||
return videoActionButton.check(path).isFiltered()
|
return videoActionButton.check(path).isFiltered()
|
||||||
&& videoActionButtonBuffer.check(protobufBufferArray).isFiltered();
|
&& videoActionButtonBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedGroup == suggestedAction) {
|
if (matchedGroup == suggestedAction) {
|
||||||
|
|
@ -356,7 +353,7 @@ public final class ShortsFilter extends Filter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return suggestedActionsBuffer.check(protobufBufferArray).isFiltered();
|
return suggestedActionsBuffer.check(buffer).isFiltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ val lithoFilterPatch = bytecodePatch(
|
||||||
move-object/from16 v$freeRegister, p2
|
move-object/from16 v$freeRegister, p2
|
||||||
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
||||||
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
||||||
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->shouldFilter(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->isFiltered(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
||||||
move-result v$freeRegister
|
move-result v$freeRegister
|
||||||
if-eqz v$freeRegister, :unfiltered
|
if-eqz v$freeRegister, :unfiltered
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue