mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 21:30:19 +02:00
fix(YouTube/Spoof player parameters): fix player tracking such as history or video watchtime
This commit is contained in:
parent
c6031bd919
commit
79897a163f
@ -5,13 +5,16 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.ParamsMapPutFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelGeneralStoryboardRendererFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelGeneralStoryboardRendererFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelLiveStreamStoryboardRendererFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelLiveStreamStoryboardRendererFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelStoryboardRecommendedLevelFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.PlayerResponseModelStoryboardRecommendedLevelFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StatsQueryParameterFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererDecoderSpecFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererDecoderSpecFingerprint
|
||||||
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererSpecFingerprint
|
import app.revanced.patches.youtube.utils.fix.parameter.fingerprints.StoryboardRendererSpecFingerprint
|
||||||
@ -24,6 +27,7 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
|||||||
import app.revanced.patches.youtube.utils.videoid.general.VideoIdPatch
|
import app.revanced.patches.youtube.utils.videoid.general.VideoIdPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Spoof player parameters",
|
name = "Spoof player parameters",
|
||||||
@ -68,9 +72,11 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
)
|
)
|
||||||
object SpoofPlayerParameterPatch : BytecodePatch(
|
object SpoofPlayerParameterPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
|
ParamsMapPutFingerprint,
|
||||||
PlayerResponseModelGeneralStoryboardRendererFingerprint,
|
PlayerResponseModelGeneralStoryboardRendererFingerprint,
|
||||||
PlayerResponseModelLiveStreamStoryboardRendererFingerprint,
|
PlayerResponseModelLiveStreamStoryboardRendererFingerprint,
|
||||||
PlayerResponseModelStoryboardRecommendedLevelFingerprint,
|
PlayerResponseModelStoryboardRecommendedLevelFingerprint,
|
||||||
|
StatsQueryParameterFingerprint,
|
||||||
StoryboardRendererDecoderRecommendedLevelFingerprint,
|
StoryboardRendererDecoderRecommendedLevelFingerprint,
|
||||||
StoryboardRendererDecoderSpecFingerprint,
|
StoryboardRendererDecoderSpecFingerprint,
|
||||||
StoryboardRendererSpecFingerprint,
|
StoryboardRendererSpecFingerprint,
|
||||||
@ -198,6 +204,37 @@ object SpoofPlayerParameterPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
} ?: throw StoryboardRendererDecoderSpecFingerprint.exception
|
} ?: throw StoryboardRendererDecoderSpecFingerprint.exception
|
||||||
|
|
||||||
|
// Fix stats not being tracked.
|
||||||
|
// Due to signature spoofing "adformat" is present in query parameters made for /stats requests,
|
||||||
|
// even though, for regular videos, it should not be.
|
||||||
|
// This breaks stats tracking.
|
||||||
|
// Replace the ad parameter with the video parameter in the query parameters.
|
||||||
|
StatsQueryParameterFingerprint.result?.let {
|
||||||
|
val putMethod = ParamsMapPutFingerprint.result?.method?.toString()
|
||||||
|
?: throw ParamsMapPutFingerprint.exception
|
||||||
|
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val adParamIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||||
|
val videoParamIndex = adParamIndex + 3
|
||||||
|
|
||||||
|
// Replace the ad parameter with the video parameter.
|
||||||
|
replaceInstruction(adParamIndex, getInstruction(videoParamIndex))
|
||||||
|
|
||||||
|
// Call paramsMap.put instead of paramsMap.putIfNotExist
|
||||||
|
// because the key is already present in the map.
|
||||||
|
val putAdParamIndex = adParamIndex + 1
|
||||||
|
val putIfKeyNotExistsInstruction = getInstruction<FiveRegisterInstruction>(putAdParamIndex)
|
||||||
|
replaceInstruction(
|
||||||
|
putAdParamIndex,
|
||||||
|
"invoke-virtual { " +
|
||||||
|
"v${putIfKeyNotExistsInstruction.registerC}, " +
|
||||||
|
"v${putIfKeyNotExistsInstruction.registerD}, " +
|
||||||
|
"v${putIfKeyNotExistsInstruction.registerE} }, " +
|
||||||
|
putMethod,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw StatsQueryParameterFingerprint.exception
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings
|
* Add settings
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fix.parameter.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 ParamsMapPutFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf(
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
"Ljava/lang/String;",
|
||||||
|
),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.CONST_4,
|
||||||
|
Opcode.MOVE_OBJECT,
|
||||||
|
Opcode.MOVE_OBJECT,
|
||||||
|
Opcode.MOVE_OBJECT,
|
||||||
|
Opcode.INVOKE_DIRECT_RANGE,
|
||||||
|
),
|
||||||
|
)
|
@ -0,0 +1,7 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fix.parameter.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
|
||||||
|
internal object StatsQueryParameterFingerprint : MethodFingerprint(
|
||||||
|
strings = listOf("adunit"),
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user