bump v2.147.0

This commit is contained in:
inotia00
2022-12-23 17:49:31 +09:00
parent 74aecf4720
commit 187d905bdb
1034 changed files with 21004 additions and 11645 deletions

View File

@ -0,0 +1,23 @@
package app.revanced.patches.youtube.video.customspeed.bytecode.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@FuzzyPatternScanMethod(2)
object SpeedArrayGeneratorFingerprint : MethodFingerprint(
"[L",
AccessFlags.PUBLIC or AccessFlags.STATIC,
null,
listOf(
Opcode.IF_NEZ,
Opcode.SGET_OBJECT,
Opcode.GOTO,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
),
listOf("0.0#")
)

View File

@ -0,0 +1,22 @@
package app.revanced.patches.youtube.video.customspeed.bytecode.fingerprints
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 SpeedLimiterFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("F"),
listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.CONST_HIGH16,
Opcode.GOTO,
Opcode.CONST_HIGH16,
Opcode.CONST_HIGH16,
Opcode.INVOKE_STATIC,
),
)

View File

@ -0,0 +1,11 @@
package app.revanced.patches.youtube.video.customspeed.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object VideoSpeedEntriesFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.FILL_ARRAY_DATA),
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("VideoSpeedEntries;") && methodDef.name == "<clinit>"
}
)

View File

