mirror of
https://github.com/revanced/revanced-patches
synced 2025-01-20 08:17:45 +01:00
fix: apply multiple changes from integrations, refactor package structure, class names and implementations
This commit is contained in:
parent
61762f76c4
commit
e756face36
@ -15,7 +15,7 @@ import app.revanced.patcher.util.smali.ExternalLabel
|
|||||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||||
import app.revanced.patches.youtube.ad.video.fingerprints.LoadVideoAdsFingerprint
|
import app.revanced.patches.youtube.ad.video.fingerprints.LoadVideoAdsFingerprint
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.playback.patch.FixPlaybackPatch
|
import app.revanced.patches.youtube.misc.playback.fix.patch.FixPlaybackPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||||
|
@ -12,7 +12,7 @@ import app.revanced.patcher.patch.annotations.Patch
|
|||||||
import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility
|
import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility
|
||||||
import app.revanced.patches.youtube.interaction.downloads.resource.patch.DownloadsResourcePatch
|
import app.revanced.patches.youtube.interaction.downloads.resource.patch.DownloadsResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("downloads")
|
@Name("downloads")
|
||||||
|
@ -51,7 +51,7 @@ class OldQualityLayoutPatch : BytecodePatch(
|
|||||||
// insert the integrations method
|
// insert the integrations method
|
||||||
method.addInstruction(
|
method.addInstruction(
|
||||||
listenerInvokeRegister, // insert the integrations instructions right before the listener
|
listenerInvokeRegister, // insert the integrations instructions right before the listener
|
||||||
"invoke-static { v$onItemClickViewRegister }, Lapp/revanced/integrations/patches/OldQualityLayoutPatch;->showOldQualityMenu(Landroid/widget/ListView;)V"
|
"invoke-static { v$onItemClickViewRegister }, Lapp/revanced/integrations/patches/playback/quality/OldQualityLayoutPatch;->showOldQualityMenu(Landroid/widget/ListView;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
|
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.Retu
|
|||||||
import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.*
|
import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.*
|
||||||
import app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch.ReturnYouTubeDislikeResourcePatch
|
import app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch.ReturnYouTubeDislikeResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, ReturnYouTubeDislikeResourcePatch::class])
|
@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, ReturnYouTubeDislikeResourcePatch::class])
|
||||||
|
@ -8,7 +8,6 @@ import app.revanced.patcher.data.toMethodWalker
|
|||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.replaceInstruction
|
import app.revanced.patcher.extensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
@ -23,9 +22,9 @@ import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
|||||||
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.patch.PlayerControllerPatch
|
|
||||||
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
||||||
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.*
|
import org.jf.dexlib2.iface.instruction.*
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
@ -36,7 +35,7 @@ import org.jf.dexlib2.iface.reference.StringReference
|
|||||||
@Patch
|
@Patch
|
||||||
@DependsOn(
|
@DependsOn(
|
||||||
dependencies = [
|
dependencies = [
|
||||||
PlayerControllerPatch::class, // updates video length and adds method to seek in video
|
VideoInformationPatch::class, // updates video information and adds method to seek in video
|
||||||
PlayerControlsBytecodePatch::class,
|
PlayerControlsBytecodePatch::class,
|
||||||
IntegrationsPatch::class,
|
IntegrationsPatch::class,
|
||||||
SponsorBlockResourcePatch::class,
|
SponsorBlockResourcePatch::class,
|
||||||
@ -49,9 +48,7 @@ import org.jf.dexlib2.iface.reference.StringReference
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class SponsorBlockBytecodePatch : BytecodePatch(
|
class SponsorBlockBytecodePatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
PlayerControllerSetTimeReferenceFingerprint,
|
|
||||||
CreateVideoPlayerSeekbarFingerprint,
|
CreateVideoPlayerSeekbarFingerprint,
|
||||||
VideoTimeFingerprint,
|
|
||||||
NextGenWatchLayoutFingerprint,
|
NextGenWatchLayoutFingerprint,
|
||||||
AppendTimeFingerprint,
|
AppendTimeFingerprint,
|
||||||
PlayerOverlaysLayoutInitFingerprint,
|
PlayerOverlaysLayoutInitFingerprint,
|
||||||
@ -59,36 +56,31 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
StartVideoInformerFingerprint
|
StartVideoInformerFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {/*
|
|
||||||
Set current video time
|
|
||||||
*/
|
|
||||||
val referenceResult = PlayerControllerSetTimeReferenceFingerprint.result!!
|
|
||||||
val playerControllerSetTimeMethod =
|
|
||||||
context.toMethodWalker(referenceResult.method)
|
|
||||||
.nextMethod(referenceResult.scanResult.patternScanResult!!.startIndex, true)
|
|
||||||
.getMethod() as MutableMethod
|
|
||||||
playerControllerSetTimeMethod.addInstruction(
|
|
||||||
2,
|
|
||||||
"invoke-static {p1, p2}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setCurrentVideoTime(J)V"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/integrations/sponsorblock/PlayerController;"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
/*
|
/*
|
||||||
Set current video time high precision
|
Hook the video time methods
|
||||||
*/
|
*/
|
||||||
val constructorFingerprint =
|
with(VideoInformationPatch) {
|
||||||
object : MethodFingerprint("V", null, listOf("J", "J", "J", "J", "I", "L"), null) {}
|
videoTimeHook(
|
||||||
constructorFingerprint.resolve(context, VideoTimeFingerprint.result!!.classDef)
|
INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR,
|
||||||
|
"setVideoTime"
|
||||||
val constructor = constructorFingerprint.result!!.mutableMethod
|
)
|
||||||
constructor.addInstruction(
|
highPrecisionTimeHook(
|
||||||
0,
|
INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR,
|
||||||
"invoke-static {p1, p2}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setCurrentVideoTimeHighPrecision(J)V"
|
"setHighPrecisionVideoTime"
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set current video id
|
Set current video id
|
||||||
*/
|
*/
|
||||||
VideoIdPatch.injectCall("Lapp/revanced/integrations/sponsorblock/PlayerController;->setCurrentVideoId(Ljava/lang/String;)V")
|
VideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Seekbar drawing
|
Seekbar drawing
|
||||||
@ -104,7 +96,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue
|
if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
index + 1,
|
index + 1,
|
||||||
"invoke-static {v0}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarRect(Ljava/lang/Object;)V"
|
"invoke-static {v0}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarRect(Ljava/lang/Object;)V"
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -120,7 +112,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
// set the thickness of the segment
|
// set the thickness of the segment
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
insertIndex,
|
insertIndex,
|
||||||
"invoke-static {v${invokeInstruction.registerC}}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarThickness(I)V"
|
"invoke-static {v${invokeInstruction.registerC}}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarThickness(I)V"
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -141,11 +133,11 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
// the reason for that is that we get the index, add instructions and then the offset would be wrong
|
// the reason for that is that we get the index, add instructions and then the offset would be wrong
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
indexLeft + 1,
|
indexLeft + 1,
|
||||||
"invoke-static {v$rectangleLeftRegister}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarAbsoluteLeft(Landroid/graphics/Rect;)V"
|
"invoke-static {v$rectangleLeftRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarAbsoluteLeft(Landroid/graphics/Rect;)V"
|
||||||
)
|
)
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
indexRight + 1,
|
indexRight + 1,
|
||||||
"invoke-static {v$rectangleRightRegister}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarAbsoluteRight(Landroid/graphics/Rect;)V"
|
"invoke-static {v$rectangleRightRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setSponsorBarAbsoluteRight(Landroid/graphics/Rect;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -157,7 +149,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
seekbarMethod.addInstruction(
|
seekbarMethod.addInstruction(
|
||||||
drawSegmentInstructionInsertIndex,
|
drawSegmentInstructionInsertIndex,
|
||||||
"invoke-static {v$canvasInstance, v$centerY}, Lapp/revanced/integrations/sponsorblock/PlayerController;->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
|
"invoke-static {v$canvasInstance, v$centerY}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->drawSponsorTimeBars(Landroid/graphics/Canvas;F)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -215,7 +207,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
val instanceRegister = 0
|
val instanceRegister = 0
|
||||||
NextGenWatchLayoutFingerprint.result!!.mutableMethod.addInstruction(
|
NextGenWatchLayoutFingerprint.result!!.mutableMethod.addInstruction(
|
||||||
3, // after super call
|
3, // after super call
|
||||||
"invoke-static/range {p$instanceRegister}, Lapp/revanced/integrations/sponsorblock/PlayerController;->addSkipSponsorView15(Landroid/view/View;)V"
|
"invoke-static/range {p$instanceRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->addSkipSponsorView15(Landroid/view/View;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
// append the new time to the player layout
|
// append the new time to the player layout
|
||||||
@ -232,7 +224,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// initialize the player controller
|
// initialize the player controller
|
||||||
PlayerControllerPatch.onCreateHook("Lapp/revanced/integrations/sponsorblock/PlayerController;", "initialize")
|
VideoInformationPatch.onCreateHook(INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR, "initialize")
|
||||||
|
|
||||||
// initialize the sponsorblock view
|
// initialize the sponsorblock view
|
||||||
PlayerOverlaysLayoutInitFingerprint.result!!.mutableMethod.addInstruction(
|
PlayerOverlaysLayoutInitFingerprint.result!!.mutableMethod.addInstruction(
|
||||||
@ -277,7 +269,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
startVideoInformerMethod.addInstructions(
|
startVideoInformerMethod.addInstructions(
|
||||||
0, """
|
0, """
|
||||||
const/4 v0, 0x0
|
const/4 v0, 0x0
|
||||||
sput-boolean v0, Lapp/revanced/integrations/sponsorblock/PlayerController;->shorts_playing:Z
|
sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -286,7 +278,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
shortsPlayerConstructorMethod.addInstructions(
|
shortsPlayerConstructorMethod.addInstructions(
|
||||||
0, """
|
0, """
|
||||||
const/4 v0, 0x1
|
const/4 v0, 0x1
|
||||||
sput-boolean v0, Lapp/revanced/integrations/sponsorblock/PlayerController;->shorts_playing:Z
|
sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playback.annotations
|
package app.revanced.patches.youtube.misc.playback.fix.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playback.patch
|
package app.revanced.patches.youtube.misc.playback.fix.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
@ -9,16 +9,16 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.ResourcePatch
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.playback.annotations.FixPlaybackCompatibility
|
import app.revanced.patches.youtube.misc.playback.fix.annotations.FixPlaybackCompatibility
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.patch.PlayerControllerPatch
|
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||||
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
|
|
||||||
@DependsOn([
|
@DependsOn([
|
||||||
IntegrationsPatch::class,
|
IntegrationsPatch::class,
|
||||||
PlayerControllerPatch::class, // updates video length and adds method to seek in video, necessary for this patch
|
VideoInformationPatch::class, // updates video length and adds method to seek in video, necessary for this patch
|
||||||
SettingsPatch::class,
|
SettingsPatch::class,
|
||||||
VideoIdPatch::class
|
VideoIdPatch::class
|
||||||
])
|
])
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.annotation
|
package app.revanced.patches.youtube.misc.video.information.annotation
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.fingerprint
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.fingerprint
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.fingerprint
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.fingerprint
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints
|
package app.revanced.patches.youtube.misc.video.information.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,13 +1,15 @@
|
|||||||
package app.revanced.patches.youtube.misc.playercontroller.patch
|
package app.revanced.patches.youtube.misc.video.information.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.data.toMethodWalker
|
||||||
import app.revanced.patcher.extensions.addInstruction
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
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.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
@ -16,11 +18,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.annotation.PlayerControllerCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.remember.annotation.RememberPlaybackSpeedCompatibility
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.fingerprint.CreateVideoPlayerSeekbarFingerprint
|
import app.revanced.patches.youtube.misc.video.information.fingerprints.*
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.fingerprint.PlayerInitFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.fingerprint.SeekFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.playercontroller.fingerprint.VideoLengthFingerprint
|
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@ -28,15 +27,17 @@ 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("player-controller-hook")
|
@Name("video-information")
|
||||||
@Description("Hooks the player controller")
|
@Description("Hooks YouTube to get information about the current playing video.")
|
||||||
@PlayerControllerCompatibility
|
@RememberPlaybackSpeedCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
@DependsOn([IntegrationsPatch::class])
|
@DependsOn([IntegrationsPatch::class])
|
||||||
class PlayerControllerPatch : BytecodePatch(
|
class VideoInformationPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
PlayerInitFingerprint,
|
PlayerInitFingerprint,
|
||||||
CreateVideoPlayerSeekbarFingerprint
|
CreateVideoPlayerSeekbarFingerprint,
|
||||||
|
PlayerControllerSetTimeReferenceFingerprint,
|
||||||
|
VideoTimeFingerprint,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
@ -88,29 +89,90 @@ class PlayerControllerPatch : BytecodePatch(
|
|||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
videoLengthMethodResult.scanResult.patternScanResult!!.endIndex,
|
videoLengthMethodResult.scanResult.patternScanResult!!.endIndex,
|
||||||
"invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, $INTEGRATIONS_CLASS_DESCRIPTOR->setCurrentVideoLength(J)V"
|
"invoke-static {v$videoLengthRegister, v$dummyRegisterForLong}, $INTEGRATIONS_CLASS_DESCRIPTOR->setVideoLength(J)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set the video time method
|
||||||
|
*/
|
||||||
|
with(PlayerControllerSetTimeReferenceFingerprint.result!!) {
|
||||||
|
timeMethod = context.toMethodWalker(method)
|
||||||
|
.nextMethod(scanResult.patternScanResult!!.startIndex, true)
|
||||||
|
.getMethod() as MutableMethod
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set the high precision video time method
|
||||||
|
*/
|
||||||
|
highPrecisionTimeMethod =
|
||||||
|
(object : MethodFingerprint("V", null, listOf("J", "J", "J", "J", "I", "L"), null) {}).also {
|
||||||
|
it.resolve(context, VideoTimeFingerprint.result!!.classDef)
|
||||||
|
}.result!!.mutableMethod
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hook the methods which set the time
|
||||||
|
*/
|
||||||
|
highPrecisionTimeHook(INTEGRATIONS_CLASS_DESCRIPTOR, "setVideoTime")
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/PlayerControllerPatch;"
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/VideoInformation;"
|
||||||
private const val INSERT_INDEX = 4
|
|
||||||
|
|
||||||
private lateinit var playerInitMethod: MutableMethod
|
private lateinit var playerInitMethod: MutableMethod
|
||||||
|
private lateinit var timeMethod: MutableMethod
|
||||||
|
private lateinit var highPrecisionTimeMethod: MutableMethod
|
||||||
|
|
||||||
|
private fun MutableMethod.insert(insert: InsertIndex, register: String, descriptor: String) =
|
||||||
|
addInstruction(insert.index, "invoke-static { $register }, $descriptor")
|
||||||
|
|
||||||
|
private fun MutableMethod.insertTimeHook(insert: InsertIndex, descriptor: String) =
|
||||||
|
insert(insert, "p1, p2", descriptor)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook the player controller.
|
* Hook the player controller.
|
||||||
*
|
*
|
||||||
* @param targetMethodClass The descriptor for the static method to invoke when the player controller is created.
|
* @param targetMethodClass The descriptor for the class to invoke when the player controller is created.
|
||||||
|
* @param targetMethodName The name of the static method to invoke when the player controller is created.
|
||||||
*/
|
*/
|
||||||
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
|
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
playerInitMethod.addInstruction(
|
playerInitMethod.insert(
|
||||||
INSERT_INDEX,
|
InsertIndex.CREATE,
|
||||||
"invoke-static { v0 }, $targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
"v0",
|
||||||
|
"$targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook the video time.
|
||||||
|
*
|
||||||
|
* @param targetMethodClass The descriptor for the static method to invoke when the player controller is created.
|
||||||
|
* @param targetMethodName The name of the static method to invoke when the player controller is created.
|
||||||
|
*/
|
||||||
|
internal fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
|
timeMethod.insertTimeHook(
|
||||||
|
InsertIndex.TIME,
|
||||||
|
"$targetMethodClass->$targetMethodName(J)V"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook the high precision video time.
|
||||||
|
*
|
||||||
|
* @param targetMethodClass The descriptor for the static method to invoke when the player controller is created.
|
||||||
|
* @param targetMethodName The name of the static method to invoke when the player controller is created.
|
||||||
|
*/
|
||||||
|
internal fun highPrecisionTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||||
|
highPrecisionTimeMethod.insertTimeHook(
|
||||||
|
InsertIndex.HIGH_PRECISION_TIME,
|
||||||
|
"$targetMethodClass->$targetMethodName(J)V"
|
||||||
|
)
|
||||||
|
|
||||||
|
enum class InsertIndex(internal val index: Int) {
|
||||||
|
CREATE(4),
|
||||||
|
TIME(2),
|
||||||
|
HIGH_PRECISION_TIME(0),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package app.revanced.patches.youtube.misc.quality.annotations
|
package app.revanced.patches.youtube.misc.video.quality.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[Package(
|
[Package(
|
||||||
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36")
|
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36")
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
internal annotation class DefaultVideoQualityCompatibility
|
internal annotation class RememberVideoQualityCompatibility
|
@ -1,18 +1,18 @@
|
|||||||
package app.revanced.patches.youtube.misc.quality.fingerprints
|
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
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 app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility
|
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
@Name("video-quality-reference-fingerprint")
|
@Name("video-quality-reference-fingerprint")
|
||||||
@DefaultVideoQualityCompatibility
|
@RememberVideoQualityCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
object VideoQualityReferenceFingerprint : MethodFingerprint(
|
object VideoQualityReferenceFingerprint : MethodFingerprint(
|
||||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
|
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
|
||||||
Opcode.IPUT_OBJECT, Opcode.RETURN_VOID
|
Opcode.IPUT_OBJECT, Opcode.RETURN_VOID
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -1,27 +1,27 @@
|
|||||||
|
|
||||||
package app.revanced.patches.youtube.misc.quality.fingerprints
|
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
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 app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility
|
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
@Name("video-quality-setter-fingerprint")
|
@Name("video-quality-setter-fingerprint")
|
||||||
@DefaultVideoQualityCompatibility
|
@RememberVideoQualityCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
object VideoQualitySetterFingerprint : MethodFingerprint(
|
object VideoQualitySetterFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
listOf("[L", "I", "I", "Z", "I"),
|
listOf("[L", "I", "I", "Z", "I"),
|
||||||
listOf(
|
listOf(
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
Opcode.INVOKE_VIRTUAL,
|
Opcode.INVOKE_VIRTUAL,
|
||||||
Opcode.IPUT_BOOLEAN,
|
Opcode.IPUT_BOOLEAN,
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -1,26 +1,26 @@
|
|||||||
|
|
||||||
package app.revanced.patches.youtube.misc.quality.fingerprints
|
package app.revanced.patches.youtube.misc.video.quality.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
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 app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility
|
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
@Name("video-user-quality-change-fingerprint")
|
@Name("video-user-quality-change-fingerprint")
|
||||||
@DefaultVideoQualityCompatibility
|
@RememberVideoQualityCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
object VideoUserQualityChangeFingerprint : MethodFingerprint(
|
object VideoUserQualityChangeFingerprint : MethodFingerprint(
|
||||||
"V",
|
"V",
|
||||||
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
listOf("L","L","I","J"),
|
listOf("L","L","I","J"),
|
||||||
listOf(
|
listOf(
|
||||||
Opcode.MOVE,
|
Opcode.MOVE,
|
||||||
Opcode.MOVE_WIDE,
|
Opcode.MOVE_WIDE,
|
||||||
Opcode.INVOKE_INTERFACE_RANGE,
|
Opcode.INVOKE_INTERFACE_RANGE,
|
||||||
Opcode.RETURN_VOID
|
Opcode.RETURN_VOID
|
||||||
)
|
)
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.quality.patch
|
package app.revanced.patches.youtube.misc.video.quality.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
@ -13,14 +13,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
|||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.quality.annotations.DefaultVideoQualityCompatibility
|
import app.revanced.patches.youtube.misc.video.quality.annotations.RememberVideoQualityCompatibility
|
||||||
import app.revanced.patches.youtube.misc.quality.fingerprints.VideoQualityReferenceFingerprint
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualityReferenceFingerprint
|
||||||
import app.revanced.patches.youtube.misc.quality.fingerprints.VideoQualitySetterFingerprint
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoQualitySetterFingerprint
|
||||||
import app.revanced.patches.youtube.misc.quality.fingerprints.VideoUserQualityChangeFingerprint
|
import app.revanced.patches.youtube.misc.video.quality.fingerprints.VideoUserQualityChangeFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||||
import app.revanced.patches.youtube.misc.videoid.patch.VideoIdPatch
|
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||||
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
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ import org.jf.dexlib2.iface.reference.FieldReference
|
|||||||
@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, SettingsPatch::class])
|
@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, SettingsPatch::class])
|
||||||
@Name("remember-video-quality")
|
@Name("remember-video-quality")
|
||||||
@Description("Adds the ability to remember the video quality you chose in the video quality flyout.")
|
@Description("Adds the ability to remember the video quality you chose in the video quality flyout.")
|
||||||
@DefaultVideoQualityCompatibility
|
@RememberVideoQualityCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class RememberVideoQualityPatch : BytecodePatch(
|
class RememberVideoQualityPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
@ -63,7 +63,7 @@ class RememberVideoQualityPatch : BytecodePatch(
|
|||||||
(method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference
|
(method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/VideoQualityPatch;->newVideoStarted(Ljava/lang/String;)V")
|
VideoIdPatch.injectCall("Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->newVideoStarted(Ljava/lang/String;)V")
|
||||||
|
|
||||||
val qIndexMethodName =
|
val qIndexMethodName =
|
||||||
context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name
|
context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name
|
||||||
@ -73,14 +73,14 @@ class RememberVideoQualityPatch : BytecodePatch(
|
|||||||
"""
|
"""
|
||||||
iget-object v0, p0, ${setterMethod.classDef.type}->${qualityFieldReference.name}:${qualityFieldReference.type}
|
iget-object v0, p0, ${setterMethod.classDef.type}->${qualityFieldReference.name}:${qualityFieldReference.type}
|
||||||
const-string v1, "$qIndexMethodName"
|
const-string v1, "$qIndexMethodName"
|
||||||
invoke-static {p1, p2, v0, v1}, Lapp/revanced/integrations/patches/VideoQualityPatch;->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I
|
invoke-static {p1, p2, v0, v1}, Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I
|
||||||
move-result p2
|
move-result p2
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
userQualityMethod.mutableMethod.addInstruction(
|
userQualityMethod.mutableMethod.addInstruction(
|
||||||
0,
|
0,
|
||||||
"invoke-static {p3}, Lapp/revanced/integrations/patches/VideoQualityPatch;->userChangedQuality(I)V"
|
"invoke-static {p3}, Lapp/revanced/integrations/patches/playback/quality/RememberVideoQualityPatch;->userChangedQuality(I)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.customplaybackspeed.annotations
|
package app.revanced.patches.youtube.misc.video.speed.custom.annotations
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
@ -1,11 +1,11 @@
|
|||||||
package app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints
|
package app.revanced.patches.youtube.misc.video.speed.custom.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints
|
package app.revanced.patches.youtube.misc.video.speed.custom.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints
|
package app.revanced.patches.youtube.misc.video.speed.custom.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
@Name("video-speed-patch-fingerprint")
|
@Name("video-speed-patch-fingerprint")
|
||||||
@ -12,6 +12,6 @@ import org.jf.dexlib2.Opcode
|
|||||||
object VideoSpeedPatchFingerprint : MethodFingerprint(
|
object VideoSpeedPatchFingerprint : MethodFingerprint(
|
||||||
opcodes = listOf(Opcode.FILL_ARRAY_DATA),
|
opcodes = listOf(Opcode.FILL_ARRAY_DATA),
|
||||||
customFingerprint = { methodDef ->
|
customFingerprint = { methodDef ->
|
||||||
methodDef.definingClass.endsWith("VideoSpeedPatch;") && methodDef.name == "<clinit>"
|
methodDef.definingClass.endsWith("CustomVideoSpeedPatch;") && methodDef.name == "<clinit>"
|
||||||
}
|
}
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.customplaybackspeed.patch
|
package app.revanced.patches.youtube.misc.video.speed.custom.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
@ -9,12 +9,11 @@ import app.revanced.patcher.extensions.replaceInstruction
|
|||||||
import app.revanced.patcher.patch.*
|
import app.revanced.patcher.patch.*
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.annotations.CustomPlaybackSpeedCompatibility
|
import app.revanced.patches.youtube.misc.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints.SpeedArrayGeneratorFingerprint
|
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.SpeedArrayGeneratorFingerprint
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints.SpeedLimiterFingerprint
|
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.SpeedLimiterFingerprint
|
||||||
import app.revanced.patches.youtube.misc.customplaybackspeed.fingerprints.VideoSpeedPatchFingerprint
|
import app.revanced.patches.youtube.misc.video.speed.custom.fingerprints.VideoSpeedPatchFingerprint
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderArrayPayload
|
import org.jf.dexlib2.builder.instruction.BuilderArrayPayload
|
||||||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
@ -25,20 +24,18 @@ import java.util.stream.DoubleStream
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("custom-playback-speed")
|
@Name("custom-video-speed")
|
||||||
@Description("Adds more video playback speed options.")
|
@Description("Adds more video speed options.")
|
||||||
@DependsOn([IntegrationsPatch::class, ResourceMappingResourcePatch::class])
|
@DependsOn([IntegrationsPatch::class])
|
||||||
@CustomPlaybackSpeedCompatibility
|
@CustomPlaybackSpeedCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class CustomPlaybackSpeedPatch : BytecodePatch(
|
class CustomVideoSpeedPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint, VideoSpeedPatchFingerprint
|
SpeedArrayGeneratorFingerprint, SpeedLimiterFingerprint, VideoSpeedPatchFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
//TODO: include setting to skip remembering the new speed
|
|
||||||
|
|
||||||
val speedLimitMin = minVideoSpeed!!.toFloat()
|
val speedLimitMin = minVideoSpeed!!.toFloat()
|
||||||
val speedLimitMax = maxVideoSpeed!!.toFloat().coerceAtLeast(speedLimitMin)
|
val speedLimitMax = maxVideoSpeed!!.toFloat().coerceAtLeast(speedLimitMin)
|
||||||
val speedsGranularity = videoSpeedsGranularity!!.toFloat()
|
val speedsGranularity = videoSpeedsGranularity!!.toFloat()
|
||||||
@ -64,7 +61,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch(
|
|||||||
|
|
||||||
val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA
|
val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA
|
||||||
|
|
||||||
val videoSpeedsArrayType = "Lapp/revanced/integrations/patches/VideoSpeedPatch;->videoSpeeds:[F"
|
val videoSpeedsArrayType = "Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;->videoSpeeds:[F"
|
||||||
|
|
||||||
arrayGenMethod.addInstructions(
|
arrayGenMethod.addInstructions(
|
||||||
arrayLengthConstIndex + 1,
|
arrayLengthConstIndex + 1,
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.misc.videoid.annotation
|
package app.revanced.patches.youtube.misc.video.videoid.annotation
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Compatibility
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
import app.revanced.patcher.annotation.Package
|
import app.revanced.patcher.annotation.Package
|
@ -1,11 +1,11 @@
|
|||||||
package app.revanced.patches.youtube.misc.videoid.fingerprint
|
package app.revanced.patches.youtube.misc.video.videoid.fingerprint
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
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 app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility
|
import app.revanced.patches.youtube.misc.video.videoid.annotation.VideoIdCompatibility
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
package app.revanced.patches.youtube.misc.videoid.patch
|
package app.revanced.patches.youtube.misc.video.videoid.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
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.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility
|
import app.revanced.patches.youtube.misc.video.videoid.annotation.VideoIdCompatibility
|
||||||
import app.revanced.patches.youtube.misc.videoid.fingerprint.VideoIdFingerprint
|
import app.revanced.patches.youtube.misc.video.videoid.fingerprint.VideoIdFingerprint
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Name("video-id-hook")
|
@Name("video-id-hook")
|
||||||
@ -27,24 +27,20 @@ class VideoIdPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
result = VideoIdFingerprint.result!!
|
with(VideoIdFingerprint.result!!) {
|
||||||
|
insertMethod = mutableMethod
|
||||||
|
insertIndex = scanResult.patternScanResult!!.endIndex + 2
|
||||||
|
|
||||||
insertMethod = result.mutableMethod
|
videoIdRegister = (insertMethod.instruction(insertIndex - 1) as OneRegisterInstruction).registerA
|
||||||
videoIdRegister =
|
}
|
||||||
(insertMethod.implementation!!.instructions[result.scanResult.patternScanResult!!.endIndex + 1] as OneRegisterInstruction).registerA
|
|
||||||
|
|
||||||
injectCall("Lapp/revanced/integrations/videoplayer/VideoInformation;->setCurrentVideoId(Ljava/lang/String;)V")
|
|
||||||
|
|
||||||
offset++ // offset so setCurrentVideoId is called before any injected call
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var offset = 2
|
private var videoIdRegister = 0
|
||||||
|
private var insertIndex = 0
|
||||||
|
|
||||||
private var videoIdRegister: Int = 0
|
|
||||||
private lateinit var result: MethodFingerprintResult
|
|
||||||
private lateinit var insertMethod: MutableMethod
|
private lateinit var insertMethod: MutableMethod
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,12 +49,10 @@ class VideoIdPatch : BytecodePatch(
|
|||||||
*/
|
*/
|
||||||
fun injectCall(
|
fun injectCall(
|
||||||
methodDescriptor: String
|
methodDescriptor: String
|
||||||
) {
|
) = insertMethod.addInstructions(
|
||||||
insertMethod.addInstructions(
|
insertIndex, // move-result-object offset
|
||||||
result.scanResult.patternScanResult!!.endIndex + offset, // move-result-object offset
|
"invoke-static {v$videoIdRegister}, $methodDescriptor"
|
||||||
"invoke-static {v$videoIdRegister}, $methodDescriptor"
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user