From 998a249a23d09eb752b35c4da731f4223be40a3b Mon Sep 17 00:00:00 2001 From: d4rkk3y <43563783+d4rkk3y@users.noreply.github.com> Date: Wed, 28 Sep 2022 03:00:24 +0700 Subject: [PATCH] fix(sponsorblock): dynamically insert `setSponsorBarRect` call (#644) --- .../bytecode/patch/SponsorBlockBytecodePatch.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index ec7972c1c..3e7580ada 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -99,10 +99,14 @@ class SponsorBlockBytecodePatch : BytecodePatch( /* Get the instance of the seekbar rectangle */ - seekbarMethod.addInstruction( - 1, - "invoke-static {v0}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarRect(Ljava/lang/Object;)V" - ) + for ((index, instruction) in seekbarMethodInstructions.withIndex()) { + if (instruction.opcode != Opcode.MOVE_OBJECT_FROM16) continue + seekbarMethod.addInstruction( + index + 1, + "invoke-static {v0}, Lapp/revanced/integrations/sponsorblock/PlayerController;->setSponsorBarRect(Ljava/lang/Object;)V" + ) + break + } for ((index, instruction) in seekbarMethodInstructions.withIndex()) { if (instruction.opcode != Opcode.INVOKE_STATIC) continue