mirror of
https://github.com/revanced/revanced-patches
synced 2024-08-29 02:25:15 +02:00
fix(video-ads): block remaining video ads
This commit is contained in:
parent
fdb312276e
commit
fbc83a22d3
@ -2,16 +2,17 @@ package app.revanced.patches.youtube.ad.video.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
@Name("show-video-ads-method-fingerprint")
|
||||
@Name("load-ads-fingerprint")
|
||||
|
||||
@VideoAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
object ShowVideoAdsFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z")
|
||||
object LoadAdsFingerprint : MethodFingerprint(
|
||||
strings = listOf("Unexpected playerAd type: "),
|
||||
customFingerprint = { method ->
|
||||
method.parameterTypes.size > 0 && method.parameterTypes.first() == "Ljava/lang/String;"
|
||||
}
|
||||
)
|
@ -1,35 +0,0 @@
|
||||
package app.revanced.patches.youtube.ad.video.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("show-video-ads-constructor-fingerprint")
|
||||
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
|
||||
@VideoAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
object ShowVideoAdsConstructorFingerprint : MethodFingerprint(
|
||||
"V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
null, // either CONST_4 or CONST_16
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.NEW_INSTANCE,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.RETURN_VOID
|
||||
)
|
||||
)
|
@ -5,15 +5,15 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||
import app.revanced.patches.youtube.ad.video.fingerprints.ShowVideoAdsConstructorFingerprint
|
||||
import app.revanced.patches.youtube.ad.video.fingerprints.ShowVideoAdsFingerprint
|
||||
import app.revanced.patches.youtube.ad.video.fingerprints.LoadAdsFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.framework.components.impl.Swit
|
||||
@Version("0.0.1")
|
||||
class VideoAdsPatch : BytecodePatch(
|
||||
listOf(
|
||||
ShowVideoAdsConstructorFingerprint
|
||||
LoadAdsFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
@ -41,17 +41,19 @@ class VideoAdsPatch : BytecodePatch(
|
||||
)
|
||||
)
|
||||
|
||||
ShowVideoAdsFingerprint.resolve(
|
||||
context, ShowVideoAdsConstructorFingerprint.result!!.classDef
|
||||
)
|
||||
|
||||
// Override the parameter by calling shouldShowAds and setting the parameter to the result
|
||||
ShowVideoAdsFingerprint.result!!.mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z
|
||||
move-result v1
|
||||
"""
|
||||
)
|
||||
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
|
||||
const/4 v1, 0x0
|
||||
return-object v1
|
||||
""",
|
||||
listOf(ExternalLabel("show_video_ads", method.instruction(0)))
|
||||
)
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user