diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/DisableAnalyticsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/DisableAnalyticsPatch.kt index 25adb33395..32d4870e8b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/DisableAnalyticsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/DisableAnalyticsPatch.kt @@ -1,7 +1,10 @@ package app.revanced.patches.instagram.misc.disableAnalytics -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.extensions.getInstruction +import app.revanced.patcher.extensions.replaceInstruction import app.revanced.patcher.patch.bytecodePatch +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Suppress("unused") val disableAnalyticsPatch = bytecodePatch( @@ -13,7 +16,7 @@ val disableAnalyticsPatch = bytecodePatch( apply { // Returns BOGUS as analytics url. instagramAnalyticsUrlBuilderMethod.addInstructions( - 0, + 0, """ const-string v0, "BOGUS" return-object v0 @@ -21,13 +24,12 @@ val disableAnalyticsPatch = bytecodePatch( ) // Replaces analytics url as BOGUS. - facebookAnalyticsUrlInitMethod.addInstructions( - 0, - """ - const-string v0, "BOGUS" - return-object v0 - """ - ) + facebookAnalyticsUrlInitMethodMatch.let { match -> + match.method.apply { + val urlIndex = match[1] + val register = getInstruction(urlIndex).registerA + replaceInstruction(urlIndex, "const-string v$register, \"BOGUS\"") + } + } } } - diff --git a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/Fingerprints.kt index 0b2159a9df..ba84c2edcb 100644 --- a/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/instagram/misc/disableAnalytics/Fingerprints.kt @@ -1,6 +1,9 @@ package app.revanced.patches.instagram.misc.disableAnalytics +import app.revanced.patcher.composingFirstMethod import app.revanced.patcher.gettingFirstMethodDeclaratively +import app.revanced.patcher.instructions +import app.revanced.patcher.invoke import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.strings @@ -8,7 +11,9 @@ internal val BytecodePatchContext.instagramAnalyticsUrlBuilderMethod by gettingF strings("/logging_client_events") } -internal const val TARGET_URL = "https://graph.facebook.com/logging_client_events" -internal val BytecodePatchContext.facebookAnalyticsUrlInitMethod by gettingFirstMethodDeclaratively { - strings("analytics_endpoint", TARGET_URL) +internal val BytecodePatchContext.facebookAnalyticsUrlInitMethodMatch by composingFirstMethod { + instructions( + "analytics_endpoint"(), + "https://graph.facebook.com/logging_client_events"() + ) }