Skip to content

Commit decdff9

Browse files
tymmesydeoSumAtrIX
andauthored
feat(Instagram): Add Hide ads patch (#3380)
Co-authored-by: oSumAtrIX <[email protected]>
1 parent 8f6519d commit decdff9

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

api/revanced-patches.api

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ public final class app/revanced/patches/inshorts/ad/HideAdsPatch : app/revanced/
241241
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
242242
}
243243

244+
public final class app/revanced/patches/instagram/patches/ad/HideAdsPatch : app/revanced/patcher/patch/BytecodePatch {
245+
public static final field INSTANCE Lapp/revanced/patches/instagram/patches/ad/HideAdsPatch;
246+
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
247+
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
248+
}
249+
244250
public final class app/revanced/patches/instagram/patches/ads/timeline/HideTimelineAdsPatch : app/revanced/patcher/patch/BytecodePatch {
245251
public static final field INSTANCE Lapp/revanced/patches/instagram/patches/ads/timeline/HideTimelineAdsPatch;
246252
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package app.revanced.patches.instagram.patches.ad
2+
3+
import app.revanced.patcher.data.BytecodeContext
4+
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
5+
import app.revanced.patcher.patch.BytecodePatch
6+
import app.revanced.patcher.patch.annotation.CompatiblePackage
7+
import app.revanced.patcher.patch.annotation.Patch
8+
import app.revanced.patches.instagram.patches.ad.fingerprints.AdInjectorFingerprint
9+
import app.revanced.util.exception
10+
11+
@Patch(
12+
name = "Hide ads",
13+
description = "Hides ads in stories, discover, profile, etc." +
14+
"An ad can still appear once when refreshing the home feed.",
15+
compatiblePackages = [CompatiblePackage("com.instagram.android")],
16+
)
17+
@Suppress("unused")
18+
object HideAdsPatch : BytecodePatch(
19+
setOf(AdInjectorFingerprint),
20+
) {
21+
override fun execute(context: BytecodeContext) =
22+
AdInjectorFingerprint.result?.mutableMethod?.addInstructions(
23+
0,
24+
"""
25+
const/4 v0, 0x0
26+
return v0
27+
""",
28+
) ?: throw AdInjectorFingerprint.exception
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package app.revanced.patches.instagram.patches.ad.fingerprints
2+
3+
import app.revanced.patcher.fingerprint.MethodFingerprint
4+
import com.android.tools.smali.dexlib2.AccessFlags
5+
import com.android.tools.smali.dexlib2.Opcode
6+
7+
internal object AdInjectorFingerprint : MethodFingerprint(
8+
returnType = "Z",
9+
accessFlags = AccessFlags.PRIVATE.value,
10+
parameters = listOf("L", "L"),
11+
opcodes = listOf(
12+
Opcode.IGET,
13+
Opcode.INVOKE_INTERFACE,
14+
Opcode.MOVE_RESULT_OBJECT,
15+
),
16+
strings = listOf("SponsoredContentController::Delivery"),
17+
)

0 commit comments

Comments
 (0)