@ -0,0 +1,150 @@
package app.revanced.patches.youtube.video.customspeed.bytecode.patch
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.extensions.instruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.video.customspeed.bytecode.fingerprints.*
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.patches.options.PatchOptions
import app.revanced.shared.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.builder.instruction.BuilderArrayPayload
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.iface.reference.MethodReference
@Name("custom-speed-bytecode-patch")
@DependsOn([PatchOptions::class])
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoSpeedBytecodePatch : BytecodePatch(
listOf(
SpeedArrayGeneratorFingerprint,
SpeedLimiterFingerprint,
VideoSpeedEntriesFingerprint
)
) {
private companion object {
const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR =
"$VIDEO_PATH/VideoSpeedPatch;"
const val INTEGRATIONS_VIDEO_SPEED_ENTRIES_CLASS_DESCRIPTOR =
"$VIDEO_PATH/VideoSpeedEntries;"
}
override fun execute(context: BytecodeContext): PatchResult {
var speed = PatchOptions.CustomSpeedArrays
val splits = speed!!.replace(" ","").split(",")
if (splits.count() < 1) throw IllegalArgumentException("Invalid speed elements")
val videoSpeedsArray = splits.map { it.toFloat().toRawBits() }
val arrayGenMethod = SpeedArrayGeneratorFingerprint.result?.mutableMethod!!
val arrayGenMethodImpl = arrayGenMethod.implementation!!
val sizeCallIndex = arrayGenMethodImpl.instructions
.indexOfFirst { ((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "size" }
if (sizeCallIndex == -1) return PatchResultError("Couldn't find call to size()")
val sizeCallResultRegister =
(arrayGenMethodImpl.instructions.elementAt(sizeCallIndex + 1) as OneRegisterInstruction).registerA
arrayGenMethod.addInstructions(
sizeCallIndex + 2,
"""
invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->isCustomVideoSpeedEnabled()Z
move-result v9
if-eqz v9, :defaultspeed
const/4 v$sizeCallResultRegister, 0x0
""", listOf(ExternalLabel("defaultspeed", arrayGenMethod.instruction(sizeCallIndex + 2)))
)
val (arrayLengthConstIndex, arrayLengthConst) = arrayGenMethodImpl.instructions.withIndex()
.first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 7 }
val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA
val videoSpeedsArrayType = "$INTEGRATIONS_VIDEO_SPEED_ENTRIES_CLASS_DESCRIPTOR->videoSpeed:[F"
arrayGenMethod.addInstructions(
arrayLengthConstIndex + 1,
"""
if-eqz v9, :defaultspeed
sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType
array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination
""", listOf(ExternalLabel("defaultspeed", arrayGenMethod.instruction(arrayLengthConstIndex + 1)))
)
val (originalArrayFetchIndex, originalArrayFetch) = arrayGenMethodImpl.instructions.withIndex()
.first {
val reference = ((it.value as? ReferenceInstruction)?.reference as? FieldReference)
reference?.definingClass?.contains("PlayerConfigModel") ?: false &&
reference?.type == "[F"
}
val originalArrayFetchDestination = (originalArrayFetch as OneRegisterInstruction).registerA
arrayGenMethod.addInstructions(
originalArrayFetchIndex + 1,
"""
if-eqz v9, :defaultspeed
sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType
""", listOf(ExternalLabel("defaultspeed", arrayGenMethod.instruction(originalArrayFetchIndex + 1)))
)
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!;
val limiterMethodImpl = limiterMethod.implementation!!
val speedLimitMin = 0.0f
val speedLimitMax = 100f
val (limiterMinConstIndex, limiterMinConst) = limiterMethodImpl.instructions.withIndex()
.first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() }
val (limiterMaxConstIndex, limiterMaxConst) = limiterMethodImpl.instructions.withIndex()
.first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() }
val limiterMinConstDestination = (limiterMinConst as OneRegisterInstruction).registerA
val limiterMaxConstDestination = (limiterMaxConst as OneRegisterInstruction).registerA
fun hexFloat(float: Float): String = "0x%08x".format(float.toRawBits())
limiterMethod.replaceInstruction(
limiterMinConstIndex,
"const/high16 v$limiterMinConstDestination, ${hexFloat(speedLimitMin)}"
)
limiterMethod.replaceInstruction(
limiterMaxConstIndex,
"const/high16 v$limiterMaxConstDestination, ${hexFloat(speedLimitMax)}"
)
val constructorResult = VideoSpeedEntriesFingerprint.result!!
val constructor = constructorResult.mutableMethod
val implementation = constructor.implementation!!
constructor.replaceInstruction(
0,
"const/16 v0, ${videoSpeedsArray.size}"
)
val arrayPayloadIndex = implementation.instructions.size - 1
implementation.replaceInstruction(
arrayPayloadIndex,
BuilderArrayPayload(
4,
videoSpeedsArray
)
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,70 @@
package app.revanced.patches.youtube.video.customspeed.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.video.customspeed.bytecode.patch.CustomVideoSpeedBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.patches.options.PatchOptions
import app.revanced.shared.util.resources.ResourceHelper
import app.revanced.shared.util.resources.ResourceUtils.copyXmlNode
import java.nio.file.Files
import java.nio.file.StandardCopyOption
@Patch
@Name("custom-video-speed")
@Description("Adds more video speed options.")
@DependsOn(
[
CustomVideoSpeedBytecodePatch::class,
PatchOptions::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class CustomVideoSpeedPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
* Copy arrays
*/
context.copyXmlNode("youtube/speed/host", "values/arrays.xml", "resources")
var speed = PatchOptions.CustomSpeedArrays
?: return PatchResultError("Invalid video speed array.")
val splits = speed.replace(" ","").split(",")
if (splits.count() < 1) throw IllegalArgumentException("Invalid speed elements")
val speedElements = splits.map { it }
for (index in 0 until splits.count()) {
ResourceHelper.addEntryValues(context, speedElements[index])
ResourceHelper.addEntries(context, speedElements[index] + "x")
}
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
"PREFERENCE: VIDEO_SETTINGS",
"SETTINGS: CUSTOM_VIDEO_SPEED"
)
ResourceHelper.patchSuccess(
context,
"custom-video-speed"
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.patches.youtube.video.quality.bytecode.fingerprints
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 VideoQualityReferenceFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
Opcode.IPUT_OBJECT, Opcode.RETURN_VOID
)
)

View File

@ -0,0 +1,19 @@
package app.revanced.patches.youtube.video.quality.bytecode.fingerprints
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 VideoQualitySetterFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("[L", "I", "I", "Z", "I"),
listOf(
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_BOOLEAN,
)
)

View File

@ -0,0 +1,18 @@
package app.revanced.patches.youtube.video.quality.bytecode.fingerprints
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 VideoUserQualityChangeFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("L","L","I","J"),
listOf(
Opcode.MOVE,
Opcode.MOVE_WIDE,
Opcode.INVOKE_INTERFACE_RANGE,
Opcode.RETURN_VOID
)
)

