mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
fix(YouTube/Spoof client): partial fix for watch history issue of brand accounts on iOS clients https://github.com/inotia00/ReVanced_Extended/issues/2297
This commit is contained in:
@ -1,39 +1,25 @@
|
||||
package app.revanced.patches.youtube.misc.watchhistory
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patches.youtube.misc.watchhistory.fingerprints.TrackingUrlModelFingerprint
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.trackingurlhook.TrackingUrlHookPatch
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
object WatchHistoryPatch : BaseBytecodePatch(
|
||||
name = "Watch history",
|
||||
description = "Adds an option to change the domain of the watch history or check its status.",
|
||||
dependencies = setOf(SettingsPatch::class),
|
||||
dependencies = setOf(
|
||||
SettingsPatch::class,
|
||||
TrackingUrlHookPatch::class
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(TrackingUrlModelFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
TrackingUrlModelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, $MISC_PATH/WatchHistoryPatch;->replaceTrackingUrl(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
TrackingUrlHookPatch.hookTrackingUrl("$MISC_PATH/WatchHistoryPatch;->replaceTrackingUrl(Landroid/net/Uri;)Landroid/net/Uri;")
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
|
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object OrganicPlaybackContextModelFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
strings = listOf("Null contentCpn")
|
||||
)
|
@ -8,6 +8,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint
|
||||
@ -17,12 +18,14 @@ import app.revanced.patches.youtube.utils.compatibility.Constants
|
||||
import app.revanced.patches.youtube.utils.fingerprints.PlaybackRateBottomSheetBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BackgroundPlaybackPlayerResponseFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildInitPlaybackRequestFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlaybackStatsRequestURIFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.BuildPlayerRequestURIFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.CreatePlaybackSpeedMenuItemFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.CreatePlayerRequestBodyFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.CreatePlayerRequestBodyWithVersionReleaseFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.CreatePlayerRequestBodyWithVersionReleaseFingerprint.indexOfBuildInstruction
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.NerdsStatsVideoFormatBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.OrganicPlaybackContextModelFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.PlayerGestureConfigSyntheticFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.SetPlayerRequestClientTypeFingerprint
|
||||
import app.revanced.patches.youtube.utils.fix.client.fingerprints.UserAgentHeaderBuilderFingerprint
|
||||
@ -31,6 +34,7 @@ import app.revanced.patches.youtube.utils.integrations.Constants.PATCH_STATUS_CL
|
||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.storyboard.StoryboardHookPatch
|
||||
import app.revanced.patches.youtube.utils.trackingurlhook.TrackingUrlHookPatch
|
||||
import app.revanced.patches.youtube.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch
|
||||
import app.revanced.util.getReference
|
||||
@ -59,6 +63,7 @@ object SpoofClientPatch : BaseBytecodePatch(
|
||||
BackgroundPlaybackPatch::class,
|
||||
PlayerTypeHookPatch::class,
|
||||
|
||||
TrackingUrlHookPatch::class,
|
||||
PlayerResponseMethodHookPatch::class,
|
||||
SettingsPatch::class,
|
||||
VideoInformationPatch::class,
|
||||
@ -79,6 +84,10 @@ object SpoofClientPatch : BaseBytecodePatch(
|
||||
// Background playback in live stream.
|
||||
BackgroundPlaybackPlayerResponseFingerprint,
|
||||
|
||||
// Watch history.
|
||||
BuildPlaybackStatsRequestURIFingerprint,
|
||||
OrganicPlaybackContextModelFingerprint,
|
||||
|
||||
// Player gesture config.
|
||||
PlayerGestureConfigSyntheticFingerprint,
|
||||
|
||||
@ -415,6 +424,37 @@ object SpoofClientPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region watch history if spoofing to iOS
|
||||
|
||||
BuildPlaybackStatsRequestURIFingerprint.resultOrThrow().let {
|
||||
val walkerMethod = context.toMethodWalker(it.method)
|
||||
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
|
||||
.getMethod() as MutableMethod
|
||||
|
||||
walkerMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR->overrideTrackingUrl(Landroid/net/Uri;)Landroid/net/Uri;
|
||||
move-result-object p0
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
OrganicPlaybackContextModelFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$insertRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->setCpn(Ljava/lang/String;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TrackingUrlHookPatch.hookTrackingUrl("$INTEGRATIONS_CLASS_DESCRIPTOR->setTrackingUriParameter(Landroid/net/Uri;)V")
|
||||
|
||||
// endregion
|
||||
|
||||
// region append spoof info.
|
||||
|
||||
NerdsStatsVideoFormatBuilderFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.youtube.utils.fix.client.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
|
||||
|
||||
internal object BuildPlaybackStatsRequestURIFingerprint : MethodFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
returnType = "L",
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_STRING,
|
||||
),
|
||||
strings = listOf("event", "streamingstats"),
|
||||
)
|
@ -0,0 +1,24 @@
|
||||
package app.revanced.patches.youtube.utils.fix.client.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
|
||||
|
||||
internal object OrganicPlaybackContextModelFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
parameters = listOf(
|
||||
"Ljava/lang/String;", // cpn
|
||||
"Z",
|
||||
"Z",
|
||||
"Z",
|
||||
"Z"
|
||||
),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.IPUT_OBJECT,
|
||||
),
|
||||
strings = listOf("Null contentCpn")
|
||||
)
|
@ -0,0 +1,42 @@
|
||||
package app.revanced.patches.youtube.utils.trackingurlhook
|
||||
|
||||
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.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.utils.trackingurlhook.fingerprints.TrackingUrlModelFingerprint
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
object TrackingUrlHookPatch : BytecodePatch(
|
||||
setOf(TrackingUrlModelFingerprint)
|
||||
) {
|
||||
private lateinit var trackingUrlMethod: MutableMethod
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
trackingUrlMethod = TrackingUrlModelFingerprint.resultOrThrow().mutableMethod
|
||||
}
|
||||
|
||||
internal fun hookTrackingUrl(
|
||||
descriptor: String
|
||||
) = trackingUrlMethod.apply {
|
||||
val targetIndex = getTargetIndexWithMethodReferenceNameOrThrow("parse") + 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
var smaliInstruction = "invoke-static {v$targetRegister}, $descriptor"
|
||||
|
||||
if (!descriptor.endsWith("V")) {
|
||||
smaliInstruction += """
|
||||
move-result-object v$targetRegister
|
||||
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1,
|
||||
smaliInstruction
|
||||
)
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.misc.watchhistory.fingerprints
|
||||
package app.revanced.patches.youtube.utils.trackingurlhook.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
Reference in New Issue
Block a user