generated from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Clear tracking params
patch @FrozenAlex's
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/crimera/patches/twitter/link/ClearTrackingParamsPatch.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,30 @@ | ||
package crimera.patches.twitter.link | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchException | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import crimera.patches.twitter.link.fingerprints.AddSessionTokenFingerprint | ||
|
||
// https://github.com/FrozenAlex/revanced-patches-new | ||
@Patch( | ||
name = "Clear tracking params", | ||
description = "Removes tracking parameters when sharing links", | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")] | ||
) | ||
@Suppress("unused") | ||
object ClearTrackingParamsPatch: BytecodePatch( | ||
setOf(AddSessionTokenFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result = AddSessionTokenFingerprint.result | ||
?: throw PatchException("Fingerprint not found") | ||
|
||
result.mutableMethod.addInstruction(0, "return-object p0") | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/crimera/patches/twitter/link/fingerprints/AddSessionTokenFingerprint.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,12 @@ | ||
package crimera.patches.twitter.link.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
// Reference: | ||
object AddSessionTokenFingerprint: MethodFingerprint( | ||
strings = listOf( | ||
"<this>", | ||
"shareParam", | ||
"sessionToken" | ||
) | ||
) |