fix(X / Twitter - Change link sharing domain): Resolve duplicate patch option (#6119)

This commit is contained in:
ADudeCalledLeo
2025-10-14 21:16:01 +03:00
committed by GitHub
parent 4b605eb270
commit 7563990750
2 changed files with 11 additions and 14 deletions

View File

@@ -2,7 +2,7 @@ package app.revanced.twitter.patches.links;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public final class ChangeLinkSharingDomainPatch { public final class ChangeLinkSharingDomainPatch {
private static final String LINK_FORMAT = "%s/%s/status/%s"; private static final String LINK_FORMAT = "https://%s/%s/status/%s";
/** /**
* Method is modified during patching. Do not change. * Method is modified during patching. Do not change.

View File

@@ -15,9 +15,9 @@ import java.util.logging.Logger
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;" internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;"
internal val domainNameOption by stringOption( internal val domainNameOption = stringOption(
key = "domainName", key = "domainName",
default = "https://fxtwitter.com", default = "fxtwitter.com",
title = "Domain name", title = "Domain name",
description = "The domain name to use when sharing links.", description = "The domain name to use when sharing links.",
required = true, required = true,
@@ -28,7 +28,7 @@ internal val domainNameOption by stringOption(
// may not allow network connections or the network may be down. // may not allow network connections or the network may be down.
try { try {
InetAddress.getByName(it) InetAddress.getByName(it)
} catch (e: UnknownHostException) { } catch (_: UnknownHostException) {
Logger.getLogger(this::class.java.name).warning( Logger.getLogger(this::class.java.name).warning(
"Host \"$it\" did not resolve to any domain." "Host \"$it\" did not resolve to any domain."
) )
@@ -38,13 +38,9 @@ internal val domainNameOption by stringOption(
internal val changeLinkSharingDomainResourcePatch = resourcePatch { internal val changeLinkSharingDomainResourcePatch = resourcePatch {
execute { execute {
val domainName = domainNameOption!! val domainName = domainNameOption.value!!
val shareLinkTemplate = if (domainName.endsWith("/")) { val shareLinkTemplate = "https://$domainName/%1\$s/status/%2\$s"
"$domainName%1\$s/status/%2\$s"
} else {
"$domainName/%1\$s/status/%2\$s"
}
document("res/values/strings.xml").use { document -> document("res/values/strings.xml").use { document ->
document.documentElement.childNodes.findElementByAttributeValueOrThrow( document.documentElement.childNodes.findElementByAttributeValueOrThrow(
@@ -58,7 +54,8 @@ internal val changeLinkSharingDomainResourcePatch = resourcePatch {
@Suppress("unused") @Suppress("unused")
val changeLinkSharingDomainPatch = bytecodePatch( val changeLinkSharingDomainPatch = bytecodePatch(
name = PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN, name = PATCH_NAME_CHANGE_LINK_SHARING_DOMAIN,
description = PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN description = PATCH_DESCRIPTION_CHANGE_LINK_SHARING_DOMAIN,
use = false
) { ) {
dependsOn( dependsOn(
changeLinkSharingDomainResourcePatch, changeLinkSharingDomainResourcePatch,
@@ -72,11 +69,11 @@ val changeLinkSharingDomainPatch = bytecodePatch(
) )
) )
execute { val domainName by domainNameOption()
val domainName = domainNameOption!!
execute {
// Replace the domain name in the link sharing extension methods. // Replace the domain name in the link sharing extension methods.
linkSharingDomainHelperFingerprint.method.returnEarly(domainName) linkSharingDomainHelperFingerprint.method.returnEarly(domainName!!)
// Replace the domain name when copying a link with "Copy link" button. // Replace the domain name when copying a link with "Copy link" button.
linkBuilderFingerprint.method.addInstructions( linkBuilderFingerprint.method.addInstructions(