mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 09:34:37 +02:00
feat(YouTube/Hide account menu): Hide account menu
now also hides elements in the You
tab
This commit is contained in:
parent
1d052a84e0
commit
73c8ad6ea4
@ -3,20 +3,26 @@ package app.revanced.patches.youtube.general.accountmenu
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountListFingerprint
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountListParentFingerprint
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuFingerprint
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuParentFingerprint
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuPatchFingerprint
|
||||
import app.revanced.patches.youtube.general.accountmenu.fingerprints.SetViewGroupMarginFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Hide account menu",
|
||||
description = "Hide account menu elements.",
|
||||
description = "Hide elements of the account menu and You tab.",
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
@ -46,10 +52,34 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
)
|
||||
@Suppress("unused")
|
||||
object AccountMenuPatch : BytecodePatch(
|
||||
setOf(AccountMenuParentFingerprint)
|
||||
setOf(
|
||||
AccountListParentFingerprint,
|
||||
AccountMenuParentFingerprint,
|
||||
AccountMenuPatchFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
AccountListParentFingerprint.result?.let { parentResult ->
|
||||
AccountListFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
)
|
||||
}.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 3
|
||||
val targetInstruction = getInstruction<FiveRegisterInstruction>(targetIndex)
|
||||
|
||||
addInstruction(
|
||||
targetIndex,
|
||||
"invoke-static {v${targetInstruction.registerC}, v${targetInstruction.registerD}}, " +
|
||||
"$GENERAL->hideAccountList(Landroid/view/View;Ljava/lang/CharSequence;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw AccountListFingerprint.exception
|
||||
} ?: throw AccountListParentFingerprint.exception
|
||||
|
||||
AccountMenuParentFingerprint.result?.let { parentResult ->
|
||||
AccountMenuFingerprint.also {
|
||||
it.resolve(
|
||||
@ -68,6 +98,25 @@ object AccountMenuPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
} ?: throw AccountMenuFingerprint.exception
|
||||
|
||||
SetViewGroupMarginFingerprint.also {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.classDef
|
||||
)
|
||||
}.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val setViewGroupMarginIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val setViewGroupMarginReference = getInstruction<ReferenceInstruction>(setViewGroupMarginIndex).reference
|
||||
|
||||
AccountMenuPatchFingerprint.result?.mutableMethod?.addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x0
|
||||
invoke-static {p0, v0, v0}, $setViewGroupMarginReference
|
||||
"""
|
||||
) ?: throw AccountMenuPatchFingerprint.exception
|
||||
}
|
||||
} ?: throw SetViewGroupMarginFingerprint.exception
|
||||
} ?: throw AccountMenuParentFingerprint.exception
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,18 @@
|
||||
package app.revanced.patches.youtube.general.accountmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object AccountListFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PROTECTED or AccessFlags.FINAL or AccessFlags.SYNTHETIC,
|
||||
opcodes = listOf(
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET
|
||||
)
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.youtube.general.accountmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.CompactListItem
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
|
||||
object AccountListParentFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(CompactListItem) }
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.general.accountmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
object AccountMenuPatchFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lapp/revanced/integrations/patches/layout/GeneralPatch;"
|
||||
&& methodDef.name == "hideAccountMenu"
|
||||
}
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
package app.revanced.patches.youtube.general.accountmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object SetViewGroupMarginFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||
parameters = listOf("Z"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
)
|
||||
)
|
@ -32,6 +32,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var BottomUiContainerStub: Long = -1
|
||||
var ChannelListSubMenu: Long = -1
|
||||
var CompactLink: Long = -1
|
||||
var CompactListItem: Long = -1
|
||||
var ControlsLayoutStub: Long = -1
|
||||
var CoreContainer: Long = -1
|
||||
var DarkSplashAnimation: Long = -1
|
||||
@ -113,6 +114,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
BottomUiContainerStub = find(ID, "bottom_ui_container_stub")
|
||||
ChannelListSubMenu = find(LAYOUT, "channel_list_sub_menu")
|
||||
CompactLink = find(LAYOUT, "compact_link")
|
||||
CompactListItem = find(LAYOUT, "compact_list_item")
|
||||
ControlsLayoutStub = find(ID, "controls_layout_stub")
|
||||
CoreContainer = find(ID, "core_container")
|
||||
DarkSplashAnimation = find(ID, "dark_splash_animation")
|
||||
|
@ -186,7 +186,8 @@ You tab > View channel > Menu > Settings"</string>
|
||||
<string name="revanced_general">General</string>
|
||||
<string name="revanced_haptic_feedback_title">Haptic feedback</string>
|
||||
<string name="revanced_hide_account_menu_filter_strings_title">Edit account menu filter</string>
|
||||
<string name="revanced_hide_account_menu_summary">Known issue: May not work in landscape mode or on high dpi devices</string>
|
||||
<string name="revanced_hide_account_menu_summary">"Hide elements of the account menu and You tab
|
||||
Some components may not be hidden"</string>
|
||||
<string name="revanced_hide_account_menu_title">Hide account menu</string>
|
||||
<string name="revanced_hide_album_card_summary_off">Album cards are shown</string>
|
||||
<string name="revanced_hide_album_card_summary_on">Album cards are hidden</string>
|
||||
|
@ -170,7 +170,7 @@
|
||||
|
||||
<!-- SETTINGS: HIDE_ACCOUNT_MENU
|
||||
<SwitchPreference android:title="@string/revanced_hide_account_menu_title" android:key="revanced_hide_account_menu" android:defaultValue="false" android:summary="@string/revanced_hide_account_menu_summary" />
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:title="@string/revanced_hide_account_menu_filter_strings_title" android:key="revanced_hide_account_menu_filter_strings" android:summary="@string/revanced_hide_account_menu_filter_strings_summary" android:defaultValue="YouTube Music\nYouTube Kids" android:inputType="textMultiLine" />SETTINGS: HIDE_ACCOUNT_MENU -->
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:title="@string/revanced_hide_account_menu_filter_strings_title" android:key="revanced_hide_account_menu_filter_strings" android:summary="@string/revanced_hide_account_menu_filter_strings_summary" android:defaultValue="" android:inputType="textMultiLine" />SETTINGS: HIDE_ACCOUNT_MENU -->
|
||||
|
||||
<!-- SETTINGS: HIDE_AUTO_PLAYER_POPUP_PANELS
|
||||
<SwitchPreference android:title="@string/revanced_hide_auto_player_popup_panels_title" android:key="revanced_hide_auto_player_popup_panels" android:defaultValue="true" android:summaryOn="@string/revanced_hide_auto_player_popup_panels_summary_on" android:summaryOff="@string/revanced_hide_auto_player_popup_panels_summary_off" />SETTINGS: HIDE_AUTO_PLAYER_POPUP_PANELS -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user