From f99406eac42c935aa1f135b33357c840401a8574 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 29 Jul 2022 03:20:55 +0200 Subject: [PATCH] refactor: do not account for order in `VideoIdPatch.injectCall` (#246) --- .../patches/youtube/misc/videoid/patch/VideoIdPatch.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt index 9eaa6eba..b62420fd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videoid/patch/VideoIdPatch.kt @@ -39,10 +39,11 @@ class VideoIdPatch : BytecodePatch( } companion object { - private lateinit var result: MethodFingerprintResult + private const val offset = 3 // offset so setCurrentVideoId is called before any injected call + private var videoIdRegister: Int = 0 + private lateinit var result: MethodFingerprintResult private lateinit var insertMethod: MutableMethod - private var offset = 2 /** * Adds an invoke-static instruction, called with the new id when the video changes @@ -52,10 +53,9 @@ class VideoIdPatch : BytecodePatch( methodDescriptor: String ) { insertMethod.addInstructions( - result.patternScanResult!!.endIndex + offset, // after the move-result-object + result.patternScanResult!!.endIndex + offset, // move-result-object offset "invoke-static {v$videoIdRegister}, $methodDescriptor" ) - offset++ // so additional instructions get added later } } }