mirror of
https://github.com/revanced/revanced-patches
synced 2025-01-07 11:55:50 +01:00
feat(YouTube): Add Remove tracking query parameter
patch
Implementation references taken from github.com/inotia00/revanced-patches/commit/4037d9c85b7e37f8635f8fdcc1efea85dcddb5e2.
This commit is contained in:
parent
e205ac761d
commit
ddda3f6e8c
@ -0,0 +1,71 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.privacy
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||||
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
||||||
|
import app.revanced.patches.youtube.misc.privacy.fingerprints.CopyTextFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Remove tracking query parameter",
|
||||||
|
description = "Remove the tracking query parameter from links.",
|
||||||
|
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
||||||
|
compatiblePackages = [
|
||||||
|
CompatiblePackage(
|
||||||
|
"com.google.android.youtube",
|
||||||
|
[
|
||||||
|
"18.43.45",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object RemoveTrackingQueryParameterPatch : BytecodePatch(
|
||||||
|
setOf(CopyTextFingerprint)
|
||||||
|
) {
|
||||||
|
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/RemoveTrackingQueryParameterPatch;"
|
||||||
|
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||||
|
SwitchPreference(
|
||||||
|
"revanced_remove_tracking_query_parameter",
|
||||||
|
StringResource(
|
||||||
|
"revanced_remove_tracking_query_parameter_title",
|
||||||
|
"Remove tracking query parameter"
|
||||||
|
),
|
||||||
|
StringResource(
|
||||||
|
"revanced_remove_tracking_query_parameter_summary_on",
|
||||||
|
"Tracking query parameter is removed from links"
|
||||||
|
),
|
||||||
|
StringResource(
|
||||||
|
"revanced_remove_tracking_query_parameter_summary_off",
|
||||||
|
"Tracking query parameter is not removed from links"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
CopyTextFingerprint.result?.let {
|
||||||
|
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
|
||||||
|
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val urlRegister = getInstruction<TwoRegisterInstruction>(insertIndex - 2).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
invoke-static {v$urlRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String;
|
||||||
|
move-result-object v$urlRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.privacy.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
object CopyTextFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("L", "Ljava/util/Map;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IGET_OBJECT, // Contains the text to copy to be sanitized.
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.INVOKE_STATIC, // ClipData.newPlainText
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_INTERFACE,
|
||||||
|
Opcode.RETURN_VOID
|
||||||
|
),
|
||||||
|
strings = listOf("text/plain")
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user