Skip to content

Commit

Permalink
refactor(youtube/remember-playback-speed): do not use other unrelated…
Browse files Browse the repository at this point in the history
… patches extension methods
  • Loading branch information
oSumAtrIX committed May 19, 2023
1 parent a64f33e commit 19798bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -218,9 +217,8 @@ class VideoInformationPatch : BytecodePatch(
)

private fun getReference(instructions: List<BuilderInstruction>, 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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<ReferenceInstruction>(0).reference

// Registers are not used at index 0, so they can be freely used.
mutableMethod.addInstructions(
Expand Down

0 comments on commit 19798bf

Please sign in to comment.