mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-05-02 23:54:34 +02:00
fix(YouTube - Hide Shorts components): Hide action buttons A/B button layout (#4889)
This commit is contained in:
parent
40fa1689e8
commit
9dcd3d35dd
@ -1,6 +1,5 @@
|
||||
package app.revanced.extension.youtube.patches.components;
|
||||
|
||||
import static app.revanced.extension.shared.Utils.hideViewUnderCondition;
|
||||
import static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton;
|
||||
|
||||
import android.view.View;
|
||||
@ -52,6 +51,7 @@ public final class ShortsFilter extends Filter {
|
||||
private final StringFilterGroup suggestedAction;
|
||||
private final ByteArrayFilterGroupList suggestedActionsGroupList = new ByteArrayFilterGroupList();
|
||||
|
||||
private final StringFilterGroup shortsActionBar;
|
||||
private final StringFilterGroup actionButton;
|
||||
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();
|
||||
|
||||
@ -141,6 +141,16 @@ public final class ShortsFilter extends Filter {
|
||||
"like_fountain.eml"
|
||||
);
|
||||
|
||||
StringFilterGroup likeButton = new StringFilterGroup(
|
||||
Settings.HIDE_SHORTS_LIKE_BUTTON,
|
||||
"shorts_like_button.eml"
|
||||
);
|
||||
|
||||
StringFilterGroup dislikeButton = new StringFilterGroup(
|
||||
Settings.HIDE_SHORTS_DISLIKE_BUTTON,
|
||||
"shorts_dislike_button.eml"
|
||||
);
|
||||
|
||||
joinButton = new StringFilterGroup(
|
||||
Settings.HIDE_SHORTS_JOIN_BUTTON,
|
||||
"sponsor_button"
|
||||
@ -156,9 +166,15 @@ public final class ShortsFilter extends Filter {
|
||||
"reel_player_disclosure.eml"
|
||||
);
|
||||
|
||||
shortsActionBar = new StringFilterGroup(
|
||||
null,
|
||||
"shorts_action_bar.eml"
|
||||
);
|
||||
|
||||
actionButton = new StringFilterGroup(
|
||||
null,
|
||||
"shorts_video_action_button.eml"
|
||||
// Can be simply 'button.eml' or 'shorts_video_action_button.eml'
|
||||
"button.eml"
|
||||
);
|
||||
|
||||
suggestedAction = new StringFilterGroup(
|
||||
@ -167,27 +183,16 @@ public final class ShortsFilter extends Filter {
|
||||
);
|
||||
|
||||
addPathCallbacks(
|
||||
shortsCompactFeedVideoPath, suggestedAction, actionButton, joinButton, subscribeButton,
|
||||
paidPromotionButton, pausedOverlayButtons, channelBar, fullVideoLinkLabel, videoTitle,
|
||||
reelSoundMetadata, soundButton, infoPanel, stickers, likeFountain
|
||||
shortsCompactFeedVideoPath, joinButton, subscribeButton, paidPromotionButton,
|
||||
shortsActionBar, suggestedAction, pausedOverlayButtons, channelBar,
|
||||
fullVideoLinkLabel, videoTitle, reelSoundMetadata, soundButton, infoPanel,
|
||||
stickers, likeFountain, likeButton, dislikeButton
|
||||
);
|
||||
|
||||
//
|
||||
// Action buttons
|
||||
// All other action buttons.
|
||||
//
|
||||
videoActionButtonGroupList.addAll(
|
||||
// This also appears as the path item 'shorts_like_button.eml'
|
||||
new ByteArrayFilterGroup(
|
||||
Settings.HIDE_SHORTS_LIKE_BUTTON,
|
||||
"reel_like_button",
|
||||
"reel_like_toggled_button"
|
||||
),
|
||||
// This also appears as the path item 'shorts_dislike_button.eml'
|
||||
new ByteArrayFilterGroup(
|
||||
Settings.HIDE_SHORTS_DISLIKE_BUTTON,
|
||||
"reel_dislike_button",
|
||||
"reel_dislike_toggled_button"
|
||||
),
|
||||
new ByteArrayFilterGroup(
|
||||
Settings.HIDE_SHORTS_COMMENTS_BUTTON,
|
||||
"reel_comment_button"
|
||||
@ -286,9 +291,11 @@ public final class ShortsFilter extends Filter {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Video action buttons (like, dislike, comment, share, remix) have the same path.
|
||||
if (matchedGroup == actionButton) {
|
||||
if (videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) {
|
||||
// Video action buttons (comment, share, remix) have the same path.
|
||||
// Like and dislike are separate path filters and don't require buffer searching.
|
||||
if (matchedGroup == shortsActionBar) {
|
||||
if (actionButton.check(path).isFiltered()
|
||||
&& videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) {
|
||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||
}
|
||||
return false;
|
||||
@ -392,37 +399,6 @@ public final class ShortsFilter extends Filter {
|
||||
return original;
|
||||
}
|
||||
|
||||
// region Hide the buttons in older versions of YouTube. New versions use Litho.
|
||||
|
||||
public static void hideLikeButton(final View likeButtonView) {
|
||||
// Cannot set the visibility to gone for like/dislike,
|
||||
// as some other unknown YT code also sets the visibility after this hook.
|
||||
//
|
||||
// Setting the view to 0dp works, but that leaves a blank space where
|
||||
// the button was (only relevant for dislikes button).
|
||||
//
|
||||
// Instead remove the view from the parent.
|
||||
Utils.hideViewByRemovingFromParentUnderCondition(Settings.HIDE_SHORTS_LIKE_BUTTON, likeButtonView);
|
||||
}
|
||||
|
||||
public static void hideDislikeButton(final View dislikeButtonView) {
|
||||
Utils.hideViewByRemovingFromParentUnderCondition(Settings.HIDE_SHORTS_DISLIKE_BUTTON, dislikeButtonView);
|
||||
}
|
||||
|
||||
public static void hideShortsCommentsButton(final View commentsButtonView) {
|
||||
hideViewUnderCondition(Settings.HIDE_SHORTS_COMMENTS_BUTTON, commentsButtonView);
|
||||
}
|
||||
|
||||
public static void hideShortsRemixButton(final View remixButtonView) {
|
||||
hideViewUnderCondition(Settings.HIDE_SHORTS_REMIX_BUTTON, remixButtonView);
|
||||
}
|
||||
|
||||
public static void hideShortsShareButton(final View shareButtonView) {
|
||||
hideViewUnderCondition(Settings.HIDE_SHORTS_SHARE_BUTTON, shareButtonView);
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
public static void setNavigationBar(PivotBar view) {
|
||||
pivotBarRef = new WeakReference<>(view);
|
||||
}
|
||||
|
@ -25,11 +25,6 @@ internal val shortsBottomBarContainerFingerprint = fingerprint {
|
||||
literal { bottomBarContainer }
|
||||
}
|
||||
|
||||
internal val createShortsButtonsFingerprint = fingerprint {
|
||||
returns("V")
|
||||
literal { reelPlayerRightCellButtonHeight }
|
||||
}
|
||||
|
||||
internal val renderBottomNavigationBarFingerprint = fingerprint {
|
||||
returns("V")
|
||||
parameters("Ljava/lang/String;")
|
||||
|
@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.booleanOption
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
@ -22,14 +21,14 @@ import app.revanced.patches.youtube.misc.playservice.is_19_41_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import app.revanced.util.forEachLiteralValueInstruction
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
internal var reelPlayerRightCellButtonHeight = -1L
|
||||
private set
|
||||
internal var bottomBarContainer = -1L
|
||||
private set
|
||||
internal var reelPlayerRightPivotV2Size = -1L
|
||||
@ -137,11 +136,6 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
|
||||
}
|
||||
}
|
||||
|
||||
reelPlayerRightCellButtonHeight = resourceMappings[
|
||||
"dimen",
|
||||
"reel_player_right_cell_button_height",
|
||||
]
|
||||
|
||||
bottomBarContainer = resourceMappings[
|
||||
"id",
|
||||
"bottom_bar_container",
|
||||
@ -186,15 +180,6 @@ val hideShortsComponentsPatch = bytecodePatch(
|
||||
hideShortsWidgetOption()
|
||||
|
||||
execute {
|
||||
// region Hide the Shorts buttons in older versions of YouTube.
|
||||
|
||||
// Some Shorts buttons are views, hide them by setting their visibility to GONE.
|
||||
ShortsButtons.entries.forEach { button -> button.injectHideCall(createShortsButtonsFingerprint.method) }
|
||||
|
||||
// endregion
|
||||
|
||||
// region Hide the Shorts buttons in newer versions of YouTube.
|
||||
|
||||
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
forEachLiteralValueInstruction(
|
||||
@ -211,7 +196,7 @@ val hideShortsComponentsPatch = bytecodePatch(
|
||||
"""
|
||||
invoke-static { v$sizeRegister }, $FILTER_CLASS_DESCRIPTOR->getSoundButtonSize(I)I
|
||||
move-result v$sizeRegister
|
||||
""",
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
@ -261,31 +246,10 @@ val hideShortsComponentsPatch = bytecodePatch(
|
||||
"""
|
||||
invoke-static { v$heightRegister }, $FILTER_CLASS_DESCRIPTOR->getNavigationBarHeight(I)I
|
||||
move-result v$heightRegister
|
||||
""",
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
}
|
||||
|
||||
private enum class ShortsButtons(private val resourceName: String, private val methodName: String) {
|
||||
LIKE("reel_dyn_like", "hideLikeButton"),
|
||||
DISLIKE("reel_dyn_dislike", "hideDislikeButton"),
|
||||
COMMENTS("reel_dyn_comment", "hideShortsCommentsButton"),
|
||||
REMIX("reel_dyn_remix", "hideShortsRemixButton"),
|
||||
SHARE("reel_dyn_share", "hideShortsShareButton"),
|
||||
;
|
||||
|
||||
fun injectHideCall(method: MutableMethod) {
|
||||
val referencedIndex = method.indexOfFirstResourceIdOrThrow(resourceName)
|
||||
|
||||
val setIdIndex = method.indexOfFirstInstructionOrThrow(referencedIndex) {
|
||||
opcode == Opcode.INVOKE_VIRTUAL && getReference<MethodReference>()?.name == "setId"
|
||||
}
|
||||
|
||||
val viewRegister = method.getInstruction<FiveRegisterInstruction>(setIdIndex).registerC
|
||||
|
||||
method.injectHideViewCall(setIdIndex + 1, viewRegister, FILTER_CLASS_DESCRIPTOR, methodName)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user