feat(Joey for Reddit): Add Disable ads patch

This commit is contained in:
oSumAtrIX 2023-07-30 18:54:56 +02:00
parent cd103dd9b8
commit ad7e147712
2 changed files with 43 additions and 0 deletions

View File

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

View File

@ -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()
}
}