feat(Sync for Lemmy): Add Disable ads patch (#2872)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
Lightdm 2024-03-25 21:52:23 +01:00 committed by GitHub
parent 1c649c976d
commit 0785819dd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 32 deletions

View file

@ -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 <init> (Ljava/util/Set;Ljava/util/Set;)V
public synthetic fun <init> (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 {

View file

@ -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<PatchClass> = emptySet(),
compatiblePackages: Set<CompatiblePackage>,
) : BytecodePatch(
name = "Disable ads",
dependencies = dependencies,
compatiblePackages = compatiblePackages,
fingerprints = setOf(IsAdsEnabledFingerprint),
) {
override fun execute(context: BytecodeContext) = listOf(IsAdsEnabledFingerprint).returnEarly()
}

View file

@ -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")
strings = listOf("SyncIapHelper"),
)

View file

@ -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")),
)

View file

@ -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
"""
object DisableAdsPatch : BaseDisableAdsPatch(
compatiblePackages = setOf(CompatiblePackage("io.syncapps.lemmy_sync")),
)
} ?: throw IsAdsEnabledFingerprint.exception
}
}