generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Enable slide to seek
patch
Implementation references taken from github.com/inotia00/revanced-patches/commit/0ede1987544aa0068f28665c6c029df23a30afe2
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/EnableSlideToSeekPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package app.revanced.patches.youtube.interaction.seekbar | ||
|
||
import app.revanced.extensions.exception | ||
import app.revanced.patcher.data.BytecodeContext | ||
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.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.shared.settings.preference.impl.StringResource | ||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference | ||
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.DoubleSpeedSeekNoticeFingerprint | ||
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SlideToSeekFingerprint | ||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch | ||
import app.revanced.patches.youtube.misc.settings.SettingsPatch | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch( | ||
name = "Enable slide to seek", | ||
description = "Enable slide to seek instead of playing at 2x speed.", | ||
dependencies = [IntegrationsPatch::class, SettingsPatch::class], | ||
compatiblePackages = [ | ||
CompatiblePackage( | ||
"com.google.android.youtube", | ||
[ | ||
"18.43.45", | ||
] | ||
) | ||
] | ||
) | ||
@Suppress("unused") | ||
object EnableSlideToSeekPatch : BytecodePatch( | ||
setOf( | ||
SlideToSeekFingerprint, | ||
DoubleSpeedSeekNoticeFingerprint | ||
) | ||
) { | ||
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/SlideToSeekPatch;" | ||
|
||
override fun execute(context: BytecodeContext) { | ||
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences( | ||
SwitchPreference( | ||
"revanced_slide_to_seek", | ||
StringResource( | ||
"revanced_slide_to_seek_title", | ||
"Enable slide to seek" | ||
), | ||
StringResource( | ||
"revanced_slide_to_seek_summary_on", | ||
"Slide to seek is enabled" | ||
), | ||
StringResource( | ||
"revanced_slide_to_seek_summary_off", | ||
"Slide to seek is not enabled" | ||
), | ||
) | ||
) | ||
|
||
arrayOf( | ||
// Restore the behaviour to slide to seek. | ||
SlideToSeekFingerprint, | ||
// Disable the double speed seek notice. | ||
DoubleSpeedSeekNoticeFingerprint | ||
).map { | ||
it.result ?: throw it.exception | ||
}.forEach { | ||
val insertIndex = it.scanResult.patternScanResult!!.endIndex + 1 | ||
|
||
it.mutableMethod.apply { | ||
val isEnabledRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA | ||
|
||
addInstructions( | ||
insertIndex, | ||
""" | ||
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->isSlideToSeekDisabled()Z | ||
move-result v$isEnabledRegister | ||
""" | ||
) | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...nced/patches/youtube/interaction/seekbar/fingerprints/DoubleSpeedSeekNoticeFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package app.revanced.patches.youtube.interaction.seekbar.fingerprints | ||
|
||
import app.revanced.util.patch.LiteralValueFingerprint | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
object DoubleSpeedSeekNoticeFingerprint : LiteralValueFingerprint( | ||
returnType = "Z", | ||
parameters = emptyList(), | ||
opcodes = listOf(Opcode.MOVE_RESULT), | ||
literalSupplier = { 45411330 } | ||
) |
11 changes: 11 additions & 0 deletions
11
...n/app/revanced/patches/youtube/interaction/seekbar/fingerprints/SlideToSeekFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package app.revanced.patches.youtube.interaction.seekbar.fingerprints | ||
|
||
import app.revanced.util.patch.LiteralValueFingerprint | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
object SlideToSeekFingerprint : LiteralValueFingerprint( | ||
returnType = "Z", | ||
parameters = emptyList(), | ||
opcodes = listOf(Opcode.MOVE_RESULT), | ||
literalSupplier = { 45411329 } | ||
) |