diff --git a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt index e206022dd..57a8bd617 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/branding/icon/CustomBrandingIconPatch.kt @@ -198,7 +198,11 @@ object CustomBrandingIconPatch : BaseResourcePatch( if (oldSplashIconNotExists) { splashIconResourceGroups.let { resourceGroups -> resourceGroups.forEach { - context.copyResources("$youtubeMusicIconResourcePath/splash", it, createDirectoryIfNotExist = true) + context.copyResources( + "$youtubeMusicIconResourcePath/splash", + it, + createDirectoryIfNotExist = true + ) } } } diff --git a/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt index c99fa68fa..90e3f1a80 100644 --- a/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt @@ -32,6 +32,11 @@ abstract class BaseAdsPatch( VideoAdsFingerprint ) ) { + private companion object { + const val INTEGRATIONS_CLASS_DESCRIPTOR = + "$PATCHES_PATH/FullscreenAdsPatch;" + } + override fun execute(context: BytecodeContext) { MusicAdsFingerprint.resultOrThrow().let { it.mutableMethod.apply { @@ -119,9 +124,4 @@ abstract class BaseAdsPatch( ) } } - - private companion object { - const val INTEGRATIONS_CLASS_DESCRIPTOR = - "$PATCHES_PATH/FullscreenAdsPatch;" - } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt index c3e85e688..acc992511 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/ToolBarComponentsPatch.kt @@ -180,7 +180,8 @@ object ToolBarComponentsPatch : BaseBytecodePatch( "invoke-static {v$viewRegister}, $GENERAL_CLASS_DESCRIPTOR->setWideSearchBarLayout(Landroid/view/View;)V" ) - val targetIndex = ActionBarRingoBackgroundFingerprint.indexOfStaticInstruction(this) + 1 + val targetIndex = + ActionBarRingoBackgroundFingerprint.indexOfStaticInstruction(this) + 1 val targetRegister = getInstruction(targetIndex).registerA injectSearchBarHook( diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/ActionBarRingoTextFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/ActionBarRingoTextFingerprint.kt index 7c8bbc6bf..8e0e7fdcc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/ActionBarRingoTextFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/toolbar/fingerprints/ActionBarRingoTextFingerprint.kt @@ -2,8 +2,8 @@ package app.revanced.patches.youtube.general.toolbar.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint -import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStaticInstruction import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStartDelayInstruction +import app.revanced.patches.youtube.general.toolbar.fingerprints.ActionBarRingoTextFingerprint.indexOfStaticInstruction import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import app.revanced.util.indexOfFirstInstructionReversed @@ -26,7 +26,7 @@ internal object ActionBarRingoTextFingerprint : MethodFingerprint( } fun indexOfStaticInstruction(methodDef: Method) = - methodDef.indexOfFirstInstructionReversed (indexOfStartDelayInstruction(methodDef)) { + methodDef.indexOfFirstInstructionReversed(indexOfStartDelayInstruction(methodDef)) { val reference = getReference() opcode == Opcode.INVOKE_STATIC && reference?.parameterTypes?.size == 1 && diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 8d8cddd7b..825b4496f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -45,7 +45,7 @@ object BackgroundPlaybackPatch : BaseBytecodePatch( override fun execute(context: BytecodeContext) { BackgroundPlaybackManagerFingerprint.resultOrThrow().mutableMethod.apply { - findOpcodeIndicesReversed(Opcode.RETURN).forEach{ index -> + findOpcodeIndicesReversed(Opcode.RETURN).forEach { index -> val register = getInstruction(index).registerA // Replace to preserve control flow label. @@ -54,7 +54,8 @@ object BackgroundPlaybackPatch : BaseBytecodePatch( "invoke-static { v$register }, $MISC_PATH/BackgroundPlaybackPatch;->allowBackgroundPlayback(Z)Z" ) - addInstructions(index + 1, + addInstructions( + index + 1, """ move-result v$register return v$register diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/PlayerResponseModelUtils.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/PlayerResponseModelUtils.kt index 9ca4a148f..0d1d44b01 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/PlayerResponseModelUtils.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/PlayerResponseModelUtils.kt @@ -10,8 +10,9 @@ internal object PlayerResponseModelUtils { const val PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR = "Lcom/google/android/libraries/youtube/innertube/model/player/PlayerResponseModel;" - fun indexOfPlayerResponseModelInstruction(methodDef: Method) = methodDef.indexOfFirstInstruction { - opcode == Opcode.INVOKE_INTERFACE && - getReference()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR - } + fun indexOfPlayerResponseModelInstruction(methodDef: Method) = + methodDef.indexOfFirstInstruction { + opcode == Opcode.INVOKE_INTERFACE && + getReference()?.definingClass == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR + } } 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 33e00dc9a..3f06ad052 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 @@ -222,7 +222,7 @@ object SpoofStreamingDataPatch : BaseBytecodePatch( // region Append spoof info. NerdsStatsVideoFormatBuilderFingerprint.resultOrThrow().mutableMethod.apply { - findOpcodeIndicesReversed(Opcode.RETURN_OBJECT).forEach{ index -> + findOpcodeIndicesReversed(Opcode.RETURN_OBJECT).forEach { index -> val register = getInstruction(index).registerA addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/PlayerTypeHookPatch.kt index 493a8e11b..9f208cdfe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/PlayerTypeHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/PlayerTypeHookPatch.kt @@ -18,7 +18,6 @@ import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.util.addFieldAndInstructions import app.revanced.util.getStringInstructionIndex import app.revanced.util.getTargetIndexOrThrow -import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt index 5518a511f..ddeab2fa5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/VideoInformationPatch.kt @@ -274,10 +274,13 @@ object VideoInformationPatch : BytecodePatch( /** * Set current video information */ - channelIdMethodCall = ChannelIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") - channelNameMethodCall = ChannelNameFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") + channelIdMethodCall = + ChannelIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") + channelNameMethodCall = + ChannelNameFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") videoIdMethodCall = VideoIdFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") - videoTitleMethodCall = VideoTitleFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") + videoTitleMethodCall = + VideoTitleFingerprint.getPlayerResponseInstruction("Ljava/lang/String;") videoLengthMethodCall = VideoLengthFingerprint.getPlayerResponseInstruction("J") videoIsLiveMethodCall = ChannelIdFingerprint.getPlayerResponseInstruction("Z") diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/PlaybackInitializationFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/PlaybackInitializationFingerprint.kt index 88d135365..d5bbd3cd6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/PlaybackInitializationFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/fingerprints/PlaybackInitializationFingerprint.kt @@ -20,8 +20,9 @@ internal object PlaybackInitializationFingerprint : MethodFingerprint( indexOfPlayerResponseModelInstruction(methodDef) >= 0 } ) { - fun indexOfPlayerResponseModelInstruction(methodDef: Method) = methodDef.indexOfFirstInstruction { - opcode == Opcode.INVOKE_DIRECT && - getReference()?.returnType == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR - } + fun indexOfPlayerResponseModelInstruction(methodDef: Method) = + methodDef.indexOfFirstInstruction { + opcode == Opcode.INVOKE_DIRECT && + getReference()?.returnType == PLAYER_RESPONSE_MODEL_CLASS_DESCRIPTOR + } } diff --git a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt index 5b746d12d..702df1930 100644 --- a/src/main/kotlin/app/revanced/util/BytecodeUtils.kt +++ b/src/main/kotlin/app/revanced/util/BytecodeUtils.kt @@ -291,7 +291,10 @@ fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, targetOpcode * @return -1 if the instruction is not found. * @see indexOfFirstInstructionReversedOrThrow */ -fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, predicate: Instruction.() -> Boolean): Int { +fun Method.indexOfFirstInstructionReversed( + startIndex: Int? = null, + predicate: Instruction.() -> Boolean +): Int { var instructions = this.implementation!!.instructions if (startIndex != null) { instructions = instructions.take(startIndex + 1) @@ -308,7 +311,10 @@ fun Method.indexOfFirstInstructionReversed(startIndex: Int? = null, predicate: I * @return -1 if the instruction is not found. * @see indexOfFirstInstructionReversed */ -fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, targetOpcode: Opcode): Int = +fun Method.indexOfFirstInstructionReversedOrThrow( + startIndex: Int? = null, + targetOpcode: Opcode +): Int = indexOfFirstInstructionReversedOrThrow(startIndex) { opcode == targetOpcode } @@ -321,7 +327,10 @@ fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, targe * @return -1 if the instruction is not found. * @see indexOfFirstInstructionReversed */ -fun Method.indexOfFirstInstructionReversedOrThrow(startIndex: Int? = null, predicate: Instruction.() -> Boolean): Int { +fun Method.indexOfFirstInstructionReversedOrThrow( + startIndex: Int? = null, + predicate: Instruction.() -> Boolean +): Int { val index = indexOfFirstInstructionReversed(startIndex, predicate) if (index < 0) { @@ -424,7 +433,8 @@ inline fun Instruction.getReference() = * @param predicate The predicate to match. * @return The index of the first [Instruction] that matches the predicate. */ -fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) = indexOfFirstInstruction(0, predicate) +fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) = + indexOfFirstInstruction(0, predicate) /** * Get the index of the first [Instruction] that matches the predicate, starting from [startIndex].