From 6bd7dca75bd2ea335a596aa93a8b767d39be5f83 Mon Sep 17 00:00:00 2001 From: g9q <83601416+g9q@users.noreply.github.com> Date: Mon, 8 Dec 2025 07:45:41 -0600 Subject: [PATCH] feat(Disney+): Add `Skip ads` patch (#6343) Co-authored-by: oSumAtrIX --- patches/api/patches.api | 4 +++ .../patches/disneyplus/Fingerprints.kt | 19 ++++++++++++++ .../patches/disneyplus/SkipAdsPatch.kt | 25 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/disneyplus/SkipAdsPatch.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index a7c4c94da..d4a9a987a 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -188,6 +188,10 @@ public final class app/revanced/patches/crunchyroll/ads/HideAdsPatchKt { public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/disneyplus/ads/SkipAdsPatchKt { + public static final fun getSkipAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/duolingo/ad/DisableAdsPatchKt { public static final fun getDisableAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt new file mode 100644 index 000000000..5cd67cba8 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/disneyplus/Fingerprints.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.disneyplus.ads + +import app.revanced.patcher.fingerprint + +internal val insertionGetPointsFingerprint = fingerprint { + returns("Ljava/util/List") + custom { method, _ -> + method.name == "getPoints" && + method.definingClass == "Lcom/dss/sdk/internal/media/Insertion;" + } +} + +internal val insertionGetRangesFingerprint = fingerprint { + returns("Ljava/util/List") + custom { method, _ -> + method.name == "getRanges" && + method.definingClass == "Lcom/dss/sdk/internal/media/Insertion;" + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/disneyplus/SkipAdsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/disneyplus/SkipAdsPatch.kt new file mode 100644 index 000000000..5b0f551cd --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/disneyplus/SkipAdsPatch.kt @@ -0,0 +1,25 @@ +package app.revanced.patches.disneyplus.ads + +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.patch.bytecodePatch + +@Suppress("unused") +val skipAdsPatch = bytecodePatch( + name = "Skip ads", + description = "Automatically skips ads.", +) { + compatibleWith("com.disney.disneyplus") + + execute { + arrayOf(insertionGetPointsFingerprint, insertionGetRangesFingerprint).forEach { + it.method.addInstructions( + 0, + """ + new-instance v0, Ljava/util/ArrayList; + invoke-direct {v0}, Ljava/util/ArrayList;->()V + return-object v0 + """, + ) + } + } +}