rollback video-id-hook patch

This commit is contained in:
inotia00
2023-04-13 16:08:14 +09:00
parent 321ebf54b7
commit 90b7577914
15 changed files with 114 additions and 35 deletions

View File

@ -9,14 +9,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatch import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatch
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.util.integrations.Constants.BUTTON_PATH import app.revanced.util.integrations.Constants.BUTTON_PATH
@Name("overlay-buttons-bytecode-patch") @Name("overlay-buttons-bytecode-patch")
@DependsOn( @DependsOn(
dependencies = [ dependencies = [
PlayerControlsPatch::class, PlayerControlsPatch::class,
VideoIdPatch::class MainstreamVideoIdPatch::class
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility

View File

@ -19,7 +19,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints.* import app.revanced.patches.youtube.misc.returnyoutubedislike.fingerprints.*
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.util.integrations.Constants.UTILS_PATH import app.revanced.util.integrations.Constants.UTILS_PATH
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction3rc import org.jf.dexlib2.builder.instruction.BuilderInstruction3rc
@ -35,8 +35,8 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Description("Shows the dislike count of videos using the Return YouTube Dislike API.") @Description("Shows the dislike count of videos using the Return YouTube Dislike API.")
@DependsOn( @DependsOn(
[ [
SettingsPatch::class, MainstreamVideoIdPatch::class,
VideoIdPatch::class SettingsPatch::class
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@ -168,7 +168,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch(
} ?: return ShortsTextComponentParentFingerprint.toErrorResult() } ?: return ShortsTextComponentParentFingerprint.toErrorResult()
VideoIdPatch.injectCall("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V") MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_RYD_CLASS_DESCRIPTOR->newVideoLoaded(Ljava/lang/String;)V")
/* /*
* Add ReVanced Settings * Add ReVanced Settings

View File

@ -17,7 +17,7 @@ import app.revanced.patches.youtube.misc.playercontrols.patch.PlayerControlsPatc
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints.* import app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints.*
import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
import app.revanced.util.bytecode.BytecodeHelper.injectInit import app.revanced.util.bytecode.BytecodeHelper.injectInit
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@ -31,10 +31,10 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Name("sponsorblock-bytecode-patch") @Name("sponsorblock-bytecode-patch")
@DependsOn( @DependsOn(
[ [
MainstreamVideoIdPatch::class,
OverrideSpeedHookPatch::class, OverrideSpeedHookPatch::class,
PlayerControlsPatch::class, PlayerControlsPatch::class,
SharedResourceIdPatch::class, SharedResourceIdPatch::class
VideoIdPatch::class
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@ -49,7 +49,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/* /*
* Hook the video time methods * Hook the video time methods
*/ */
with(VideoIdPatch) { with(MainstreamVideoIdPatch) {
videoTimeHook( videoTimeHook(
INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR, INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR,
"setVideoTime" "setVideoTime"
@ -59,7 +59,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/* /*
* Inject VideoIdPatch * Inject VideoIdPatch
*/ */
VideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V") MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
/* /*
@ -146,7 +146,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
val register = (instruction as OneRegisterInstruction).registerA val register = (instruction as OneRegisterInstruction).registerA
it.replaceInstruction( it.replaceInstruction(
index, index,
"const-string v$register, \"${VideoIdPatch.reactReference}\"" "const-string v$register, \"${MainstreamVideoIdPatch.reactReference}\""
) )
break break
} }

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.misc.videoid.legacy.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object LegacyVideoIdFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC,
parameters = listOf("L"),
opcodes = listOf(Opcode.INVOKE_INTERFACE),
customFingerprint = {
it.definingClass.endsWith("PlaybackLifecycleMonitor;")
}
)

View File

@ -0,0 +1,63 @@
package app.revanced.patches.youtube.misc.videoid.legacy.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.videoid.legacy.fingerprint.LegacyVideoIdFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("video-id-hook-legacy")
@Description("Hook to detect when the video id changes (legacy)")
@YouTubeCompatibility
@Version("0.0.1")
class LegacyVideoIdPatch : BytecodePatch(
listOf(
LegacyVideoIdFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
LegacyVideoIdFingerprint.result?.let {
insertIndex = it.scanResult.patternScanResult!!.endIndex
with (it.mutableMethod) {
insertMethod = this
videoIdRegister = (implementation!!.instructions[insertIndex + 1] as OneRegisterInstruction).registerA
}
offset++ // offset so setCurrentVideoId is called before any injected call
} ?: return LegacyVideoIdFingerprint.toErrorResult()
return PatchResultSuccess()
}
companion object {
private var offset = 2
private var insertIndex: Int = 0
private var videoIdRegister: Int = 0
private lateinit var insertMethod: MutableMethod
/**
* Adds an invoke-static instruction, called with the new id when the video changes
* @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;`
*/
fun injectCall(
methodDescriptor: String
) {
insertMethod.addInstructions(
insertIndex + offset, // move-result-object offset
"invoke-static {v$videoIdRegister}, $methodDescriptor"
)
}
}
}

View File

@ -1,11 +1,11 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
object VideoIdFingerprint : MethodFingerprint( object MainstreamVideoIdFingerprint : MethodFingerprint(
returnType = "V", returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL, access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"), parameters = listOf("L"),

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.fingerprint package app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.misc.videoid.patch package app.revanced.patches.youtube.misc.videoid.mainstream.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
@ -19,7 +19,7 @@ import app.revanced.patches.shared.fingerprints.VideoEndFingerprint
import app.revanced.patches.shared.fingerprints.VideoEndParentFingerprint import app.revanced.patches.shared.fingerprints.VideoEndParentFingerprint
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch import app.revanced.patches.youtube.misc.timebar.patch.HookTimebarPatch
import app.revanced.patches.youtube.misc.videoid.fingerprint.* import app.revanced.patches.youtube.misc.videoid.mainstream.fingerprint.*
import app.revanced.util.integrations.Constants.VIDEO_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.builder.MutableMethodImplementation import org.jf.dexlib2.builder.MutableMethodImplementation
@ -32,8 +32,8 @@ import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodParameter import org.jf.dexlib2.immutable.ImmutableMethodParameter
import org.jf.dexlib2.util.MethodUtil import org.jf.dexlib2.util.MethodUtil
@Name("video-id-hook") @Name("video-id-hook-mainstream")
@Description("Hook to detect when the video id changes") @Description("Hook to detect when the video id changes (mainstream)")
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1") @Version("0.0.1")
@DependsOn( @DependsOn(
@ -42,14 +42,14 @@ import org.jf.dexlib2.util.MethodUtil
PlayerTypeHookPatch::class PlayerTypeHookPatch::class
] ]
) )
class VideoIdPatch : BytecodePatch( class MainstreamVideoIdPatch : BytecodePatch(
listOf( listOf(
MainstreamVideoIdFingerprint,
PlayerControllerSetTimeReferenceFingerprint, PlayerControllerSetTimeReferenceFingerprint,
PlayerInitFingerprint, PlayerInitFingerprint,
SeekFingerprint, SeekFingerprint,
TimebarFingerprint, TimebarFingerprint,
VideoEndParentFingerprint, VideoEndParentFingerprint,
VideoIdFingerprint,
VideoTimeHighPrecisionFingerprint, VideoTimeHighPrecisionFingerprint,
VideoTimeHighPrecisionParentFingerprint VideoTimeHighPrecisionParentFingerprint
) )
@ -154,7 +154,7 @@ class VideoIdPatch : BytecodePatch(
} }
VideoIdFingerprint.result?.let { MainstreamVideoIdFingerprint.result?.let {
insertIndex = it.scanResult.patternScanResult!!.endIndex insertIndex = it.scanResult.patternScanResult!!.endIndex
with (it.mutableMethod) { with (it.mutableMethod) {
@ -162,7 +162,7 @@ class VideoIdPatch : BytecodePatch(
videoIdRegister = (implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA videoIdRegister = (implementation!!.instructions[insertIndex] as OneRegisterInstruction).registerA
} }
offset++ // offset so setVideoId is called before any injected call offset++ // offset so setVideoId is called before any injected call
} ?: return VideoIdFingerprint.toErrorResult() } ?: return MainstreamVideoIdFingerprint.toErrorResult()
injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V") injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V")

View File

@ -12,14 +12,14 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.* import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.*
import app.revanced.util.integrations.Constants.VIDEO_PATH import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.FieldReference
@Name("default-video-quality-bytecode-patch") @Name("default-video-quality-bytecode-patch")
@DependsOn([VideoIdPatch::class]) @DependsOn([LegacyVideoIdPatch::class])
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1") @Version("0.0.1")
class VideoQualityBytecodePatch : BytecodePatch( class VideoQualityBytecodePatch : BytecodePatch(
@ -62,7 +62,7 @@ class VideoQualityBytecodePatch : BytecodePatch(
) )
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult() } ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
VideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -13,7 +13,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint
import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.* import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.*
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@ -23,10 +23,10 @@ import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
@Name("default-video-speed-bytecode-patch") @Name("default-video-speed-bytecode-patch")
@DependsOn( @DependsOn(
[ [
LegacyVideoIdPatch::class,
LiveStreamPatch::class, LiveStreamPatch::class,
OverrideSpeedHookPatch::class, OverrideSpeedHookPatch::class,
SharedResourceIdPatch::class, SharedResourceIdPatch::class
VideoIdPatch::class
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@ -56,7 +56,7 @@ class VideoSpeedBytecodePatch : BytecodePatch(
"invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V" "invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V"
) ?: return VideoSpeedSettingsFingerprint.toErrorResult() ) ?: return VideoSpeedSettingsFingerprint.toErrorResult()
VideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
context.updatePatchStatus("VideoSpeed") context.updatePatchStatus("VideoSpeed")