Skip to content

Commit ad7fab6

Browse files
fix(Twitter - Change link sharing domain): Use correct extension package
1 parent 9194e15 commit ad7fab6

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

patches/src/main/kotlin/app/revanced/patches/twitter/misc/links/ChangeLinkSharingDomainPatch.kt

+5-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
1111
import app.revanced.patches.shared.misc.mapping.resourceMappings
1212
import app.revanced.patches.twitter.misc.extension.sharedExtensionPatch
1313
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
14+
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
1415
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
15-
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
1616

1717
internal var tweetShareLinkTemplateId = -1L
1818
private set
@@ -25,15 +25,7 @@ internal val changeLinkSharingDomainResourcePatch = resourcePatch {
2525
}
2626
}
2727

28-
// This method is used to build the link that is shared when the "Share via..." button is pressed.
29-
private const val FORMAT_METHOD_RESOURCE_REFERENCE =
30-
"Lapp/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch;->" +
31-
"formatResourceLink([Ljava/lang/Object;)Ljava/lang/String;"
32-
33-
// This method is used to build the link that is shared when the "Copy link" button is pressed.
34-
private const val FORMAT_METHOD_REFERENCE =
35-
"Lapp/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch;->" +
36-
"formatLink(JLjava/lang/String;)Ljava/lang/String;"
28+
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;"
3729

3830
@Suppress("unused")
3931
val changeLinkSharingDomainPatch = bytecodePatch(
@@ -71,7 +63,7 @@ val changeLinkSharingDomainPatch = bytecodePatch(
7163
addInstructions(
7264
0,
7365
"""
74-
invoke-static { p0, p1, p2 }, $FORMAT_METHOD_REFERENCE
66+
invoke-static { p0, p1, p2 }, $EXTENSION_CLASS_DESCRIPTOR->formatLink(JLjava/lang/String;)Ljava/lang/String;
7567
move-result-object p0
7668
return-object p0
7769
""",
@@ -84,12 +76,12 @@ val changeLinkSharingDomainPatch = bytecodePatch(
8476

8577
// Format the link with the new domain name register (1 instruction below the const).
8678
val formatLinkCallIndex = templateIdConstIndex + 1
87-
val formatLinkCall = getInstruction<Instruction35c>(formatLinkCallIndex)
79+
val register = getInstruction<FiveRegisterInstruction>(formatLinkCallIndex).registerE
8880

8981
// Replace the original method call with the new method call.
9082
replaceInstruction(
9183
formatLinkCallIndex,
92-
"invoke-static { v${formatLinkCall.registerE} }, $FORMAT_METHOD_RESOURCE_REFERENCE",
84+
"invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->formatResourceLink([Ljava/lang/Object;)Ljava/lang/String;",
9385
)
9486
}
9587
}

0 commit comments

Comments
 (0)