View File

@ -0,0 +1,71 @@
package app.revanced.patches.youtube.video.quality.bytecode.patch
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.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.VideoQualityReferenceFingerprint
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.VideoQualitySetterFingerprint
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.VideoUserQualityChangeFingerprint
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
@Name("default-video-quality-bytecode-patch")
@DependsOn([LegacyVideoIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class VideoQualityBytecodePatch : BytecodePatch(
listOf(
VideoQualitySetterFingerprint
)
) {
private companion object {
const val INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR =
"$VIDEO_PATH/VideoQualityPatch;"
}
override fun execute(context: BytecodeContext): PatchResult {
val setterMethod = VideoQualitySetterFingerprint.result!!
VideoUserQualityChangeFingerprint.resolve(context, setterMethod.classDef)
val userQualityResult = VideoUserQualityChangeFingerprint.result!!
VideoQualityReferenceFingerprint.resolve(context, setterMethod.classDef)
val qualityFieldReference =
VideoQualityReferenceFingerprint.result!!.method.let { method ->
(method.implementation!!.instructions.elementAt(0) as ReferenceInstruction).reference as FieldReference
}
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
val qIndexMethodName =
context.classes.single { it.type == qualityFieldReference.type }.methods.single { it.parameterTypes.first() == "I" }.name
setterMethod.mutableMethod.addInstructions(
0,
"""
iget-object v0, p0, ${setterMethod.classDef.type}->${qualityFieldReference.name}:${qualityFieldReference.type}
const-string v1, "$qIndexMethodName"
invoke-static {p1, p2, v0, v1}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I
move-result p2
""",
)
userQualityResult.mutableMethod.addInstruction(
0,
"invoke-static {p3}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->userChangedQuality(I)V"
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,56 @@
package app.revanced.patches.youtube.video.quality.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.video.quality.bytecode.patch.VideoQualityBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
import app.revanced.shared.util.resources.ResourceUtils.copyXmlNode
@Patch
@Name("default-video-quality")
@Description("Adds ability to set default video quality settings.")
@DependsOn(
[
VideoQualityBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class VideoQualityPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
* Copy arrays
*/
context.copyXmlNode("youtube/quality/host", "values/arrays.xml", "resources")
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
"PREFERENCE: VIDEO_SETTINGS",
"SETTINGS: DEFAULT_VIDEO_QUALITY"
)
ResourceHelper.patchSuccess(
context,
"default-video-quality"
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.patches.youtube.video.speed.bytecode.fingerprints
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 VideoSpeedReferenceFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"), listOf(
Opcode.IPUT_OBJECT, Opcode.RETURN_VOID
)
)

View File

@ -0,0 +1,19 @@
package app.revanced.patches.youtube.video.speed.bytecode.fingerprints
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 VideoSpeedSetterFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("[L", "I"),
listOf(
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_VIRTUAL,
)
)

View File

@ -0,0 +1,27 @@
package app.revanced.patches.youtube.video.speed.bytecode.fingerprints
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 VideoUserSpeedChangeFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("L","L","I","J"),
listOf(
Opcode.IGET_OBJECT,
Opcode.IF_EQZ,
Opcode.IF_EQZ,
Opcode.IGET,
Opcode.CHECK_CAST,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID
)
)

View File

@ -0,0 +1,112 @@
package app.revanced.patches.youtube.video.speed.bytecode.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.annotations.DependsOn
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.Companion.toMutable
import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.VideoSpeedReferenceFingerprint
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.VideoSpeedSetterFingerprint
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.VideoUserSpeedChangeFingerprint
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.bytecode.BytecodeHelper
import app.revanced.shared.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
import org.jf.dexlib2.immutable.ImmutableMethodParameter
@Name("default-video-speed-bytecode-patch")
@DependsOn([LegacyVideoIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class VideoSpeedBytecodePatch : BytecodePatch(
listOf(
VideoSpeedSetterFingerprint, VideoUserSpeedChangeFingerprint
)
) {
private companion object {
const val INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR =
"$VIDEO_PATH/VideoSpeedPatch;"
}
override fun execute(context: BytecodeContext): PatchResult {
val userSpeedResult = VideoUserSpeedChangeFingerprint.result!!
val userSpeedMutableMethod = userSpeedResult.mutableMethod
val setterResult = VideoSpeedSetterFingerprint.result!!
val setterMutableMethod = setterResult.mutableMethod
VideoUserSpeedChangeFingerprint.resolve(context, setterResult.classDef)
val FirstReference =
VideoUserSpeedChangeFingerprint.result!!.method.let { method ->
(method.implementation!!.instructions.elementAt(5) as ReferenceInstruction).reference as FieldReference
}
val SecondReference =
VideoUserSpeedChangeFingerprint.result!!.method.let { method ->
(method.implementation!!.instructions.elementAt(10) as ReferenceInstruction).reference as FieldReference
}
val ThirdReference =
VideoUserSpeedChangeFingerprint.result!!.method.let { method ->
(method.implementation!!.instructions.elementAt(11) as ReferenceInstruction).reference as MethodReference
}
userSpeedMutableMethod.addInstruction(
0, "invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->userChangedSpeed()V"
)
setterMutableMethod.addInstructions(
0,
"""
invoke-static {p1, p2}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->getSpeedValue([Ljava/lang/Object;I)F
move-result v0
invoke-direct {p0, v0}, ${setterResult.classDef.type}->overrideSpeed(F)V
""",
)
val classDef = userSpeedResult.mutableClass
classDef.methods.add(
ImmutableMethod(
classDef.type,
"overrideSpeed",
listOf(ImmutableMethodParameter("F", null, null)),
"V",
AccessFlags.PRIVATE or AccessFlags.PRIVATE,
null,
null,
ImmutableMethodImplementation(
4, """
const/4 v0, 0x0
cmpg-float v0, v3, v0
if-gez v0, :cond_0
return-void
:cond_0
iget-object v0, v2, ${setterResult.classDef.type}->${FirstReference.name}:${FirstReference.type}
check-cast v0, ${SecondReference.definingClass}
iget-object v1, v0, ${SecondReference.definingClass}->${SecondReference.name}:${SecondReference.type}
invoke-virtual {v1, v3}, $ThirdReference
return-void
""".toInstructions(), null, null
)
).toMutable()
)
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
BytecodeHelper.patchStatus(context, "VideoSpeed")
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,48 @@
package app.revanced.patches.youtube.video.speed.resource.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.video.speed.bytecode.patch.VideoSpeedBytecodePatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.shared.annotation.YouTubeCompatibility
import app.revanced.shared.util.resources.ResourceHelper
@Patch
@Name("default-video-speed")
@Description("Adds ability to set default video speed settings.")
@DependsOn(
[
VideoSpeedBytecodePatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class VideoSpeedPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
add settings
*/
ResourceHelper.addSettings(
context,
"PREFERENCE_CATEGORY: REVANCED_EXTENDED_SETTINGS",
"PREFERENCE: VIDEO_SETTINGS",
"SETTINGS: DEFAULT_VIDEO_SPEED"
)
ResourceHelper.patchSuccess(
context,
"default-video-speed"
)
return PatchResultSuccess()
}
}