feat(youtubevanced): general-ads
patch (#1693)
This commit is contained in:
parent
29f952d73e
commit
b6ca3b4491
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.spoof.annotations
|
package app.revanced.patches.shared.misc.fix.spoof.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.spoof.fingerprints
|
package app.revanced.patches.shared.misc.fix.spoof.fingerprints
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.spoof.patch
|
package app.revanced.patches.shared.misc.fix.spoof.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
|
@ -10,8 +10,8 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.misc.fix.spoof.annotations.ClientSpoofCompatibility
|
import app.revanced.patches.shared.misc.fix.spoof.annotations.ClientSpoofCompatibility
|
||||||
import app.revanced.patches.youtube.misc.fix.spoof.fingerprints.UserAgentHeaderBuilderFingerprint
|
import app.revanced.patches.shared.misc.fix.spoof.fingerprints.UserAgentHeaderBuilderFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.verticalscroll.annotations
|
package app.revanced.patches.shared.misc.fix.verticalscroll.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
|
@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Package
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[
|
[
|
||||||
Package("com.google.android.youtube"),
|
Package("com.google.android.youtube"),
|
||||||
|
Package("com.vanced.android.youtube")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints
|
package app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints
|
||||||
|
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
@ -1,4 +1,4 @@
|
||||||
package app.revanced.patches.youtube.misc.fix.verticalscroll.patch
|
package app.revanced.patches.shared.misc.fix.verticalscroll.patch
|
||||||
|
|
||||||
import app.revanced.extensions.toErrorResult
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
|
@ -9,8 +9,8 @@ import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patches.youtube.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
|
import app.revanced.patches.shared.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
|
||||||
import app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint
|
import app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.")
|
@Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.")
|
|
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibilit
|
||||||
import app.revanced.patches.youtube.ad.general.bytecode.fingerprints.ReelConstructorFingerprint
|
import app.revanced.patches.youtube.ad.general.bytecode.fingerprints.ReelConstructorFingerprint
|
||||||
import app.revanced.patches.youtube.ad.general.resource.patch.GeneralAdsResourcePatch
|
import app.revanced.patches.youtube.ad.general.resource.patch.GeneralAdsResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch.FixBackToExitGesturePatch
|
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch.FixBackToExitGesturePatch
|
||||||
import app.revanced.patches.youtube.misc.fix.verticalscroll.patch.VerticalScrollPatch
|
import app.revanced.patches.shared.misc.fix.verticalscroll.patch.VerticalScrollPatch
|
||||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
|
|
@ -11,7 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
|
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
|
||||||
import app.revanced.patches.youtube.layout.buttons.cast.patch.HideCastButtonPatch
|
import app.revanced.patches.youtube.layout.buttons.cast.patch.HideCastButtonPatch
|
||||||
import app.revanced.patches.youtube.misc.fix.spoof.patch.ClientSpoofPatch
|
import app.revanced.patches.shared.misc.fix.spoof.patch.ClientSpoofPatch
|
||||||
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch
|
import app.revanced.patches.youtube.misc.fix.playback.patch.SpoofSignatureVerificationPatch
|
||||||
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
||||||
import app.revanced.patches.youtube.misc.microg.fingerprints.*
|
import app.revanced.patches.youtube.misc.microg.fingerprints.*
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package app.revanced.patches.youtubevanced.ad.general.annotations
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility([Package("com.vanced.android.youtube")])
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
internal annotation class HideAdsCompatibility
|
|
@ -0,0 +1,25 @@
|
||||||
|
package app.revanced.patches.youtubevanced.ad.general.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object ContainsAdFingerprint:MethodFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
parameters = listOf("L", "L"),
|
||||||
|
access = AccessFlags.STATIC or AccessFlags.PUBLIC,
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.INVOKE_INTERFACE
|
||||||
|
),
|
||||||
|
strings = listOf("ads_video_with_context"),
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.name == "containsAd" && methodDef.definingClass.endsWith("LithoAdRemoval;")
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package app.revanced.patches.youtubevanced.ad.general.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
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.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.patches.shared.misc.fix.verticalscroll.patch.VerticalScrollPatch
|
||||||
|
import app.revanced.patches.youtubevanced.ad.general.annotations.HideAdsCompatibility
|
||||||
|
import app.revanced.patches.youtubevanced.ad.general.fingerprints.ContainsAdFingerprint
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("hide-ads")
|
||||||
|
@Description("Removes general ads.")
|
||||||
|
@DependsOn([VerticalScrollPatch::class])
|
||||||
|
@HideAdsCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class HideAdsPatch : BytecodePatch(
|
||||||
|
listOf(
|
||||||
|
ContainsAdFingerprint
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
ContainsAdFingerprint.result?.let { result ->
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
||||||
|
val adsListRegister = (instruction(insertIndex - 2) as Instruction21c).registerA
|
||||||
|
|
||||||
|
listOf(
|
||||||
|
"video_display_full_buttoned_layout",
|
||||||
|
"full_width_square_image_layout",
|
||||||
|
"_ad_with",
|
||||||
|
"landscape_image_wide_button_layout",
|
||||||
|
"banner_text_icon",
|
||||||
|
"cell_divider",
|
||||||
|
"square_image_layout",
|
||||||
|
"watch_metadata_app_promo",
|
||||||
|
"video_display_full_layout",
|
||||||
|
"hero_promo_image",
|
||||||
|
"statement_banner",
|
||||||
|
"primetime_promo"
|
||||||
|
).forEach { component ->
|
||||||
|
addInstructions(
|
||||||
|
insertIndex, """
|
||||||
|
const-string v$adsListRegister, "$component"
|
||||||
|
invoke-interface {v0, v$adsListRegister}, Ljava/util/List;->add(Ljava/lang/Object;)Z
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: return ContainsAdFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue