From e65dc3d261eebe06c2fe44b2953043ba7da78fa1 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:41:02 +0900 Subject: [PATCH] fix(YouTube Music/Hide general ads): `Hide premium renewal banner` is not hidden --- .../music/ads/general/GeneralAdsPatch.kt | 13 +++++-------- .../fingerprints/NotifierShelfFingerprint.kt | 18 ++++++++---------- .../utils/resourceid/SharedResourceIdPatch.kt | 2 ++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt index 16223f529..51fa34840 100644 --- a/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/ads/general/GeneralAdsPatch.kt @@ -13,6 +13,7 @@ import app.revanced.patches.music.utils.integrations.Constants.ADS_PATH import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH import app.revanced.patches.music.utils.litho.LithoFilterPatch import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ButtonContainer import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.FloatingLayout import app.revanced.patches.music.utils.settings.CategoryType import app.revanced.patches.music.utils.settings.SettingsPatch @@ -62,17 +63,13 @@ object GeneralAdsPatch : BytecodePatch( */ NotifierShelfFingerprint.result?.let { it.mutableMethod.apply { - val linearLayoutIndex = it.scanResult.patternScanResult!!.startIndex + val linearLayoutIndex = getWideLiteralInstructionIndex(ButtonContainer) + 3 val linearLayoutRegister = - getInstruction(linearLayoutIndex).registerC - - val textViewIndex = linearLayoutIndex + 2 - val textViewRegister = - getInstruction(textViewIndex).registerA + getInstruction(linearLayoutIndex).registerA addInstruction( - textViewIndex, - "invoke-static {v$linearLayoutRegister, v$textViewRegister}, $ADS_PATH/PremiumRenewalPatch;->hidePremiumRenewal(Landroid/widget/LinearLayout;Landroid/view/View;)V" + linearLayoutIndex + 1, + "invoke-static {v$linearLayoutRegister}, $ADS_PATH/PremiumRenewalPatch;->hidePremiumRenewal(Landroid/widget/LinearLayout;)V" ) } } ?: throw NotifierShelfFingerprint.exception diff --git a/src/main/kotlin/app/revanced/patches/music/ads/general/fingerprints/NotifierShelfFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/ads/general/fingerprints/NotifierShelfFingerprint.kt index 5f88e662d..e75bc9600 100644 --- a/src/main/kotlin/app/revanced/patches/music/ads/general/fingerprints/NotifierShelfFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/ads/general/fingerprints/NotifierShelfFingerprint.kt @@ -1,19 +1,17 @@ package app.revanced.patches.music.ads.general.fingerprints import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ButtonContainer import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicNotifierShelf -import app.revanced.util.fingerprint.LiteralValueFingerprint +import app.revanced.util.containsWideLiteralInstructionIndex import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode -object NotifierShelfFingerprint : LiteralValueFingerprint( +object NotifierShelfFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - opcodes = listOf( - Opcode.INVOKE_VIRTUAL, - Opcode.MOVE_RESULT_OBJECT, - Opcode.CHECK_CAST, - Opcode.IPUT_OBJECT - ), - literalSupplier = { MusicNotifierShelf } + customFingerprint = { methodDef, _ -> + methodDef.containsWideLiteralInstructionIndex(MusicNotifierShelf) + && methodDef.containsWideLiteralInstructionIndex(ButtonContainer) + } ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt index 493147abe..e2510d010 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt @@ -17,6 +17,7 @@ import app.revanced.patches.shared.patch.mapping.ResourceType.STYLE object SharedResourceIdPatch : ResourcePatch() { var AccountSwitcherAccessibility: Long = -1 var ActionsContainer: Long = -1 + var ButtonContainer: Long = -1 var ButtonIconPaddingMedium: Long = -1 var ChipCloud: Long = -1 var ColorGrey: Long = -1 @@ -46,6 +47,7 @@ object SharedResourceIdPatch : ResourcePatch() { AccountSwitcherAccessibility = find(STRING, "account_switcher_accessibility_label") ActionsContainer = find(ID, "actions_container") + ButtonContainer = find(ID, "button_container") ButtonIconPaddingMedium = find(DIMEN, "button_icon_padding_medium") ChipCloud = find(LAYOUT, "chip_cloud") ColorGrey = find(COLOR, "ytm_color_grey_12")