Skip to content

Commit

Permalink
feat(Instagram): Add Hide ads patch (ReVanced#3380)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
tymmesyde and oSumAtrIX authored Jun 27, 2024
1 parent 3569f4b commit c6b2f8c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ public final class app/revanced/patches/inshorts/ad/HideAdsPatch : app/revanced/
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/instagram/patches/ad/HideAdsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/instagram/patches/ad/HideAdsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/instagram/patches/ads/timeline/HideTimelineAdsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/instagram/patches/ads/timeline/HideTimelineAdsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
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
}
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"),
)

0 comments on commit c6b2f8c

Please sign in to comment.