diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt similarity index 82% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt index 428e8fcd..8ed8a471 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/annotations/ClientSpoofCompatibility.kt @@ -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.Package diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt index 0c1dcdbd..f3cf363e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/fingerprints/UserAgentHeaderBuilderFingerprint.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt similarity index 84% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/patch/ClientSpoofPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt index 0b6a1ebe..c58e71c9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/spoof/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/spoof/patch/ClientSpoofPatch.kt @@ -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.Name @@ -10,8 +10,8 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patches.youtube.misc.fix.spoof.annotations.ClientSpoofCompatibility -import app.revanced.patches.youtube.misc.fix.spoof.fingerprints.UserAgentHeaderBuilderFingerprint +import app.revanced.patches.shared.misc.fix.spoof.annotations.ClientSpoofCompatibility +import app.revanced.patches.shared.misc.fix.spoof.fingerprints.UserAgentHeaderBuilderFingerprint import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction @Patch diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt similarity index 69% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt index 9924f25c..bd19fbc4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/annotations/VerticalScrollCompatibility.kt @@ -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.Package @@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Package @Compatibility( [ Package("com.google.android.youtube"), + Package("com.vanced.android.youtube") ] ) @Target(AnnotationTarget.CLASS) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt similarity index 85% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt index 338e0777..e5d137ca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/fingerprints/CanScrollVerticallyFingerprint.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt similarity index 83% rename from src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt index f78eb494..557ccb5a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt @@ -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.patcher.annotation.Description @@ -9,8 +9,8 @@ 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.patches.youtube.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility -import app.revanced.patches.youtube.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint +import app.revanced.patches.shared.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility +import app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint import org.jf.dexlib2.iface.instruction.OneRegisterInstruction @Description("Fixes issues with scrolling on the home screen when the first component is of type EmptyComponent.") diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt index 4fc21177..9bcc728a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralAdsPatch.kt @@ -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.resource.patch.GeneralAdsResourcePatch 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.formats.Instruction31i import org.jf.dexlib2.iface.instruction.formats.Instruction35c diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index 9fc74c4e..4063a2de 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -11,7 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint 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.microg.annotations.MicroGPatchCompatibility import app.revanced.patches.youtube.misc.microg.fingerprints.* diff --git a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/annotations/HideAdsCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/annotations/HideAdsCompatibility.kt new file mode 100644 index 00000000..e7c85c58 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/annotations/HideAdsCompatibility.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/fingerprints/ContainsAdFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/fingerprints/ContainsAdFingerprint.kt new file mode 100644 index 00000000..ed26fa03 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/fingerprints/ContainsAdFingerprint.kt @@ -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;") + } +) { +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt new file mode 100644 index 00000000..c820e1e4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt @@ -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() + } +} \ No newline at end of file