Skip to content

Commit

Permalink
feat(Joey for Reddit): Add Disable ads patch
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jul 30, 2023
1 parent cd103dd commit ad7e147
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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")
)
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit ad7e147

Please sign in to comment.