diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/fingerprints/IsAdFreeUserFingerprint.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/fingerprints/IsAdFreeUserFingerprint.kt new file mode 100644 index 000000000..4c625220d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/fingerprints/IsAdFreeUserFingerprint.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.reddit.customclients.joeyforreddit.ads.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.AccessFlags + +object IsAdFreeUserFingerprint : MethodFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC.value, + strings = listOf("AD_FREE_USER") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt new file mode 100644 index 000000000..7b0c565da --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt @@ -0,0 +1,33 @@ +package app.revanced.patches.reddit.customclients.joeyforreddit.ads.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Package +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +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.reddit.customclients.joeyforreddit.ads.fingerprints.IsAdFreeUserFingerprint +import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch.DisablePiracyDetectionPatch + +@Patch +@Name("Disable ads") +@DependsOn([DisablePiracyDetectionPatch::class]) +@Compatibility([Package("o.o.joey")]) +class DisableAdsPatch : BytecodePatch(listOf(IsAdFreeUserFingerprint)) { + override fun execute(context: BytecodeContext): PatchResult { + IsAdFreeUserFingerprint.result?.mutableMethod?.addInstructions( + 0, + """ + const/4 v0, 0x1 + return v0 + """ + ) ?: return IsAdFreeUserFingerprint.toErrorResult() + + return PatchResultSuccess() + } +} \ No newline at end of file