generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(irplus):
remove-ads
patch (#1554)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
1 parent
184b403
commit 9943a52
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/app/revanced/patches/irplus/ad/annotations/IrplusAdsCompatibility.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,9 @@ | ||
package app.revanced.patches.irplus.ad.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("net.binarymode.android.irplus")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class IrplusAdsCompatibility |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/app/revanced/patches/irplus/ad/fingerprints/IrplusAdsFingerprint.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,12 @@ | ||
package app.revanced.patches.irplus.ad.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
|
||
object IrplusAdsFingerprint : MethodFingerprint( | ||
"V", | ||
AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, | ||
listOf("L", "Z"), | ||
strings = listOf("TAGGED") | ||
) |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/app/revanced/patches/irplus/ad/patch/IrplusAdsPatch.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,33 @@ | ||
package app.revanced.patches.irplus.ad.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.BytecodeContext | ||
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.irplus.ad.annotations.IrplusAdsCompatibility | ||
import app.revanced.patches.irplus.ad.fingerprints.IrplusAdsFingerprint | ||
|
||
|
||
@Patch | ||
@Name("remove-ads") | ||
@Description("Removes all ads from the app.") | ||
@IrplusAdsCompatibility | ||
@Version("0.0.1") | ||
class IrplusAdsPatch : BytecodePatch( | ||
listOf(IrplusAdsFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
val method = IrplusAdsFingerprint.result!!.mutableMethod | ||
|
||
// By overwriting the second parameter of the method, | ||
// the view which holds the advertisement is removed. | ||
method.addInstruction(0, "const/4 p2, 0x0") | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |