forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Instagram): Add
Hide ads
patch (ReVanced#3380)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 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
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/app/revanced/patches/instagram/patches/ad/HideAdsPatch.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,29 @@ | ||
package app.revanced.patches.instagram.patches.ad | ||
|
||
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.instagram.patches.ad.fingerprints.AdInjectorFingerprint | ||
import app.revanced.util.exception | ||
|
||
@Patch( | ||
name = "Hide ads", | ||
description = "Hides ads in stories, discover, profile, etc." + | ||
"An ad can still appear once when refreshing the home feed.", | ||
compatiblePackages = [CompatiblePackage("com.instagram.android")], | ||
) | ||
@Suppress("unused") | ||
object HideAdsPatch : BytecodePatch( | ||
setOf(AdInjectorFingerprint), | ||
) { | ||
override fun execute(context: BytecodeContext) = | ||
AdInjectorFingerprint.result?.mutableMethod?.addInstructions( | ||
0, | ||
""" | ||
const/4 v0, 0x0 | ||
return v0 | ||
""", | ||
) ?: throw AdInjectorFingerprint.exception | ||
} |
17 changes: 17 additions & 0 deletions
17
...in/kotlin/app/revanced/patches/instagram/patches/ad/fingerprints/AdInjectorFingerprint.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,17 @@ | ||
package app.revanced.patches.instagram.patches.ad.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
internal object AdInjectorFingerprint : MethodFingerprint( | ||
returnType = "Z", | ||
accessFlags = AccessFlags.PRIVATE.value, | ||
parameters = listOf("L", "L"), | ||
opcodes = listOf( | ||
Opcode.IGET, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
), | ||
strings = listOf("SponsoredContentController::Delivery"), | ||
) |