Skip to content

Commit 08c4468

Browse files
LightdmoSumAtrIX
andauthored
feat(Sync for Lemmy): Add Disable ads patch (#2872)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent 7c981f6 commit 08c4468

File tree

5 files changed

+48
-32
lines changed

5 files changed

+48
-32
lines changed

api/revanced-patches.api

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@ public final class app/revanced/patches/reddit/customclients/Constants {
481481
public static final field OAUTH_USER_AGENT Ljava/lang/String;
482482
}
483483

484+
public abstract class app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch : app/revanced/patcher/patch/BytecodePatch {
485+
public fun <init> (Ljava/util/Set;Ljava/util/Set;)V
486+
public synthetic fun <init> (Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
487+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
488+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
489+
}
490+
484491
public final class app/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch : app/revanced/patches/reddit/customclients/BaseSpoofClientPatch {
485492
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/baconreader/api/SpoofClientPatch;
486493
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
536543
public fun patchClientId (Ljava/util/Set;Lapp/revanced/patcher/data/BytecodeContext;)V
537544
}
538545

539-
public final class app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch : app/revanced/patcher/patch/BytecodePatch {
546+
public final class app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch : app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch {
547+
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch;
548+
}
549+
550+
public final class app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch : app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch {
540551
public static final field INSTANCE Lapp/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch;
541-
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
542-
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
543552
}
544553

545554
public final class app/revanced/patches/reddit/customclients/syncforreddit/annoyances/startup/DisableSyncForLemmyBottomSheetPatch : app/revanced/patcher/patch/BytecodePatch {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package app.revanced.patches.reddit.customclients.ads
2+
3+
import app.revanced.patcher.PatchClass
4+
import app.revanced.patcher.data.BytecodeContext
5+
import app.revanced.patcher.patch.BytecodePatch
6+
import app.revanced.patches.reddit.customclients.ads.fingerprints.IsAdsEnabledFingerprint
7+
import app.revanced.util.returnEarly
8+
9+
abstract class BaseDisableAdsPatch(
10+
dependencies: Set<PatchClass> = emptySet(),
11+
compatiblePackages: Set<CompatiblePackage>,
12+
) : BytecodePatch(
13+
name = "Disable ads",
14+
dependencies = dependencies,
15+
compatiblePackages = compatiblePackages,
16+
fingerprints = setOf(IsAdsEnabledFingerprint),
17+
) {
18+
override fun execute(context: BytecodeContext) = listOf(IsAdsEnabledFingerprint).returnEarly()
19+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints
1+
package app.revanced.patches.reddit.customclients.ads.fingerprints
22

33
import app.revanced.patcher.extensions.or
44
import app.revanced.patcher.fingerprint.MethodFingerprint
@@ -7,5 +7,5 @@ import com.android.tools.smali.dexlib2.AccessFlags
77
internal object IsAdsEnabledFingerprint : MethodFingerprint(
88
returnType = "Z",
99
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
10-
strings = listOf("SyncIapHelper")
11-
)
10+
strings = listOf("SyncIapHelper"),
11+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package app.revanced.patches.reddit.customclients.syncforlemmy.ads
2+
3+
import app.revanced.patches.reddit.customclients.ads.BaseDisableAdsPatch
4+
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch
5+
6+
@Suppress("unused")
7+
object DisableAdsPatch : BaseDisableAdsPatch(
8+
dependencies = setOf(DisablePiracyDetectionPatch::class),
9+
compatiblePackages = setOf(CompatiblePackage("com.laurencedawson.reddit_sync")),
10+
)
Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
11
package app.revanced.patches.reddit.customclients.syncforreddit.ads
22

3-
import app.revanced.util.exception
4-
import app.revanced.patcher.data.BytecodeContext
5-
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
6-
import app.revanced.patcher.patch.BytecodePatch
7-
import app.revanced.patcher.patch.annotation.CompatiblePackage
8-
import app.revanced.patcher.patch.annotation.Patch
9-
import app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints.IsAdsEnabledFingerprint
10-
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch
3+
import app.revanced.patches.reddit.customclients.ads.BaseDisableAdsPatch
114

12-
@Patch(
13-
name = "Disable ads",
14-
dependencies = [DisablePiracyDetectionPatch::class],
15-
compatiblePackages = [CompatiblePackage("com.laurencedawson.reddit_sync")]
16-
)
175
@Suppress("unused")
18-
object DisableAdsPatch : BytecodePatch(setOf(IsAdsEnabledFingerprint)) {
19-
override fun execute(context: BytecodeContext) {
20-
IsAdsEnabledFingerprint.result?.mutableMethod?.apply {
21-
addInstructions(
22-
0,
23-
"""
24-
const/4 v0, 0x0
25-
return v0
26-
"""
27-
)
28-
} ?: throw IsAdsEnabledFingerprint.exception
29-
}
30-
}
6+
object DisableAdsPatch : BaseDisableAdsPatch(
7+
compatiblePackages = setOf(CompatiblePackage("io.syncapps.lemmy_sync")),
8+
)

0 commit comments

Comments
 (0)