feat(Twitter): Add Sanitize sharing links patch (#3003)

This commit is contained in:
Twin 2024-04-09 13:42:51 -04:00 committed by GitHub
parent a92b7fb43c
commit 186b887415
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 0 deletions

View File

@ -1202,6 +1202,12 @@ public final class app/revanced/patches/twitter/misc/links/OpenLinksWithAppChoos
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}
public final class app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}
public final class app/revanced/patches/vsco/misc/pro/UnlockProPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/vsco/misc/pro/UnlockProPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V

View File

@ -0,0 +1,29 @@
package app.revanced.patches.twitter.misc.links
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.twitter.misc.links.fingerprints.SanitizeSharingLinksFingerprint
import app.revanced.util.exception
@Patch(
name = "Sanitize sharing links",
description = "Removes the tracking query parameters from links before they are shared.",
compatiblePackages = [CompatiblePackage("com.twitter.android")],
)
object SanitizeSharingLinksPatch : BytecodePatch(
setOf(SanitizeSharingLinksFingerprint),
) {
override fun execute(context: BytecodeContext) {
SanitizeSharingLinksFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
# Method takes in a link (string, param 0) and then appends the tracking query params,
# so all we need to do is return back the passed-in string
return-object p0
""",
) ?: throw SanitizeSharingLinksFingerprint.exception
}
}

View File

@ -0,0 +1,8 @@
package app.revanced.patches.twitter.misc.links.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
internal object SanitizeSharingLinksFingerprint : MethodFingerprint(
strings = listOf("<this>", "shareParam", "sessionToken"),
returnType = "Ljava/lang/String;",
)