From becaad4a9876392b567478cdfe773956655901f0 Mon Sep 17 00:00:00 2001 From: ILoveOpenSourceApplications <117499019+ILoveOpenSourceApplications@users.noreply.github.com> Date: Sun, 4 Aug 2024 13:39:48 +0530 Subject: [PATCH] refactor(YouTube Music): Rename `Hide music video ads` to `Hide video ads` and add patch description (#3494) Co-authored-by: ILoveOpenSourceApplications Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> --- api/revanced-patches.api | 6 ++++ .../{HideMusicVideoAds.kt => HideVideoAds.kt} | 29 ++++++++++++------- ...nt.kt => ShowVideoAdsParentFingerprint.kt} | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) rename src/main/kotlin/app/revanced/patches/music/ad/video/{HideMusicVideoAds.kt => HideVideoAds.kt} (60%) rename src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/{ShowMusicVideoAdsParentFingerprint.kt => ShowVideoAdsParentFingerprint.kt} (84%) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index 14a4e3230..a30a71d22 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -423,6 +423,12 @@ public final class app/revanced/patches/music/ad/video/HideMusicVideoAds : app/r public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } +public final class app/revanced/patches/music/ad/video/HideVideoAds : app/revanced/patcher/patch/BytecodePatch { + public static final field INSTANCE Lapp/revanced/patches/music/ad/video/HideVideoAds; + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/music/ad/video/MusicVideoAdsPatch : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/music/ad/video/MusicVideoAdsPatch; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/HideMusicVideoAds.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt similarity index 60% rename from src/main/kotlin/app/revanced/patches/music/ad/video/HideMusicVideoAds.kt rename to src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt index eddec5b90..b374f4cb7 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/HideMusicVideoAds.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/HideVideoAds.kt @@ -6,11 +6,12 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsParentFingerprint +import app.revanced.patches.music.ad.video.fingerprints.ShowVideoAdsParentFingerprint import app.revanced.util.exception @Patch( - name = "Hide music video ads", + name = "Hide video ads", + description = "Hides ads that appear while listening to or streaming music videos, podcasts, or songs.", compatiblePackages = [ CompatiblePackage( "com.google.android.apps.youtube.music", @@ -25,24 +26,32 @@ import app.revanced.util.exception ], ) @Suppress("unused") -object HideMusicVideoAds : BytecodePatch( - setOf(ShowMusicVideoAdsParentFingerprint), +object HideVideoAds : BytecodePatch( + setOf(ShowVideoAdsParentFingerprint), ) { override fun execute(context: BytecodeContext) { - ShowMusicVideoAdsParentFingerprint.result?.let { - val showMusicVideoAdsMethod = context + ShowVideoAdsParentFingerprint.result?.let { + val showVideoAdsMethod = context .toMethodWalker(it.mutableMethod) .nextMethod(it.scanResult.patternScanResult!!.startIndex + 1, true).getMethod() as MutableMethod - showMusicVideoAdsMethod.addInstruction(0, "const/4 p1, 0x0") - } ?: throw ShowMusicVideoAdsParentFingerprint.exception + showVideoAdsMethod.addInstruction(0, "const/4 p1, 0x0") + } ?: throw ShowVideoAdsParentFingerprint.exception } } -@Deprecated("This patch class has been renamed to HideMusicVideoAds.") +@Deprecated("This patch class has been renamed to HideVideoAds.") +object HideMusicVideoAds : BytecodePatch( + dependencies = setOf(HideVideoAds::class) +) { + override fun execute(context: BytecodeContext) { + } +} + +@Deprecated("This patch class has been renamed to HideVideoAds.") object MusicVideoAdsPatch : BytecodePatch( dependencies = setOf(HideMusicVideoAds::class), ) { override fun execute(context: BytecodeContext) { } -} +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsParentFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowVideoAdsParentFingerprint.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsParentFingerprint.kt rename to src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowVideoAdsParentFingerprint.kt index 5996ee98d..5bdd644bc 100644 --- a/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowMusicVideoAdsParentFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/ad/video/fingerprints/ShowVideoAdsParentFingerprint.kt @@ -3,7 +3,7 @@ package app.revanced.patches.music.ad.video.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint import com.android.tools.smali.dexlib2.Opcode -internal object ShowMusicVideoAdsParentFingerprint : MethodFingerprint( +internal object ShowVideoAdsParentFingerprint : MethodFingerprint( opcodes = listOf( Opcode.MOVE_RESULT_OBJECT, Opcode.INVOKE_VIRTUAL,