mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-01 12:05:35 +02:00
fix(video-ads): return empty list in correct method
This commit is contained in:
parent
6199e89cbd
commit
bbcf0501d4
@ -5,14 +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(
|
||||
strings = listOf("Unexpected playerAd type: "),
|
||||
opcodes = listOf(Opcode.INVOKE_INTERFACE_RANGE),
|
||||
customFingerprint = { method ->
|
||||
method.parameterTypes.size > 0 && method.parameterTypes.first() == "Ljava/lang/String;"
|
||||
method.parameterTypes.size > 0 && method.parameterTypes.first().endsWith("InstreamAdBreak;")
|
||||
}
|
||||
)
|
@ -41,19 +41,20 @@ class VideoAdsPatch : BytecodePatch(
|
||||
)
|
||||
)
|
||||
|
||||
LoadAdsFingerprint.result!!.mutableMethod.let { method ->
|
||||
method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z
|
||||
move-result v1
|
||||
if-nez v1, :show_video_ads
|
||||
new-instance v3, Ljava/util/ArrayList;
|
||||
invoke-direct { v3 }, Ljava/util/ArrayList;-><init>()V
|
||||
return-object v3
|
||||
""",
|
||||
listOf(ExternalLabel("show_video_ads", method.instruction(0)))
|
||||
)
|
||||
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 v3
|
||||
""",
|
||||
listOf(ExternalLabel("show_video_ads", instruction(insertIndex)))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
Loading…
Reference in New Issue
Block a user