From 19798bf31cc7f85b5927a4c56c236371d068c231 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Thu, 18 May 2023 02:58:27 +0200 Subject: [PATCH] refactor(youtube/remember-playback-speed): do not use other unrelated patches extension methods --- .../video/information/patch/VideoInformationPatch.kt | 6 ++---- .../speed/remember/patch/RememberPlaybackSpeedPatch.kt | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt index e73f0d246..1df612641 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt @@ -28,7 +28,6 @@ import org.jf.dexlib2.Opcode import org.jf.dexlib2.builder.BuilderInstruction import org.jf.dexlib2.builder.MutableMethodImplementation import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction -import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.immutable.ImmutableMethod @@ -218,9 +217,8 @@ class VideoInformationPatch : BytecodePatch( ) private fun getReference(instructions: List, offset: Int, opcode: Opcode) = - instructions[instructions.indexOfFirst { it.opcode == opcode } + offset].reference - - val Instruction.reference get() = (this as ReferenceInstruction).reference.toString() + (instructions[instructions.indexOfFirst { it.opcode == opcode } + offset] as ReferenceInstruction) + .reference.toString() private lateinit var speedSelectionInsertMethod: MutableMethod private var speedSelectionInsertIndex = 0 diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt index 96e678dea..625d773df 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt @@ -19,9 +19,9 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch 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.Companion.reference import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint +import org.jf.dexlib2.iface.instruction.ReferenceInstruction @Name("remember-playback-speed") @Description("Adds the ability to remember the playback speed you chose in the video playback speed flyout.") @@ -78,7 +78,8 @@ class RememberPlaybackSpeedPatch : BytecodePatch( */ InitializePlaybackSpeedValuesFingerprint.result?.apply { // Infer everything necessary for calling the method setPlaybackSpeed(). - val onItemClickListenerClassFieldReference = mutableMethod.instruction(0).reference + val onItemClickListenerClassFieldReference = + mutableMethod.instruction(0).reference // Registers are not used at index 0, so they can be freely used. mutableMethod.addInstructions(