mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-05-03 16:14:28 +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;
|
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 static app.revanced.extension.youtube.shared.NavigationBar.NavigationButton;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -52,6 +51,7 @@ public final class ShortsFilter extends Filter {
|
|||||||
private final StringFilterGroup suggestedAction;
|
private final StringFilterGroup suggestedAction;
|
||||||
private final ByteArrayFilterGroupList suggestedActionsGroupList = new ByteArrayFilterGroupList();
|
private final ByteArrayFilterGroupList suggestedActionsGroupList = new ByteArrayFilterGroupList();
|
||||||
|
|
||||||
|
private final StringFilterGroup shortsActionBar;
|
||||||
private final StringFilterGroup actionButton;
|
private final StringFilterGroup actionButton;
|
||||||
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();
|
private final ByteArrayFilterGroupList videoActionButtonGroupList = new ByteArrayFilterGroupList();
|
||||||
|
|
||||||
@ -141,6 +141,16 @@ public final class ShortsFilter extends Filter {
|
|||||||
"like_fountain.eml"
|
"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(
|
joinButton = new StringFilterGroup(
|
||||||
Settings.HIDE_SHORTS_JOIN_BUTTON,
|
Settings.HIDE_SHORTS_JOIN_BUTTON,
|
||||||
"sponsor_button"
|
"sponsor_button"
|
||||||
@ -156,9 +166,15 @@ public final class ShortsFilter extends Filter {
|
|||||||
"reel_player_disclosure.eml"
|
"reel_player_disclosure.eml"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
shortsActionBar = new StringFilterGroup(
|
||||||
|
null,
|
||||||
|
"shorts_action_bar.eml"
|
||||||
|
);
|
||||||
|
|
||||||
actionButton = new StringFilterGroup(
|
actionButton = new StringFilterGroup(
|
||||||
null,
|
null,
|
||||||
"shorts_video_action_button.eml"
|
// Can be simply 'button.eml' or 'shorts_video_action_button.eml'
|
||||||
|
"button.eml"
|
||||||
);
|
);
|
||||||
|
|
||||||
suggestedAction = new StringFilterGroup(
|
suggestedAction = new StringFilterGroup(
|
||||||
@ -167,27 +183,16 @@ public final class ShortsFilter extends Filter {
|
|||||||
);
|
);
|
||||||
|
|
||||||
addPathCallbacks(
|
addPathCallbacks(
|
||||||
shortsCompactFeedVideoPath, suggestedAction, actionButton, joinButton, subscribeButton,
|
shortsCompactFeedVideoPath, joinButton, subscribeButton, paidPromotionButton,
|
||||||
paidPromotionButton, pausedOverlayButtons, channelBar, fullVideoLinkLabel, videoTitle,
|
shortsActionBar, suggestedAction, pausedOverlayButtons, channelBar,
|
||||||
reelSoundMetadata, soundButton, infoPanel, stickers, likeFountain
|
fullVideoLinkLabel, videoTitle, reelSoundMetadata, soundButton, infoPanel,
|
||||||
|
stickers, likeFountain, likeButton, dislikeButton
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action buttons
|
// All other action buttons.
|
||||||
//
|
//
|
||||||
videoActionButtonGroupList.addAll(
|
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(
|
new ByteArrayFilterGroup(
|
||||||
Settings.HIDE_SHORTS_COMMENTS_BUTTON,
|
Settings.HIDE_SHORTS_COMMENTS_BUTTON,
|
||||||
"reel_comment_button"
|
"reel_comment_button"
|
||||||
@ -286,9 +291,11 @@ public final class ShortsFilter extends Filter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video action buttons (like, dislike, comment, share, remix) have the same path.
|
// Video action buttons (comment, share, remix) have the same path.
|
||||||
if (matchedGroup == actionButton) {
|
// Like and dislike are separate path filters and don't require buffer searching.
|
||||||
if (videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) {
|
if (matchedGroup == shortsActionBar) {
|
||||||
|
if (actionButton.check(path).isFiltered()
|
||||||
|
&& videoActionButtonGroupList.check(protobufBufferArray).isFiltered()) {
|
||||||
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
return super.isFiltered(identifier, path, protobufBufferArray, matchedGroup, contentType, contentIndex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -392,37 +399,6 @@ public final class ShortsFilter extends Filter {
|
|||||||
return original;
|
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) {
|
public static void setNavigationBar(PivotBar view) {
|
||||||
pivotBarRef = new WeakReference<>(view);
|
pivotBarRef = new WeakReference<>(view);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,6 @@ internal val shortsBottomBarContainerFingerprint = fingerprint {
|
|||||||
literal { bottomBarContainer }
|
literal { bottomBarContainer }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val createShortsButtonsFingerprint = fingerprint {
|
|
||||||
returns("V")
|
|
||||||
literal { reelPlayerRightCellButtonHeight }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val renderBottomNavigationBarFingerprint = fingerprint {
|
internal val renderBottomNavigationBarFingerprint = fingerprint {
|
||||||
returns("V")
|
returns("V")
|
||||||
parameters("Ljava/lang/String;")
|
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.booleanOption
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patcher.patch.resourcePatch
|
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.addResources
|
||||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||||
import app.revanced.patches.shared.misc.mapping.get
|
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.playservice.versionCheckPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||||
import app.revanced.util.*
|
import app.revanced.util.findElementByAttributeValueOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import app.revanced.util.forEachLiteralValueInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
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.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
internal var reelPlayerRightCellButtonHeight = -1L
|
|
||||||
private set
|
|
||||||
internal var bottomBarContainer = -1L
|
internal var bottomBarContainer = -1L
|
||||||
private set
|
private set
|
||||||
internal var reelPlayerRightPivotV2Size = -1L
|
internal var reelPlayerRightPivotV2Size = -1L
|
||||||
@ -137,11 +136,6 @@ private val hideShortsComponentsResourcePatch = resourcePatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reelPlayerRightCellButtonHeight = resourceMappings[
|
|
||||||
"dimen",
|
|
||||||
"reel_player_right_cell_button_height",
|
|
||||||
]
|
|
||||||
|
|
||||||
bottomBarContainer = resourceMappings[
|
bottomBarContainer = resourceMappings[
|
||||||
"id",
|
"id",
|
||||||
"bottom_bar_container",
|
"bottom_bar_container",
|
||||||
@ -186,15 +180,6 @@ val hideShortsComponentsPatch = bytecodePatch(
|
|||||||
hideShortsWidgetOption()
|
hideShortsWidgetOption()
|
||||||
|
|
||||||
execute {
|
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)
|
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
|
||||||
|
|
||||||
forEachLiteralValueInstruction(
|
forEachLiteralValueInstruction(
|
||||||
@ -211,7 +196,7 @@ val hideShortsComponentsPatch = bytecodePatch(
|
|||||||
"""
|
"""
|
||||||
invoke-static { v$sizeRegister }, $FILTER_CLASS_DESCRIPTOR->getSoundButtonSize(I)I
|
invoke-static { v$sizeRegister }, $FILTER_CLASS_DESCRIPTOR->getSoundButtonSize(I)I
|
||||||
move-result v$sizeRegister
|
move-result v$sizeRegister
|
||||||
""",
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,31 +246,10 @@ val hideShortsComponentsPatch = bytecodePatch(
|
|||||||
"""
|
"""
|
||||||
invoke-static { v$heightRegister }, $FILTER_CLASS_DESCRIPTOR->getNavigationBarHeight(I)I
|
invoke-static { v$heightRegister }, $FILTER_CLASS_DESCRIPTOR->getNavigationBarHeight(I)I
|
||||||
move-result v$heightRegister
|
move-result v$heightRegister
|
||||||
""",
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// 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