Skip to content

Commit

Permalink
feat(inshorts): hide-ads patch (ReVanced#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunali321 authored and oSumAtrIX committed Apr 16, 2023
1 parent 47ff447 commit 04a2acc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.inshorts.ad.annotations

import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package

@Compatibility([Package("com.nis.app")])

@Target(AnnotationTarget.CLASS)
internal annotation class HideAdsCompatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.inshorts.ad.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode

object InshortsAdsFingerprint : MethodFingerprint(
"V",
strings = listOf("GoogleAdLoader","exception in requestAd")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package app.revanced.patches.inshorts.ad.patch

import app.revanced.extensions.toErrorResult
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.inshorts.ad.annotations.HideAdsCompatibility
import app.revanced.patches.inshorts.ad.fingerprints.InshortsAdsFingerprint

@Patch
@Name("hide-ads")
@Description("Removes ads from Inshorts.")
@HideAdsCompatibility
@Version("0.0.1")
class HideAdsPatch : BytecodePatch(
listOf(InshortsAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
InshortsAdsFingerprint.result?.let { result ->
result.apply {
mutableMethod.addInstruction(
0,
"""
return-void
"""
)
}
} ?: return InshortsAdsFingerprint.toErrorResult()

return PatchResultSuccess()
}
}

0 comments on commit 04a2acc

Please sign in to comment.