From 10e170a7302fdb585efee663ca13c814aea46c54 Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Sat, 20 Apr 2024 23:37:51 +0100 Subject: [PATCH] feat(YT Music - Hide 'Get Music Premium' label): Remove occurences of label in settings (#3046) Co-authored-by: oSumAtrIX --- .../layout/premium/HideGetPremiumPatch.kt | 17 ++++++++++++++-- .../fingerprints/HideGetPremiumFingerprint.kt | 2 ++ .../MembershipSettingsFingerprint.kt | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/MembershipSettingsFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt index 4be4470dc..4475dafce 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/HideGetPremiumPatch.kt @@ -2,23 +2,28 @@ package app.revanced.patches.music.layout.premium 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.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint +import app.revanced.patches.music.layout.premium.fingerprints.MembershipSettingsFingerprint import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @Patch( name = "Hide 'Get Music Premium' label", - description = "Hides the red \"Get Music Premium\" label from the account menu.", + description = "Hides the \"Get Music Premium\" label from the account menu and settings.", compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")], ) @Suppress("unused") object HideGetPremiumPatch : BytecodePatch( - setOf(HideGetPremiumFingerprint), + setOf( + HideGetPremiumFingerprint, + MembershipSettingsFingerprint, + ), ) { override fun execute(context: BytecodeContext) { HideGetPremiumFingerprint.result?.let { @@ -41,5 +46,13 @@ object HideGetPremiumPatch : BytecodePatch( ) } } ?: throw HideGetPremiumFingerprint.exception + + MembershipSettingsFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const/4 v0, 0x0 + return-object v0 + """, + ) ?: throw MembershipSettingsFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt index e97251de5..c5c346409 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/HideGetPremiumFingerprint.kt @@ -12,6 +12,8 @@ internal object HideGetPremiumFingerprint : MethodFingerprint( listOf( Opcode.IF_NEZ, Opcode.CONST_16, + Opcode.GOTO, + Opcode.NOP, Opcode.INVOKE_VIRTUAL, ), listOf("FEmusic_history", "FEmusic_offline"), diff --git a/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/MembershipSettingsFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/MembershipSettingsFingerprint.kt new file mode 100644 index 000000000..0f6c8b661 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/layout/premium/fingerprints/MembershipSettingsFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.music.layout.premium.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 + +internal object MembershipSettingsFingerprint : MethodFingerprint( + returnType = "Ljava/lang/CharSequence;", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.INVOKE_INTERFACE, + Opcode.MOVE_RESULT_OBJECT, + Opcode.INVOKE_VIRTUAL, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IF_EQZ, + Opcode.IGET_OBJECT + ) +)