diff --git a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt index c5694edc..6c112fad 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt @@ -67,4 +67,4 @@ class ExclusiveAudioPatch : BytecodePatch( return PatchResultSuccess() } -} \ No newline at end of file +} diff --git a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt index 5995370c..c5cd8f94 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/tastebuilder/patch/RemoveTasteBuilderPatch.kt @@ -9,7 +9,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.music.layout.tastebuilder.annotations.RemoveTasteBuilderCompatibility import app.revanced.patches.music.layout.tastebuilder.signatures.TasteBuilderConstructorSignature import org.jf.dexlib2.iface.instruction.formats.Instruction22c diff --git a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt index a30492c7..6e9445d6 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/backgroundplay/patch/BackgroundPlayPatch.kt @@ -9,7 +9,6 @@ import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.music.premium.backgroundplay.annotations.BackgroundPlayCompatibility import app.revanced.patches.music.premium.backgroundplay.signatures.BackgroundPlaybackDisableSignature @@ -24,12 +23,12 @@ class BackgroundPlayPatch : BytecodePatch( ) ) { override fun execute(data: BytecodeData): PatchResult { - BackgroundPlaybackDisableSignature.result!!.method.implementation!!.addInstructions( + BackgroundPlaybackDisableSignature.result!!.method.addInstructions( 0, """ const/4 v0, 0x1 return v0 - """.trimIndent().toInstructions() + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt index 2ec0a66a..7b7f6df6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/general/bytecode/patch/GeneralBytecodeAdsPatch.kt @@ -148,11 +148,11 @@ class GeneralBytecodeAdsPatch : BytecodePatch( mutableClass!!.findMutableMethodOf(method) // TODO: dynamically get registers - mutableMethod!!.implementation!!.addInstructions( + mutableMethod!!.addInstructions( insertIndex, """ const/16 v1, 0x8 invoke-virtual {v0,v1}, Landroid/widget/FrameLayout;->setVisibility(I)V - """.trimIndent().toInstructions() + """ ) } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt index 1d7d5354..598d2ae4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/video/patch/VideoAdsPatch.kt @@ -15,7 +15,6 @@ import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.annotation.DirectPatternScanMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility import app.revanced.patches.youtube.ad.video.signatures.ShowVideoAdsConstructorSignature import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -41,11 +40,11 @@ class VideoAdsPatch : BytecodePatch( ) {}) ?: return PatchResultError("Required parent method could not be found.") // Override the parameter by calling shouldShowAds and setting the parameter to the result - result.method.implementation!!.addInstructions( + result.method.addInstructions( 0, """ invoke-static { }, Lfi/vanced/libraries/youtube/whitelisting/Whitelist;->shouldShowAds()Z move-result v1 - """.trimIndent().toInstructions() + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt index bd7ed75b..36f76e1b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultError import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingParentSignature import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingSignature @@ -73,11 +72,11 @@ class EnableSeekbarTappingPatch : BytecodePatch( val register = (instruction as Instruction35c).registerC // the instructions are written in reverse order. - implementation.addInstructions( + result.method.addInstructions( result.scanResult.endIndex + 1, """ invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V - """.trimIndent().toInstructions() + """ ) // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label @@ -85,11 +84,11 @@ class EnableSeekbarTappingPatch : BytecodePatch( implementation.addInstruction( result.scanResult.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) ) - implementation.addInstructions( + result.method.addInstructions( result.scanResult.endIndex + 1, """ invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z move-result v0 - """.trimIndent().toInstructions() + """ ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt index 8b1744d7..b32022b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/createbutton/patch/CreateButtonRemoverPatch.kt @@ -4,13 +4,13 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.annotations.Dependencies import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultError import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -38,9 +38,9 @@ class CreateButtonRemoverPatch : BytecodePatch( val register = (instruction as Instruction35c).registerC // Hide the button view via proxy by passing it to the hideCreateButton method - implementation.addInstruction( + result.method.addInstruction( result.scanResult.endIndex + 1, - "invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction() + "invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V" ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt index 8378b839..1569e301 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -3,13 +3,12 @@ package app.revanced.patches.youtube.layout.minimizedplayback.patch import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility import app.revanced.patches.youtube.layout.minimizedplayback.signatures.MinimizedPlaybackManagerSignature @@ -27,11 +26,11 @@ class MinimizedPlaybackPatch : BytecodePatch( override fun execute(data: BytecodeData): PatchResult { // Instead of removing all instructions like Vanced, // we return the method at the beginning instead - MinimizedPlaybackManagerSignature.result!!.method.implementation!!.addInstructions( + MinimizedPlaybackManagerSignature.result!!.method.addInstructions( 0, """ const/4 v0, 0x1 return v0 - """.trimIndent().toInstructions() + """ ) return PatchResultSuccess() } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt index 5094a8cb..b77797a1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/oldqualitylayout/patch/OldQualityLayoutPatch.kt @@ -15,7 +15,6 @@ import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod -import app.revanced.patcher.util.smali.toInstructions import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility import app.revanced.patches.youtube.layout.oldqualitylayout.signatures.OldQualityParentSignature import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch @@ -57,11 +56,11 @@ class OldQualityLayoutPatch : BytecodePatch( Opcode.IF_NEZ, 0, implementation.instructions[result.scanResult.endIndex].location.labels.first() ) implementation.addInstruction(5, jmpInstruction) - implementation.addInstructions( + result.method.addInstructions( 0, """ invoke-static { }, Lfi/razerman/youtube/XGlobals;->useOldStyleQualitySettings()Z move-result v0 - """.trimIndent().toInstructions() + """ ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt index d516e584..6017d50d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/reels/patch/HideReelsPatch.kt @@ -4,10 +4,10 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature @@ -23,13 +23,12 @@ class HideReelsPatch : BytecodePatch( ) { override fun execute(data: BytecodeData): PatchResult { val result = HideReelsSignature.result!! - val implementation = result.method.implementation!! // HideReel will hide the reel view before it is being used, // so we pass the view to the HideReel method - implementation.addInstruction( + result.method.addInstruction( result.scanResult.endIndex, - "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction() + "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V" ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt index 1bb3c9b9..1191caa9 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/shorts/button/patch/ShortsButtonRemoverPatch.kt @@ -4,12 +4,12 @@ import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.extensions.addInstruction import app.revanced.patcher.patch.annotations.Dependencies import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess -import app.revanced.patcher.util.smali.toInstruction import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonTabenumSignature import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonsViewSignature @@ -39,16 +39,16 @@ class ShortsButtonRemoverPatch : BytecodePatch( val viewRegister = (moveViewInstruction as Instruction11x).registerA // Save the tab enum in XGlobals to avoid smali/register workarounds - implementation1.addInstruction( + result1.method.addInstruction( result1.scanResult.endIndex + 1, - "sput-object v$enumRegister, Lfi/razerman/youtube/XGlobals;->lastPivotTab:Ljava/lang/Enum;".toInstruction() + "sput-object v$enumRegister, Lfi/razerman/youtube/XGlobals;->lastPivotTab:Ljava/lang/Enum;" ) // Hide the button view via proxy by passing it to the hideShortsButton method // It only hides it if the last tab name is "TAB_SHORTS" - implementation2.addInstruction( + result2.method.addInstruction( result2.scanResult.endIndex + 2, - "invoke-static { v$viewRegister }, Lfi/razerman/youtube/XAdRemover;->hideShortsButton(Landroid/view/View;)V".toInstruction() + "invoke-static { v$viewRegister }, Lfi/razerman/youtube/XAdRemover;->hideShortsButton(Landroid/view/View;)V" ) return PatchResultSuccess() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt index 05205e24..319c0e6c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/integrations/patch/IntegrationsPatch.kt @@ -36,11 +36,11 @@ class IntegrationsPatch : BytecodePatch( val implementation = result.method.implementation!! val count = implementation.registerCount - 1 - implementation.addInstructions( + result.method.addInstructions( result.scanResult.endIndex + 1, """ invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context; - """.trimIndent().toInstructions() + """ ) val classDef = result.definingClassProxy.resolve() diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt index ef12652e..c5d5c79d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/microg/patch/bytecode/MicroGBytecodePatch.kt @@ -147,8 +147,8 @@ class MicroGBytecodePatch : BytecodePatch( else -> throw Exception("This case should never happen.") } - result.method.implementation!!.addInstructions( - 0, stringInstructions.trimIndent().toInstructions() + result.method.addInstructions( + 0, stringInstructions ) }