refactor(hide-shorts-component): add Hide shorts player info panels settings

This commit is contained in:
inotia00 2023-04-08 06:38:39 +09:00
parent c505d28c1a
commit ff43393daa
6 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.layout.general.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object ShortsInfoPanelFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId
} == true
}
)

View File

@ -28,6 +28,7 @@ import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
SettingsPatch::class,
SharedResourceIdPatch::class,
ShortsCommentButtonPatch::class,
ShortsInfoPanelPatch::class,
ShortsRemixButtonPatch::class,
ShortsSubscriptionsButtonPatch::class
]

View File

@ -0,0 +1,46 @@
package app.revanced.patches.youtube.layout.general.shortscomponent.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.shortscomponent.fingerprints.ShortsInfoPanelFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("hide-shorts-info-panel")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsInfoPanelPatch : BytecodePatch(
listOf(ShortsInfoPanelFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsInfoPanelFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId
} + 3
val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA
method.addInstructions(
insertIndex + 1, """
invoke-static {v$insertRegister}, $GENERAL->hideShortsPlayerInfoPanel(Landroid/view/ViewGroup;)Landroid/view/ViewGroup;
move-result-object v$insertRegister
"""
)
}
} ?: return ShortsInfoPanelFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View File

@ -40,6 +40,7 @@ class SharedResourceIdPatch : ResourcePatch {
var layoutVideo: Long = -1
var liveChatButtonId: Long = -1
var reelPlayerFooterLabelId: Long = -1
var reelPlayerInfoPanelLabelId: Long = -1
var reelPlayerPausedLabelId: Long = -1
var reelRemixLabelId: Long = -1
var relatedChipCloudMarginLabelId: Long = -1
@ -78,6 +79,7 @@ class SharedResourceIdPatch : ResourcePatch {
layoutVideo = find(LAYOUT, "endscreen_element_layout_video")
liveChatButtonId = find(ID, "live_chat_overlay_button")
reelPlayerFooterLabelId = find(LAYOUT, "reel_player_dyn_footer_vert_stories3")
reelPlayerInfoPanelLabelId = find(ID, "reel_player_info_panel")
reelPlayerPausedLabelId = find(ID, "reel_player_paused_state_buttons")
reelRemixLabelId = find(ID, "reel_dyn_remix")
relatedChipCloudMarginLabelId = find(LAYOUT, "related_chip_cloud_reduced_margins")

View File

@ -437,6 +437,7 @@ Please do not report any issues you encounter while using this feature."</string
<string name="revanced_hide_shorts_player_comments_button_summary_on">Shorts player comments button is hidden</string>
<string name="revanced_hide_shorts_player_comments_button_title">Hide shorts player comments button</string>
<string name="revanced_hide_shorts_player_component_title">Hide shorts player component</string>
<string name="revanced_hide_shorts_player_info_panel_title">Hide shorts player info panels</string>
<string name="revanced_hide_shorts_player_join_button_summary_off">Shorts player join button is shown</string>
<string name="revanced_hide_shorts_player_join_button_summary_on">Shorts player join button is hidden</string>
<string name="revanced_hide_shorts_player_join_button_title">Hide shorts player join button</string>

View File

@ -8,6 +8,8 @@
<string name="revanced_backup_title">@string/settings_ie</string>
<string name="revanced_extended_settings_title">ReVanced Extended</string>
<string name="revanced_hide_shorts_player_info_panel_summary_off">@string/revanced_hide_info_panel_summary_off</string>
<string name="revanced_hide_shorts_player_info_panel_summary_on">@string/revanced_hide_info_panel_summary_on</string>
<string name="revanced_whitelisting_speed_button">@string/camera_speed_button_label</string>
<string name="revanced_icons_blue">afn / blue</string>