forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Add
Sanitize sharing links
patch (ReVanced#3003)
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/app/revanced/patches/twitter/misc/links/SanitizeSharingLinksPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...n/app/revanced/patches/twitter/misc/links/fingerprints/SanitizeSharingLinksFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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;", | ||
) |