From 2eb5e3afebe374a86e9da521d6441402130f0fd0 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:37:40 -0400 Subject: [PATCH] fix(YouTube - Return YouTube Dislike): Show correct value when swiping back to prior Short and disliking --- .../patches/ReturnYouTubeDislikePatch.java | 1 + .../ReturnYouTubeDislikeFilterPatch.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java index 8aa2c5ca5a..ec52ef076f 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/ReturnYouTubeDislikePatch.java @@ -664,6 +664,7 @@ public static void setLastLithoShortsVideoId(@Nullable String videoId) { if (videoIdIsSame(lastLithoShortsVideoData, videoId)) { return; } + if (videoId == null) { // Litho filter did not detect the video id. App is in incognito mode, // or the proto buffer structure was changed and the video id is no longer present. diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java index 11bffcc54e..8df0d1903e 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/ReturnYouTubeDislikeFilterPatch.java @@ -68,18 +68,23 @@ public static void newPlayerResponseVideoId(String videoId, boolean isShortAndOp private final ByteArrayFilterGroupList videoIdFilterGroup = new ByteArrayFilterGroupList(); public ReturnYouTubeDislikeFilterPatch() { - // Likes always seems to load before the dislikes, but if this - // ever changes then both likes and dislikes need callbacks. + // When a new Short is opened, the like buttons always seem to load before the dislike. + // But if swiping back to a previous video and liking/disliking, then only that single button reloads. + // So must check for both buttons. addPathCallbacks( - new StringFilterGroup(null, "|shorts_like_button.eml") + new StringFilterGroup(null, "|shorts_like_button.eml"), + new StringFilterGroup(null, "|shorts_dislike_button.eml") ); // After the likes icon name is some binary data and then the video id for that specific short. videoIdFilterGroup.addAll( - // Video was previously liked before video was opened. + // on_shadowed = Video was previously like/disliked before opening. + // off_shadowed = Video was not previously liked/disliked before opening. new ByteArrayFilterGroup(null, "ic_right_like_on_shadowed"), - // Video was not already liked. - new ByteArrayFilterGroup(null, "ic_right_like_off_shadowed") + new ByteArrayFilterGroup(null, "ic_right_like_off_shadowed"), + + new ByteArrayFilterGroup(null, "ic_right_dislike_on_shadowed"), + new ByteArrayFilterGroup(null, "ic_right_dislike_off_shadowed") ); } @@ -111,6 +116,7 @@ private String findVideoId(byte[] protobufBufferArray) { return videoId; } } + return null; } } @@ -132,6 +138,7 @@ private static boolean byteArrayContainsString(@NonNull byte[] array, @NonNull S return true; } } + return false; } } \ No newline at end of file