mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2024-11-10 01:01:56 +01:00
fix(YouTube - Remove tracking query parameter): Sanitize shared URLs in remaining places
This commit is contained in:
parent
f760b204f7
commit
2442902dac
3 changed files with 63 additions and 14 deletions
|
@ -1,16 +1,23 @@
|
|||
package app.revanced.patches.youtube.misc.privacy
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult.MethodFingerprintScanResult.PatternScanResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
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.privacy.fingerprints.SystemShareSheetFingerprint
|
||||
import app.revanced.patches.youtube.misc.privacy.fingerprints.YouTubeShareSheetFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
|
@ -30,7 +37,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|||
)
|
||||
@Suppress("unused")
|
||||
object RemoveTrackingQueryParameterPatch : BytecodePatch(
|
||||
setOf(CopyTextFingerprint)
|
||||
setOf(CopyTextFingerprint, SystemShareSheetFingerprint, YouTubeShareSheetFingerprint)
|
||||
) {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/RemoveTrackingQueryParameterPatch;"
|
||||
|
||||
|
@ -53,21 +60,31 @@ object RemoveTrackingQueryParameterPatch : BytecodePatch(
|
|||
)
|
||||
)
|
||||
|
||||
CopyTextFingerprint.result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 2
|
||||
fun MethodFingerprint.hook(
|
||||
getInsertIndex: PatternScanResult.() -> Int,
|
||||
getUrlRegister: MutableMethod.(insertIndex: Int) -> Int
|
||||
) = result?.let {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.getInsertIndex()
|
||||
val urlRegister = it.mutableMethod.getUrlRegister(insertIndex)
|
||||
|
||||
it.mutableMethod.apply {
|
||||
val urlRegister = getInstruction<TwoRegisterInstruction>(insertIndex - 2).registerA
|
||||
it.mutableMethod.addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {v$urlRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$urlRegister
|
||||
"""
|
||||
)
|
||||
} ?: throw exception
|
||||
|
||||
addInstructions(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static {v$urlRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$urlRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
// Native YouTube share sheet.
|
||||
YouTubeShareSheetFingerprint.hook(getInsertIndex = { startIndex + 1 })
|
||||
{ insertIndex -> getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA }
|
||||
|
||||
}
|
||||
// Native system share sheet.
|
||||
SystemShareSheetFingerprint.hook(getInsertIndex = { endIndex })
|
||||
{ insertIndex -> getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA }
|
||||
|
||||
CopyTextFingerprint.hook(getInsertIndex = { startIndex + 2 })
|
||||
{ insertIndex -> getInstruction<TwoRegisterInstruction>(insertIndex - 2).registerA }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package app.revanced.patches.youtube.misc.privacy.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object SystemShareSheetFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
parameters = listOf("L", "Ljava/util/Map;"),
|
||||
opcodes = listOf(
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.GOTO
|
||||
),
|
||||
strings = listOf("YTShare_Logging_Share_Intent_Endpoint_Byte_Array")
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
package app.revanced.patches.youtube.misc.privacy.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object YouTubeShareSheetFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "Ljava/util/Map;"),
|
||||
opcodes = listOf(
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.GOTO,
|
||||
Opcode.MOVE_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
)
|
||||
)
|
Loading…
Reference in a new issue