From db3d1c5740beefab590f201a5c7550950a78b157 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 1 Sep 2024 03:10:53 +0900 Subject: [PATCH] chore: lint code --- .../general/downloads/DownloadActionsPatch.kt | 9 ++++-- .../streamingdata/SpoofStreamingDataPatch.kt | 30 ++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/downloads/DownloadActionsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/downloads/DownloadActionsPatch.kt index 7cd5f3dbe..f1fe0d3f1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/downloads/DownloadActionsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/downloads/DownloadActionsPatch.kt @@ -125,7 +125,8 @@ object DownloadActionsPatch : BaseBytecodePatch( reference?.definingClass == OFFLINE_PLAYLIST_ENDPOINT_OUTER_CLASS_DESCRIPTOR && reference.type == "Ljava/lang/String;" } - val playlistIdReference = getInstruction(playlistIdIndex).reference + val playlistIdReference = + getInstruction(playlistIdIndex).reference val targetIndex = indexOfFirstInstructionOrThrow { opcode == Opcode.CHECK_CAST && @@ -134,13 +135,15 @@ object DownloadActionsPatch : BaseBytecodePatch( val targetRegister = getInstruction(targetIndex).registerA addInstructionsWithLabels( - targetIndex + 1, """ + targetIndex + 1, + """ iget-object v$freeRegister, v$targetRegister, $playlistIdReference invoke-static {v$freeRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->inAppPlaylistDownloadMenuOnClick(Ljava/lang/String;)Z move-result v$freeRegister if-eqz v$freeRegister, :show_native_downloader return-void - """, ExternalLabel("show_native_downloader", getInstruction(targetIndex + 1)) + """, + ExternalLabel("show_native_downloader", getInstruction(targetIndex + 1)) ) } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt index eec41d67e..c16b3d7a1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt @@ -61,7 +61,8 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( BuildInitPlaybackRequestFingerprint.resultOrThrow().let { it.mutableMethod.apply { val moveUriStringIndex = it.scanResult.patternScanResult!!.startIndex - val targetRegister = getInstruction(moveUriStringIndex).registerA + val targetRegister = + getInstruction(moveUriStringIndex).registerA addInstructions( moveUriStringIndex + 1, @@ -79,8 +80,10 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( BuildPlayerRequestURIFingerprint.resultOrThrow().let { it.mutableMethod.apply { - val invokeToStringIndex = BuildPlayerRequestURIFingerprint.indexOfToStringInstruction(this) - val uriRegister = getInstruction(invokeToStringIndex).registerC + val invokeToStringIndex = + BuildPlayerRequestURIFingerprint.indexOfToStringInstruction(this) + val uriRegister = + getInstruction(invokeToStringIndex).registerC addInstructions( invokeToStringIndex, @@ -100,11 +103,13 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( result.mutableMethod.apply { val buildRequestIndex = BuildRequestFingerprint.indexOfBuildUrlRequestInstruction(this) - val requestBuilderRegister = getInstruction(buildRequestIndex).registerC + val requestBuilderRegister = + getInstruction(buildRequestIndex).registerC val newRequestBuilderIndex = BuildRequestFingerprint.indexOfNewUrlRequestBuilderInstruction(this) - val urlRegister = getInstruction(newRequestBuilderIndex).registerD + val urlRegister = + getInstruction(newRequestBuilderIndex).registerD // Replace "requestBuilder.build()" with integrations call. replaceInstruction( @@ -143,10 +148,13 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( CreateStreamingDataFingerprint.resultOrThrow().let { result -> result.mutableMethod.apply { val setStreamingDataIndex = result.scanResult.patternScanResult!!.startIndex - val setStreamingDataField = getInstruction(setStreamingDataIndex).getReference().toString() + val setStreamingDataField = + getInstruction(setStreamingDataIndex).getReference().toString() - val playerProtoClass = getInstruction(setStreamingDataIndex + 1).getReference()!!.definingClass - val protobufClass = ProtobufClassParseByteBufferFingerprint.resultOrThrow().mutableMethod.definingClass + val playerProtoClass = + getInstruction(setStreamingDataIndex + 1).getReference()!!.definingClass + val protobufClass = + ProtobufClassParseByteBufferFingerprint.resultOrThrow().mutableMethod.definingClass val getStreamingDataField = getInstructions().find { instruction -> instruction.opcode == Opcode.IGET_OBJECT && @@ -155,10 +163,12 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( ?: throw PatchException("Could not find getStreamingDataField") val videoDetailsIndex = result.scanResult.patternScanResult!!.endIndex - val videoDetailsClass = getInstruction(videoDetailsIndex).getReference()!!.type + val videoDetailsClass = + getInstruction(videoDetailsIndex).getReference()!!.type val insertIndex = videoDetailsIndex + 1 - val videoDetailsRegister = getInstruction(videoDetailsIndex).registerA + val videoDetailsRegister = + getInstruction(videoDetailsIndex).registerA val overrideRegister = getInstruction(insertIndex).registerA val freeRegister = implementation!!.registerCount - parameters.size - 2