From f9517d2058c7561cf89b59ed36f690417dc076f7 Mon Sep 17 00:00:00 2001 From: OxrxL <108184954+OxrxL@users.noreply.github.com> Date: Wed, 19 Oct 2022 11:31:42 +0200 Subject: [PATCH] fix(youtube/video-ads): block earlier in call hirarchy (#813) --- .../video/fingerprints/LoadAdsFingerprint.kt | 7 +++--- .../youtube/ad/video/patch/VideoAdsPatch.kt | 25 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/LoadAdsFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/LoadAdsFingerprint.kt index 7d1b85e0e..1ef079761 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/LoadAdsFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/fingerprints/LoadAdsFingerprint.kt @@ -5,16 +5,15 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility -import org.jf.dexlib2.Opcode @Name("load-ads-fingerprint") @VideoAdsCompatibility @Version("0.0.1") object LoadAdsFingerprint : MethodFingerprint( - opcodes = listOf(Opcode.INVOKE_INTERFACE_RANGE), strings = listOf( - "Received unsupported ad type, this should never happen.", - "AdBreakRenderer path ad playerResponse cannot be deserialized." + "OnFulfillmentTriggersActivated has non registered slot", + "markFillRequested", + "Trying to enter a slot when a slot of same type and physical position is already active. Its status: ", ) ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt index fcf20c127..d08920a77 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt @@ -41,21 +41,16 @@ class VideoAdsPatch : BytecodePatch( ) ) - with(LoadAdsFingerprint.result!!) { - val insertIndex = scanResult.patternScanResult!!.startIndex - with(mutableMethod) { - addInstructions( - insertIndex, - """ - invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z - move-result v4 - if-nez v4, :show_video_ads - return-object v9 - """, - listOf(ExternalLabel("show_video_ads", instruction(insertIndex))) - ) - } - } + val lithoAdsFingerprintMethod = LoadAdsFingerprint.result!!.mutableMethod + + lithoAdsFingerprintMethod.addInstructions( + 0, """ + invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z + move-result v0 + if-nez v0, :show_video_ads + return-void + """, listOf(ExternalLabel("show_video_ads", lithoAdsFingerprintMethod.instruction(0))) + ) return PatchResultSuccess() }