diff --git a/api/revanced-patches.api b/api/revanced-patches.api index a7057757..849737d4 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -481,6 +481,13 @@ public final class app/revanced/patches/reddit/customclients/Constants { public static final field OAUTH_USER_AGENT Ljava/lang/String; } +public abstract class app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch : app/revanced/patcher/patch/BytecodePatch { + public fun (Ljava/util/Set;Ljava/util/Set;)V + public synthetic fun (Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V + public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V +} + public final class app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch; public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V @@ -536,10 +543,12 @@ public final class app/revanced/patches/reddit/customclients/slide/api/SpoofClie public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V } -public final class app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch : app/revanced/patcher/patch/BytecodePatch { +public final class app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch : app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch { + public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch; +} + +public final class app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch : app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch { public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch; - public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V - public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V } public final class app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch : app/revanced/patcher/patch/BytecodePatch { diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch.kt new file mode 100644 index 00000000..c8697180 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.reddit.customclients.ads + +import app.revanced.patcher.PatchClass +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patches.reddit.customclients.ads.fingerprints.IsAdsEnabledFingerprint +import app.revanced.util.returnEarly + +abstract class BaseDisableAdsPatch( + dependencies: Set = emptySet(), + compatiblePackages: Set, +) : BytecodePatch( + name = "Disable ads", + dependencies = dependencies, + compatiblePackages = compatiblePackages, + fingerprints = setOf(IsAdsEnabledFingerprint), +) { + override fun execute(context: BytecodeContext) = listOf(IsAdsEnabledFingerprint).returnEarly() +} diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/fingerprints/IsAdsEnabledFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/ads/fingerprints/IsAdsEnabledFingerprint.kt similarity index 71% rename from src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/fingerprints/IsAdsEnabledFingerprint.kt rename to src/main/kotlin/app/revanced/patches/reddit/customclients/ads/fingerprints/IsAdsEnabledFingerprint.kt index 2c15da4e..a4c8b61d 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/fingerprints/IsAdsEnabledFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/ads/fingerprints/IsAdsEnabledFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints +package app.revanced.patches.reddit.customclients.ads.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint @@ -7,5 +7,5 @@ import com.android.tools.smali.dexlib2.AccessFlags internal object IsAdsEnabledFingerprint : MethodFingerprint( returnType = "Z", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - strings = listOf("SyncIapHelper") -) \ No newline at end of file + strings = listOf("SyncIapHelper"), +) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch.kt new file mode 100644 index 00000000..2359a40d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.reddit.customclients.syncforlemmy.ads + +import app.revanced.patches.reddit.customclients.ads.BaseDisableAdsPatch +import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch + +@Suppress("unused") +object DisableAdsPatch : BaseDisableAdsPatch( + dependencies = setOf(DisablePiracyDetectionPatch::class), + compatiblePackages = setOf(CompatiblePackage("com.laurencedawson.reddit_sync")), +) diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt index 75c57b64..c43f4d32 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt @@ -1,30 +1,8 @@ package app.revanced.patches.reddit.customclients.syncforreddit.ads -import app.revanced.util.exception -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints.IsAdsEnabledFingerprint -import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch +import app.revanced.patches.reddit.customclients.ads.BaseDisableAdsPatch -@Patch( - name = "Disable ads", - dependencies = [DisablePiracyDetectionPatch::class], - compatiblePackages = [CompatiblePackage("com.laurencedawson.reddit_sync")] -) @Suppress("unused") -object DisableAdsPatch : BytecodePatch(setOf(IsAdsEnabledFingerprint)) { - override fun execute(context: BytecodeContext) { - IsAdsEnabledFingerprint.result?.mutableMethod?.apply { - addInstructions( - 0, - """ - const/4 v0, 0x0 - return v0 - """ - ) - } ?: throw IsAdsEnabledFingerprint.exception - } -} \ No newline at end of file +object DisableAdsPatch : BaseDisableAdsPatch( + compatiblePackages = setOf(CompatiblePackage("io.syncapps.lemmy_sync")), +)