Compare commits

..

13 Commits

Author SHA1 Message Date
semantic-release-bot
89fed3874f chore(release): 2.185.0-dev.4 [skip ci]
# [2.185.0-dev.4](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.3...v2.185.0-dev.4) (2023-07-19)

### Bug Fixes

* **TikTok - Show seekbar:** fix seekbar not always showing ([#2660](https://github.com/ReVanced/revanced-patches/issues/2660)) ([e4adaeb](e4adaebad4))
2023-07-19 12:58:39 +00:00
Vu Hoan Huy
e4adaebad4 fix(TikTok - Show seekbar): fix seekbar not always showing (#2660) 2023-07-19 14:55:17 +02:00
semantic-release-bot
0b78e8377b chore(release): 2.185.0-dev.3 [skip ci]
# [2.185.0-dev.3](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.2...v2.185.0-dev.3) (2023-07-17)

### Bug Fixes

* **Sync for Reddit - Disable ads:** fix compatibility with latest version ([6b2f786](6b2f7862d1))
2023-07-17 22:39:26 +00:00
oSumAtrIX
6b2f7862d1 fix(Sync for Reddit - Disable ads): fix compatibility with latest version 2023-07-18 00:36:37 +02:00
Aaronjamt
4668861d65 chore: fix typos (fingereprints -> fingerprints) (#2650) 2023-07-17 15:21:07 +04:00
semantic-release-bot
c5c63537ff chore(release): 2.185.0-dev.2 [skip ci]
# [2.185.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.1...v2.185.0-dev.2) (2023-07-15)

### Bug Fixes

* allocate for more than eight `LithoFilter` array items ([#2643](https://github.com/ReVanced/revanced-patches/issues/2643)) ([5de8ee5](5de8ee51c1))
2023-07-15 21:27:19 +00:00
johnconner122
5de8ee51c1 fix: allocate for more than eight LithoFilter array items (#2643) 2023-07-15 23:24:34 +02:00
semantic-release-bot
65087833b0 chore(release): 2.185.0-dev.1 [skip ci]
# [2.185.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.184.1-dev.1...v2.185.0-dev.1) (2023-07-15)

### Features

* **youtube:** rename `video-speed` to `playback-speed` ([#2642](https://github.com/revanced/revanced-patches/issues/2642)) ([75fd96f](75fd96f4c3))
2023-07-15 12:36:34 +00:00
KAZI MMT
75fd96f4c3 feat(youtube): rename video-speed to playback-speed (#2642) 2023-07-15 16:32:39 +04:00
semantic-release-bot
2cac5b1b74 chore(release): 2.184.1-dev.1 [skip ci]
## [2.184.1-dev.1](https://github.com/revanced/revanced-patches/compare/v2.184.0...v2.184.1-dev.1) (2023-07-14)

### Bug Fixes

* **youtube/sponsorblock:** fix some segments skipping slightly too late ([#2634](https://github.com/revanced/revanced-patches/issues/2634)) ([180c777](180c7775e6))
2023-07-14 08:39:40 +00:00
LisoUseInAIKyrios
180c7775e6 fix(youtube/sponsorblock): fix some segments skipping slightly too late (#2634) 2023-07-14 12:35:49 +04:00
semantic-release-bot
d0440c17f6 chore(release): 2.184.0 [skip ci]
# [2.184.0](https://github.com/revanced/revanced-patches/compare/v2.183.1...v2.184.0) (2023-07-11)

### Features

* **youtube/custom-branding:** update logo ([801584b](801584b78c))
2023-07-11 00:56:29 +00:00
oSumAtrIX
c6f4497031 chore: merge branch dev to main (#2615) 2023-07-11 02:54:05 +02:00
21 changed files with 135 additions and 143 deletions

View File

@@ -1,3 +1,45 @@
# [2.185.0-dev.4](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.3...v2.185.0-dev.4) (2023-07-19)
### Bug Fixes
* **TikTok - Show seekbar:** fix seekbar not always showing ([#2660](https://github.com/ReVanced/revanced-patches/issues/2660)) ([f2742f1](https://github.com/ReVanced/revanced-patches/commit/f2742f1ba117809971a10780823fca99c19a4f34))
# [2.185.0-dev.3](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.2...v2.185.0-dev.3) (2023-07-17)
### Bug Fixes
* **Sync for Reddit - Disable ads:** fix compatibility with latest version ([1456577](https://github.com/ReVanced/revanced-patches/commit/1456577f11c4a7e49d6c1ba0103b919dc487f4cf))
# [2.185.0-dev.2](https://github.com/ReVanced/revanced-patches/compare/v2.185.0-dev.1...v2.185.0-dev.2) (2023-07-15)
### Bug Fixes
* allocate for more than eight `LithoFilter` array items ([#2643](https://github.com/ReVanced/revanced-patches/issues/2643)) ([fc8660b](https://github.com/ReVanced/revanced-patches/commit/fc8660b740bec2747e5f82b7321027bb8a51e0cf))
# [2.185.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.184.1-dev.1...v2.185.0-dev.1) (2023-07-15)
### Features
* **youtube:** rename `video-speed` to `playback-speed` ([#2642](https://github.com/revanced/revanced-patches/issues/2642)) ([77e8639](https://github.com/revanced/revanced-patches/commit/77e8639b71048f2795f8f32fe18d052b335e3ce4))
## [2.184.1-dev.1](https://github.com/revanced/revanced-patches/compare/v2.184.0...v2.184.1-dev.1) (2023-07-14)
### Bug Fixes
* **youtube/sponsorblock:** fix some segments skipping slightly too late ([#2634](https://github.com/revanced/revanced-patches/issues/2634)) ([3175431](https://github.com/revanced/revanced-patches/commit/31754311870324b1e245b12965d7486878e9eba4))
# [2.184.0](https://github.com/revanced/revanced-patches/compare/v2.183.1...v2.184.0) (2023-07-11)
### Features
* **youtube/custom-branding:** update logo ([e2187f3](https://github.com/revanced/revanced-patches/commit/e2187f33ff82fce40592517aef31cb191b42987c))
# [2.184.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.183.1...v2.184.0-dev.1) (2023-07-11) # [2.184.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.183.1...v2.184.0-dev.1) (2023-07-11)

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true org.gradle.parallel = true
org.gradle.caching = true org.gradle.caching = true
kotlin.code.style = official kotlin.code.style = official
version = 2.184.0-dev.1 version = 2.185.0-dev.4

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,10 @@
package app.revanced.patches.syncforreddit.detection.piracy.fingerprints package app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.fingerprints
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
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.TypeReference
object PiracyDetectionFingerprint : MethodFingerprint( object PiracyDetectionFingerprint : MethodFingerprint(
returnType = "V", returnType = "V",

View File

@@ -1,19 +1,18 @@
package app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.patch package app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.syncforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
@Description("Disables detection of modified versions.") @Description("Disables detection of modified versions.")
@Version("0.0.1")
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) { class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
// Do not return an error if the fingerprint is not resolved.
// This is fine because new versions of the target app do not need this patch.
PiracyDetectionFingerprint.result?.mutableMethod?.apply { PiracyDetectionFingerprint.result?.mutableMethod?.apply {
addInstruction( addInstruction(
0, 0,
@@ -21,7 +20,7 @@ class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerpr
return-void return-void
""" """
) )
} ?: return PiracyDetectionFingerprint.toErrorResult() }
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@@ -1,12 +0,0 @@
package app.revanced.patches.tiktok.interaction.seekbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object AwemeGetVideoControlFingerprint : MethodFingerprint(
"L",
AccessFlags.PUBLIC.value,
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/Aweme;") && methodDef.name == "getVideoControl"
}
)

View File

@@ -0,0 +1,9 @@
package app.revanced.patches.tiktok.interaction.seekbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SetSeekBarShowTypeFingerprint : MethodFingerprint(
strings = listOf(
"seekbar show type change, change to:"
),
)

View File

@@ -6,17 +6,14 @@ 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.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCompatibility import app.revanced.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCompatibility
import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.AwemeGetVideoControlFingerprint import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.SetSeekBarShowTypeFingerprint
import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction22t
import org.jf.dexlib2.builder.instruction.BuilderInstruction11n
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
@Patch @Patch
@Name("Show seekbar") @Name("Show seekbar")
@@ -25,27 +22,20 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
@Version("0.0.1") @Version("0.0.1")
class ShowSeekbarPatch : BytecodePatch( class ShowSeekbarPatch : BytecodePatch(
listOf( listOf(
AwemeGetVideoControlFingerprint SetSeekBarShowTypeFingerprint,
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
//Get VideoControl FieldReference SetSeekBarShowTypeFingerprint.result?.mutableMethod?.apply {
val videoControl = context.findClass { it.type.endsWith("/VideoControl;") } val typeRegister = getInstruction<Instruction22t>(1).registerB
?: return PatchResultError("Can not find target class")
val fieldList = videoControl.immutableClass.fields.associateBy { field -> field.name }
AwemeGetVideoControlFingerprint.result?.mutableMethod?.implementation?.apply {
val ifNullLabel = newLabelForIndex(1)
addInstructions( addInstructions(
1, 0,
listOf( """
BuilderInstruction11n(Opcode.CONST_4, 1, 1), const/16 v$typeRegister, 0x64
BuilderInstruction21t(Opcode.IF_EQZ, 0, ifNullLabel), """
BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["showProgressBar"]!!),
BuilderInstruction22c(Opcode.IPUT, 1, 0, fieldList["draftProgressBar"]!!)
)
) )
} ?: return AwemeGetVideoControlFingerprint.toErrorResult() } ?: return SetSeekBarShowTypeFingerprint.toErrorResult()
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@@ -176,7 +176,7 @@ class LithoFilterPatch : BytecodePatch(
""" """
new-instance v1, $classDescriptor new-instance v1, $classDescriptor
invoke-direct {v1}, $classDescriptor-><init>()V invoke-direct {v1}, $classDescriptor-><init>()V
const/4 v2, ${filterCount++} const/16 v2, ${filterCount++}
aput-object v1, v0, v2 aput-object v1, v0, v2
""" """
) )
@@ -187,7 +187,7 @@ class LithoFilterPatch : BytecodePatch(
} }
override fun close() = LithoFilterFingerprint.result!! override fun close() = LithoFilterFingerprint.result!!
.mutableMethod.replaceInstruction(0, "const/4 v0, $filterCount") .mutableMethod.replaceInstruction(0, "const/16 v0, $filterCount")
companion object { companion object {
private val MethodFingerprint.patternScanResult private val MethodFingerprint.patternScanResult
@@ -208,4 +208,4 @@ class LithoFilterPatch : BytecodePatch(
private var filterCount = 0 private var filterCount = 0
} }
} }

View File

@@ -1,8 +0,0 @@
package app.revanced.patches.youtube.video.information.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object VideoTimeFingerprint : MethodFingerprint(
strings = listOf("MedialibPlayerTimeInfo{currentPositionMillis=")
)

View File

@@ -10,7 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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
@@ -44,7 +43,6 @@ class VideoInformationPatch : BytecodePatch(
PlayerInitFingerprint, PlayerInitFingerprint,
CreateVideoPlayerSeekbarFingerprint, CreateVideoPlayerSeekbarFingerprint,
PlayerControllerSetTimeReferenceFingerprint, PlayerControllerSetTimeReferenceFingerprint,
VideoTimeFingerprint,
OnPlaybackSpeedItemClickFingerprint, OnPlaybackSpeedItemClickFingerprint,
) )
) { ) {
@@ -118,18 +116,10 @@ class VideoInformationPatch : BytecodePatch(
.getMethod() as MutableMethod .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 * Hook the methods which set the time
*/ */
highPrecisionTimeHook(INTEGRATIONS_CLASS_DESCRIPTOR, "setVideoTimeHighPrecision") videoTimeHook(INTEGRATIONS_CLASS_DESCRIPTOR, "setVideoTime")
/* /*
@@ -164,9 +154,6 @@ class VideoInformationPatch : BytecodePatch(
private lateinit var timeMethod: MutableMethod private lateinit var timeMethod: MutableMethod
private var timeInitInsertIndex = 2 private var timeInitInsertIndex = 2
private lateinit var highPrecisionTimeMethod: MutableMethod
private var highPrecisionInsertIndex = 0
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) = private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) =
addInstruction(insertIndex, "invoke-static { $register }, $descriptor") addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
@@ -202,20 +189,6 @@ class VideoInformationPatch : BytecodePatch(
"$targetMethodClass->$targetMethodName(J)V" "$targetMethodClass->$targetMethodName(J)V"
) )
/**
* Hook the high precision video time.
* The hooks is called extremely often (10 to 15 times a seconds), so use with caution.
* Note: the hook is usually called _off_ the main thread
*
* @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(
highPrecisionInsertIndex++,
"$targetMethodClass->$targetMethodName(J)V"
)
private fun getReference(instructions: List<BuilderInstruction>, offset: Int, opcode: Opcode) = private fun getReference(instructions: List<BuilderInstruction>, offset: Int, opcode: Opcode) =
(instructions[instructions.indexOfFirst { it.opcode == opcode } + offset] as ReferenceInstruction) (instructions[instructions.indexOfFirst { it.opcode == opcode } + offset] as ReferenceInstruction)
.reference.toString() .reference.toString()

View File

@@ -1,25 +1,25 @@
package app.revanced.patches.youtube.video.speed package app.revanced.patches.youtube.video.speed
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.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.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch import app.revanced.patches.youtube.video.speed.custom.patch.CustomPlaybackSpeedPatch
import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackSpeedPatch import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackSpeedPatch
@Patch @Patch
@Name("Video speed") @Name("Playback speed")
@Description("Adds custom video speeds and ability to remember the playback speed you chose in the video playback speed flyout.") @Description("Adds custom playback speeds and ability to remember the playback speed you chose in the video playback speed flyout.")
@DependsOn([CustomVideoSpeedPatch::class, RememberPlaybackSpeedPatch::class]) @DependsOn([CustomPlaybackSpeedPatch::class, RememberPlaybackSpeedPatch::class])
@VideoSpeedCompatibility @PlaybackSpeedCompatibility
@Version("0.0.1") @Version("0.0.1")
class VideoSpeed : BytecodePatch() { class PlaybackSpeed : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
return PatchResultSuccess() // All patches this patch depends on succeed. return PatchResultSuccess() // All patches this patch depends on succeed.
} }
} }

View File

@@ -5,4 +5,4 @@ import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.google.android.youtube", arrayOf("18.20.39", "18.23.35"))]) @Compatibility([Package("com.google.android.youtube", arrayOf("18.20.39", "18.23.35"))])
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class VideoSpeedCompatibility internal annotation class PlaybackSpeedCompatibility

View File

@@ -2,7 +2,7 @@ package app.revanced.patches.youtube.video.speed.custom.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object GetOldVideoSpeedsFingerprint : MethodFingerprint( object GetOldPlaybackSpeedsFingerprint : MethodFingerprint(
parameters = listOf("[L", "I"), parameters = listOf("[L", "I"),
strings = listOf("menu_item_playback_speed") strings = listOf("menu_item_playback_speed")
) )

View File

@@ -2,6 +2,6 @@ package app.revanced.patches.youtube.video.speed.custom.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ShowOldVideoSpeedMenuFingerprint : MethodFingerprint( object ShowOldPlaybackSpeedMenuFingerprint : MethodFingerprint(
strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT") strings = listOf("PLAYBACK_RATE_MENU_BOTTOM_SHEET_FRAGMENT")
) )

View File

@@ -0,0 +1,7 @@
package app.revanced.patches.youtube.video.speed.custom.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ShowOldPlaybackSpeedMenuIntegrationsFingerprint : MethodFingerprint(
customFingerprint = { method, _ -> method.name == "showOldPlaybackSpeedMenu" }
)

View File

@@ -1,7 +0,0 @@
package app.revanced.patches.youtube.video.speed.custom.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ShowOldVideoSpeedMenuIntegrationsFingerprint : MethodFingerprint(
customFingerprint = { method, _ -> method.name == "showOldVideoSpeedMenu" }
)

View File

@@ -31,16 +31,16 @@ import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.iface.reference.MethodReference import org.jf.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.immutable.ImmutableField import org.jf.dexlib2.immutable.ImmutableField
@Name("Custom video speed") @Name("Custom playback speed")
@Description("Adds custom video speed options.") @Description("Adds custom playback speed options.")
@DependsOn([IntegrationsPatch::class, LithoFilterPatch::class, SettingsPatch::class, BottomSheetHookPatch::class]) @DependsOn([IntegrationsPatch::class, LithoFilterPatch::class, SettingsPatch::class, BottomSheetHookPatch::class])
@Version("0.0.1") @Version("0.0.1")
class CustomVideoSpeedPatch : BytecodePatch( class CustomPlaybackSpeedPatch : BytecodePatch(
listOf( listOf(
SpeedArrayGeneratorFingerprint, SpeedArrayGeneratorFingerprint,
SpeedLimiterFingerprint, SpeedLimiterFingerprint,
GetOldVideoSpeedsFingerprint, GetOldPlaybackSpeedsFingerprint,
ShowOldVideoSpeedMenuIntegrationsFingerprint ShowOldPlaybackSpeedMenuIntegrationsFingerprint
) )
) { ) {
@@ -81,12 +81,12 @@ class CustomVideoSpeedPatch : BytecodePatch(
val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA val arrayLengthConstDestination = (arrayLengthConst as OneRegisterInstruction).registerA
val videoSpeedsArrayType = "$INTEGRATIONS_CLASS_DESCRIPTOR->customVideoSpeeds:[F" val playbackSpeedsArrayType = "$INTEGRATIONS_CLASS_DESCRIPTOR->customPlaybackSpeeds:[F"
arrayGenMethod.addInstructions( arrayGenMethod.addInstructions(
arrayLengthConstIndex + 1, arrayLengthConstIndex + 1,
""" """
sget-object v$arrayLengthConstDestination, $videoSpeedsArrayType sget-object v$arrayLengthConstDestination, $playbackSpeedsArrayType
array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination array-length v$arrayLengthConstDestination, v$arrayLengthConstDestination
""" """
) )
@@ -102,7 +102,7 @@ class CustomVideoSpeedPatch : BytecodePatch(
arrayGenMethod.replaceInstruction( arrayGenMethod.replaceInstruction(
originalArrayFetchIndex, originalArrayFetchIndex,
"sget-object v$originalArrayFetchDestination, $videoSpeedsArrayType" "sget-object v$originalArrayFetchDestination, $playbackSpeedsArrayType"
) )
val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!! val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!!
@@ -121,24 +121,24 @@ class CustomVideoSpeedPatch : BytecodePatch(
// edit: alternatively this might work by overriding with fixed values such as 0.1x and 10x // edit: alternatively this might work by overriding with fixed values such as 0.1x and 10x
limiterMethod.replaceInstruction( limiterMethod.replaceInstruction(
limiterMinConstIndex, limiterMinConstIndex,
"sget v$limiterMinConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->minVideoSpeed:F" "sget v$limiterMinConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->minPlaybackSpeed:F"
) )
limiterMethod.replaceInstruction( limiterMethod.replaceInstruction(
limiterMaxConstIndex, limiterMaxConstIndex,
"sget v$limiterMaxConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->maxVideoSpeed:F" "sget v$limiterMaxConstDestination, $INTEGRATIONS_CLASS_DESCRIPTOR->maxPlaybackSpeed:F"
) )
// region Force old video quality menu. // region Force old video quality menu.
// This is necessary, because there is no known way of adding custom video speeds to the new menu. // This is necessary, because there is no known way of adding custom playback speeds to the new menu.
BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR) BottomSheetHookPatch.addHook(INTEGRATIONS_CLASS_DESCRIPTOR)
// Required to check if the video speed menu is currently shown. // Required to check if the playback speed menu is currently shown.
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
GetOldVideoSpeedsFingerprint.result?.let { result -> GetOldPlaybackSpeedsFingerprint.result?.let { result ->
// Add a static INSTANCE field to the class. // Add a static INSTANCE field to the class.
// This is later used to call "showOldVideoSpeedMenu" on the instance. // This is later used to call "showOldPlaybackSpeedMenu" on the instance.
val instanceField = ImmutableField( val instanceField = ImmutableField(
result.classDef.type, result.classDef.type,
"INSTANCE", "INSTANCE",
@@ -154,15 +154,15 @@ class CustomVideoSpeedPatch : BytecodePatch(
// In order to prevent a conflict with another patch, add the instruction at index 1. // In order to prevent a conflict with another patch, add the instruction at index 1.
result.mutableMethod.addInstruction(1, "sput-object p0, $instanceField") result.mutableMethod.addInstruction(1, "sput-object p0, $instanceField")
// Get the "showOldVideoSpeedMenu" method. // Get the "showOldPlaybackSpeedMenu" method.
// This is later called on the field INSTANCE. // This is later called on the field INSTANCE.
val showOldVideoSpeedMenuMethod = ShowOldVideoSpeedMenuFingerprint.also { val showOldPlaybackSpeedMenuMethod = ShowOldPlaybackSpeedMenuFingerprint.also {
if (!it.resolve(context, result.classDef)) if (!it.resolve(context, result.classDef))
throw ShowOldVideoSpeedMenuFingerprint.toErrorResult() throw ShowOldPlaybackSpeedMenuFingerprint.toErrorResult()
}.result!!.method.toString() }.result!!.method.toString()
// Insert the call to the "showOldVideoSpeedMenu" method on the field INSTANCE. // Insert the call to the "showOldPlaybackSpeedMenu" method on the field INSTANCE.
ShowOldVideoSpeedMenuIntegrationsFingerprint.result?.mutableMethod?.apply { ShowOldPlaybackSpeedMenuIntegrationsFingerprint.result?.mutableMethod?.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
implementation!!.instructions.lastIndex, implementation!!.instructions.lastIndex,
""" """
@@ -170,11 +170,11 @@ class CustomVideoSpeedPatch : BytecodePatch(
if-nez v0, :not_null if-nez v0, :not_null
return-void return-void
:not_null :not_null
invoke-virtual { v0 }, $showOldVideoSpeedMenuMethod invoke-virtual { v0 }, $showOldPlaybackSpeedMenuMethod
""" """
) )
} ?: return ShowOldVideoSpeedMenuIntegrationsFingerprint.toErrorResult() } ?: return ShowOldPlaybackSpeedMenuIntegrationsFingerprint.toErrorResult()
} ?: return GetOldVideoSpeedsFingerprint.toErrorResult() } ?: return GetOldPlaybackSpeedsFingerprint.toErrorResult()
// endregion // endregion
@@ -183,10 +183,10 @@ class CustomVideoSpeedPatch : BytecodePatch(
private companion object { private companion object {
private const val FILTER_CLASS_DESCRIPTOR = private const val FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/patches/components/VideoSpeedMenuFilterPatch;" "Lapp/revanced/integrations/patches/components/PlaybackSpeedMenuFilterPatch;"
private const val INTEGRATIONS_CLASS_DESCRIPTOR = private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/patches/playback/speed/CustomVideoSpeedPatch;" "Lapp/revanced/integrations/patches/playback/speed/CustomPlaybackSpeedPatch;"
} }
} }

View File

@@ -19,13 +19,13 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
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.video.information.patch.VideoInformationPatch import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch
import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch import app.revanced.patches.youtube.video.speed.custom.patch.CustomPlaybackSpeedPatch
import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Name("Remember playback speed") @Name("Remember playback speed")
@Description("Adds the ability to remember the playback speed you chose in the video playback speed flyout.") @Description("Adds the ability to remember the playback speed you chose in the playback speed flyout.")
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomVideoSpeedPatch::class]) @DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomPlaybackSpeedPatch::class])
@Version("0.0.1") @Version("0.0.1")
class RememberPlaybackSpeedPatch : BytecodePatch( class RememberPlaybackSpeedPatch : BytecodePatch(
listOf( listOf(