From 86e0728e152362a606f6cbf9257a463979df0268 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 4 May 2022 23:50:45 +0200 Subject: [PATCH] add: resource patcher Signed-off-by: oSumAtrIX --- src/main/kotlin/app/revanced/patches/Index.kt | 15 +++--- .../patches/music/audio/CodecsUnlockPatch.kt | 16 ++++--- .../music/audio/EnableAudioOnlyPatch.kt | 13 ++++-- .../music/layout/RemoveTasteBuilderPatch.kt | 12 +++-- .../music/layout/RemoveUpgradeTabPatch.kt | 12 +++-- .../music/premium/BackgroundPlayPatch.kt | 12 +++-- .../patches/youtube/ad/HomeAdsPatch.kt | 12 +++-- .../patches/youtube/ad/HomePromoPatch.kt | 17 ++++--- .../patches/youtube/ad/VideoAdsPatch.kt | 16 ++++--- .../interaction/EnableSeekbarTappingPatch.kt | 13 ++++-- .../layout/CreateButtonRemoverPatch.kt | 13 ++++-- .../patches/youtube/layout/HideReelsPatch.kt | 12 +++-- .../youtube/layout/MinimizedPlaybackPatch.kt | 12 +++-- .../youtube/layout/OldQualityLayoutPatch.kt | 13 ++++-- .../layout/ShortsButtonRemoverPatch.kt | 12 +++-- .../youtube/misc/FixLocaleConfigErrorPatch.kt | 46 +++++++++++++++++++ .../patches/youtube/misc/IntegrationsPatch.kt | 12 +++-- 17 files changed, 186 insertions(+), 72 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/FixLocaleConfigErrorPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/Index.kt b/src/main/kotlin/app/revanced/patches/Index.kt index f55a8b01..4c4e843d 100644 --- a/src/main/kotlin/app/revanced/patches/Index.kt +++ b/src/main/kotlin/app/revanced/patches/Index.kt @@ -1,16 +1,18 @@ package app.revanced.patches -import app.revanced.patcher.patch.Patch -import app.revanced.patches.music.audio.EnableAudioOnlyPatch -import app.revanced.patches.music.layout.RemoveUpgradeTabPatch -import app.revanced.patches.music.layout.RemoveTasteBuilderPatch -import app.revanced.patches.music.premium.BackgroundPlayPatch +import app.revanced.patcher.data.base.Data +import app.revanced.patcher.patch.base.Patch import app.revanced.patches.music.audio.CodecsUnlockPatch +import app.revanced.patches.music.audio.EnableAudioOnlyPatch +import app.revanced.patches.music.layout.RemoveTasteBuilderPatch +import app.revanced.patches.music.layout.RemoveUpgradeTabPatch +import app.revanced.patches.music.premium.BackgroundPlayPatch import app.revanced.patches.youtube.ad.HomeAdsPatch import app.revanced.patches.youtube.ad.HomePromoPatch import app.revanced.patches.youtube.ad.VideoAdsPatch import app.revanced.patches.youtube.interaction.EnableSeekbarTappingPatch import app.revanced.patches.youtube.layout.* +import app.revanced.patches.youtube.misc.FixLocaleConfigErrorPatch import app.revanced.patches.youtube.misc.IntegrationsPatch /** @@ -22,8 +24,9 @@ object Index { * Array of patches. * New patches should be added to the array. */ - val patches: List<() -> Patch> = listOf( + val patches: List<() -> Patch> = listOf( ::IntegrationsPatch, + ::FixLocaleConfigErrorPatch, ::HomeAdsPatch, ::VideoAdsPatch, ::HomePromoPatch, diff --git a/src/main/kotlin/app/revanced/patches/music/audio/CodecsUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/CodecsUnlockPatch.kt index df24b4de..03c2264f 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/CodecsUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/CodecsUnlockPatch.kt @@ -1,14 +1,18 @@ package app.revanced.patches.music.audio -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.implementation.toMethodWalker import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod import app.revanced.patcher.smali.toInstruction -import app.revanced.patcher.toMethodWalker import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode @@ -27,7 +31,7 @@ private val patchMetadata = PatchMetadata( "0.0.1" ) -class CodecsUnlockPatch : Patch( +class CodecsUnlockPatch : BytecodePatch( patchMetadata, listOf( MethodSignature( @@ -130,7 +134,7 @@ class CodecsUnlockPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { var result = signatures.first().result!! val implementation = result.method.implementation!! @@ -138,7 +142,7 @@ class CodecsUnlockPatch : Patch( val instructionIndex = result.scanData.startIndex result = signatures.last().result!! - val codecMethod = patcherData + val codecMethod = data .toMethodWalker(result.immutableMethod) .walk(result.scanData.startIndex) .getMethod() diff --git a/src/main/kotlin/app/revanced/patches/music/audio/EnableAudioOnlyPatch.kt b/src/main/kotlin/app/revanced/patches/music/audio/EnableAudioOnlyPatch.kt index 2227de92..e1186acb 100644 --- a/src/main/kotlin/app/revanced/patches/music/audio/EnableAudioOnlyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/audio/EnableAudioOnlyPatch.kt @@ -1,8 +1,13 @@ package app.revanced.patches.music.audio -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -18,7 +23,7 @@ private val compatiblePackages = listOf( ) ) -class EnableAudioOnlyPatch : Patch( +class EnableAudioOnlyPatch : BytecodePatch( PatchMetadata( "audio-only-playback-patch", "Audio Only Mode Patch", @@ -78,7 +83,7 @@ class EnableAudioOnlyPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!!.findParentMethod( MethodSignature( MethodSignatureMetadata( diff --git a/src/main/kotlin/app/revanced/patches/music/layout/RemoveTasteBuilderPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/RemoveTasteBuilderPatch.kt index de03987e..904c16e5 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/RemoveTasteBuilderPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/RemoveTasteBuilderPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.music.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -20,7 +24,7 @@ private val compatiblePackages = listOf( ) ) -class RemoveTasteBuilderPatch : Patch( +class RemoveTasteBuilderPatch : BytecodePatch( PatchMetadata( "tasteBuilder-remover", "Remove TasteBuilder Patch", @@ -66,7 +70,7 @@ class RemoveTasteBuilderPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! val implementation = result.method.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/music/layout/RemoveUpgradeTabPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/RemoveUpgradeTabPatch.kt index 18afabb9..b55c2800 100644 --- a/src/main/kotlin/app/revanced/patches/music/layout/RemoveUpgradeTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/layout/RemoveUpgradeTabPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.music.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -22,7 +26,7 @@ private val compatiblePackages = listOf( ) ) -class RemoveUpgradeTabPatch : Patch( +class RemoveUpgradeTabPatch : BytecodePatch( PatchMetadata( "upgrade-tab-remover", "Remove Upgrade Tab Patch", @@ -93,7 +97,7 @@ class RemoveUpgradeTabPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! val implementation = result.method.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/music/premium/BackgroundPlayPatch.kt b/src/main/kotlin/app/revanced/patches/music/premium/BackgroundPlayPatch.kt index a6698e12..f84aec6f 100644 --- a/src/main/kotlin/app/revanced/patches/music/premium/BackgroundPlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/premium/BackgroundPlayPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.music.premium -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -19,7 +23,7 @@ private val compatiblePackages = listOf( ) ) -class BackgroundPlayPatch : Patch( +class BackgroundPlayPatch : BytecodePatch( PatchMetadata( "background-play", "Enable Background Playback Patch", @@ -74,7 +78,7 @@ class BackgroundPlayPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { signatures.first().result!!.method.implementation!!.addInstructions( 0, """ diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/HomeAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/HomeAdsPatch.kt index 96b8e155..fda073ee 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/HomeAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/HomeAdsPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.youtube.ad import app.revanced.extensions.injectHideCall -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -30,7 +34,7 @@ private val patchMetadata = PatchMetadata( private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38." -class HomeAdsPatch : Patch( +class HomeAdsPatch : BytecodePatch( patchMetadata, listOf( MethodSignature( @@ -1685,7 +1689,7 @@ class HomeAdsPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { for (i in 0 until signatures.count()) { val signature = signatures.elementAt(i) val result = signature.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/HomePromoPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/HomePromoPatch.kt index 5c623a30..60cf6105 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/HomePromoPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/HomePromoPatch.kt @@ -1,15 +1,20 @@ package app.revanced.patches.youtube.ad import app.revanced.extensions.injectHideCall -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData +import app.revanced.patcher.data.implementation.toMethodWalker import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.proxy.mutableTypes.MutableMethod import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.PatternScanMethod -import app.revanced.patcher.toMethodWalker import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.Opcode import org.jf.dexlib2.iface.instruction.formats.Instruction11x @@ -31,7 +36,7 @@ private val patchMetadata = PatchMetadata( private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38." -class HomePromoPatch : Patch( +class HomePromoPatch : BytecodePatch( patchMetadata, listOf( MethodSignature( @@ -137,7 +142,7 @@ class HomePromoPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { for (signature in signatures) { val result = signature.result!! @@ -162,7 +167,7 @@ class HomePromoPatch : Patch( val toBePatchedInvokeOffset = requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT } - val toBePatchedMethod = patcherData + val toBePatchedMethod = data .toMethodWalker(requiredMethod.immutableMethod) .walk(toBePatchedInvokeOffset, true) .getMethod() as MutableMethod diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/VideoAdsPatch.kt index 25141995..4498d335 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/VideoAdsPatch.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.ad -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -27,7 +32,7 @@ private val patchMetadata = PatchMetadata( "0.0.1" ) -class VideoAdsPatch : Patch( +class VideoAdsPatch : BytecodePatch( patchMetadata, listOf( MethodSignature( @@ -66,7 +71,7 @@ class VideoAdsPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { var result = signatures.first().result!! val responsibleMethodSignature = MethodSignature( @@ -104,5 +109,4 @@ class VideoAdsPatch : Patch( return PatchResultSuccess() } -} - +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/EnableSeekbarTappingPatch.kt index 50a238b9..3f49f830 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/EnableSeekbarTappingPatch.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.interaction -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -23,7 +28,7 @@ private val compatiblePackages = listOf( ) ) -class EnableSeekbarTappingPatch : Patch( +class EnableSeekbarTappingPatch : BytecodePatch( PatchMetadata( "seekbar-tapping", "Enable seekbar tapping patch", @@ -124,7 +129,7 @@ class EnableSeekbarTappingPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { var result = signatures.first().result!! val tapSeekMethods = mutableMapOf() diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/CreateButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/CreateButtonRemoverPatch.kt index 2302ed7e..4bcde789 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/CreateButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/CreateButtonRemoverPatch.kt @@ -1,8 +1,13 @@ package app.revanced.patches.youtube.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -19,7 +24,7 @@ private val compatiblePackages = listOf( ) ) -class CreateButtonRemoverPatch : Patch( +class CreateButtonRemoverPatch : BytecodePatch( PatchMetadata( "create-button", "Create button patch", @@ -76,7 +81,7 @@ class CreateButtonRemoverPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! // Get the required register which holds the view object we need to pass to the method hideCreateButton diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/HideReelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/HideReelsPatch.kt index f846da1f..59fc80e6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/HideReelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/HideReelsPatch.kt @@ -1,8 +1,12 @@ package app.revanced.patches.youtube.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -18,7 +22,7 @@ private val compatiblePackages = listOf( ) ) -class HideReelsPatch : Patch( +class HideReelsPatch : BytecodePatch( PatchMetadata( "hide-reels", "Hide reels patch", @@ -96,7 +100,7 @@ class HideReelsPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! val implementation = result.method.implementation!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/MinimizedPlaybackPatch.kt index 42c36585..2383fcfd 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/MinimizedPlaybackPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.youtube.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -19,7 +23,7 @@ private val compatiblePackages = listOf( ) ) -class MinimizedPlaybackPatch : Patch( +class MinimizedPlaybackPatch : BytecodePatch( PatchMetadata( "minimized-playback", "Minimized Playback Patch", @@ -70,7 +74,7 @@ class MinimizedPlaybackPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { // Instead of removing all instructions like Vanced, // we return the method at the beginning instead signatures.first().result!!.method.implementation!!.addInstructions( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/OldQualityLayoutPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/OldQualityLayoutPatch.kt index 00dcdd3f..65eb3744 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/OldQualityLayoutPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/OldQualityLayoutPatch.kt @@ -1,9 +1,14 @@ package app.revanced.patches.youtube.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +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.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -20,7 +25,7 @@ private val compatiblePackages = listOf( ) ) -class OldQualityLayoutPatch : Patch( +class OldQualityLayoutPatch : BytecodePatch( PatchMetadata( "old-quality-layout", "Old Quality Layout Patch", @@ -70,7 +75,7 @@ class OldQualityLayoutPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { var result = signatures.first().result!! result = result.findParentMethod( diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/ShortsButtonRemoverPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/ShortsButtonRemoverPatch.kt index 3402c2a4..0b0102c6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/ShortsButtonRemoverPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/ShortsButtonRemoverPatch.kt @@ -1,8 +1,12 @@ package app.revanced.patches.youtube.layout -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignatureMetadata @@ -19,7 +23,7 @@ private val compatiblePackages = listOf( ) ) -class ShortsButtonRemoverPatch : Patch( +class ShortsButtonRemoverPatch : BytecodePatch( PatchMetadata( "shorts-button", "Shorts button patch", @@ -102,7 +106,7 @@ class ShortsButtonRemoverPatch : Patch( ), ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result1 = signatures.first().result!! val implementation1 = result1.method.implementation!! val moveEnumInstruction = implementation1.instructions[result1.scanData.endIndex] diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/FixLocaleConfigErrorPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/FixLocaleConfigErrorPatch.kt new file mode 100644 index 00000000..77058dbe --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/FixLocaleConfigErrorPatch.kt @@ -0,0 +1,46 @@ +package app.revanced.patches.youtube.misc + +import app.revanced.patcher.data.implementation.ResourceData +import app.revanced.patcher.patch.implementation.ResourcePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess +import com.sun.org.apache.xerces.internal.dom.ElementImpl + +private val compatiblePackages = listOf( + PackageMetadata( + "com.google.android.youtube", + listOf("17.14.35") + ) +) +class FixLocaleConfigErrorPatch : ResourcePatch( + PatchMetadata( + "locale-config-fix", + "Manifest attribute fix patch", + "Fix an error when building the resources by patching the manifest file.", + compatiblePackages, + "0.0.1" + ), +) { + override fun execute(data: ResourceData): PatchResult { + // create an xml editor instance + val editor = data.getXmlEditor("AndroidManifest.xml") + + // edit the application nodes attribute... + val applicationNode = editor + .file + .getElementsByTagName("application") + .item(0) as ElementImpl + + // by replacing the attributes name + val attribute = "android:localeConfig" + applicationNode.setAttribute("localeConfig", applicationNode.getAttribute(attribute)) + applicationNode.removeAttribute("android:localeConfig") + + // close & save the modified file + editor.close() + + return PatchResultSuccess() + } +} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/IntegrationsPatch.kt index 931838ff..7683f18f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/IntegrationsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/IntegrationsPatch.kt @@ -1,9 +1,13 @@ package app.revanced.patches.youtube.misc -import app.revanced.patcher.PatcherData +import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.or -import app.revanced.patcher.patch.* +import app.revanced.patcher.patch.implementation.BytecodePatch +import app.revanced.patcher.patch.implementation.metadata.PackageMetadata +import app.revanced.patcher.patch.implementation.metadata.PatchMetadata +import app.revanced.patcher.patch.implementation.misc.PatchResult +import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodSignature @@ -22,7 +26,7 @@ private val compatiblePackages = listOf( ) ) -class IntegrationsPatch : Patch( +class IntegrationsPatch : BytecodePatch( PatchMetadata( "integrations", "Inject Integrations Patch", @@ -80,7 +84,7 @@ class IntegrationsPatch : Patch( ) ) ) { - override fun execute(patcherData: PatcherData): PatchResult { + override fun execute(data: BytecodeData): PatchResult { val result = signatures.first().result!! val implementation = result.method.implementation!!