Compare commits

...

2 Commits

Author SHA1 Message Date
semantic-release-bot
59b648c049 chore: Release v4.18.0-dev.2 [skip ci]
# [4.18.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v4.18.0-dev.1...v4.18.0-dev.2) (2024-10-22)

### Bug Fixes

* **Twitter - Change link sharing domain:** Support latest app version ([#3786](https://github.com/ReVanced/revanced-patches/issues/3786)) ([5bdb3a2](5bdb3a2e29))
2024-10-22 21:05:36 +00:00
Alex
5bdb3a2e29 fix(Twitter - Change link sharing domain): Support latest app version (#3786) 2024-10-22 23:03:33 +02:00
5 changed files with 37 additions and 12 deletions

View File

@@ -1,3 +1,10 @@
# [4.18.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v4.18.0-dev.1...v4.18.0-dev.2) (2024-10-22)
### Bug Fixes
* **Twitter - Change link sharing domain:** Support latest app version ([#3786](https://github.com/ReVanced/revanced-patches/issues/3786)) ([b54592c](https://github.com/ReVanced/revanced-patches/commit/b54592cf9c5d859e1af2f02e8e6aaad7d47ab760))
# [4.18.0-dev.1](https://github.com/ReVanced/revanced-patches/compare/v4.17.0...v4.18.0-dev.1) (2024-10-21)

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 4.18.0-dev.1
version = 4.18.0-dev.2

View File

@@ -12,15 +12,16 @@ import app.revanced.patches.twitter.misc.links.fingerprints.LinkBuilderFingerpri
import app.revanced.patches.twitter.misc.links.fingerprints.LinkResourceGetterFingerprint
import app.revanced.patches.twitter.misc.links.fingerprints.LinkSharingDomainFingerprint
import app.revanced.util.exception
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Patch(
name = "Change link sharing domain",
description = "Replaces the domain name of Twitter links when sharing them.",
dependencies = [
ChangeLinkSharingDomainResourcePatch::class,
],
compatiblePackages = [CompatiblePackage("com.twitter.android")],
)
@Suppress("unused")
@@ -75,12 +76,11 @@ object ChangeLinkSharingDomainPatch : BytecodePatch(
// Used in the Share via... dialog.
LinkResourceGetterFingerprint.result?.mutableMethod?.apply {
val constWithParameterName = indexOfFirstInstructionOrThrow {
getReference<StringReference>()?.string?.contains("id.toString()") == true
}
val templateIdConstIndex =
indexOfFirstWideLiteralInstructionValueOrThrow(ChangeLinkSharingDomainResourcePatch.tweetShareLinkTemplateId)
// Format the link with the new domain name register (2 instructions above the const-string).
val formatLinkCallIndex = constWithParameterName - 2
// Format the link with the new domain name register (1 instruction below the const).
val formatLinkCallIndex = templateIdConstIndex + 1
val formatLinkCall = getInstruction<Instruction35c>(formatLinkCallIndex)
// Replace the original method call with the new method call.

View File

@@ -0,0 +1,17 @@
package app.revanced.patches.twitter.misc.links
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
@Patch(
dependencies = [ResourceMappingPatch::class],
)
internal object ChangeLinkSharingDomainResourcePatch : ResourcePatch() {
internal var tweetShareLinkTemplateId: Long = -1
override fun execute(context: ResourceContext) {
tweetShareLinkTemplateId = ResourceMappingPatch["string", "tweet_share_link"]
}
}

View File

@@ -1,12 +1,13 @@
package app.revanced.patches.twitter.misc.links.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.patches.twitter.misc.links.ChangeLinkSharingDomainResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
// Gets Resource string for share link view available by pressing "Share via" button.
internal object LinkResourceGetterFingerprint : MethodFingerprint(
internal object LinkResourceGetterFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Landroid/content/res/Resources;"),
strings = listOf("res.getString(R.string.t…lUsername, id.toString())"),
literalSupplier = { ChangeLinkSharingDomainResourcePatch.tweetShareLinkTemplateId }
)