forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Sync for Lemmy): Add
Disable ads
patch (ReVanced#2872)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
Showing
5 changed files
with
48 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/app/revanced/patches/reddit/customclients/ads/BaseDisableAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...main/kotlin/app/revanced/patches/reddit/customclients/syncforlemmy/ads/DisableAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")), | ||
) |
30 changes: 4 additions & 26 deletions
30
...ain/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/DisableAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
object DisableAdsPatch : BaseDisableAdsPatch( | ||
compatiblePackages = setOf(CompatiblePackage("io.syncapps.lemmy_sync")), | ||
) |