add: resource patcher

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
oSumAtrIX 2022-05-04 23:50:45 +02:00
parent ec9618ed55
commit 86e0728e15
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
17 changed files with 186 additions and 72 deletions

View File

@ -1,16 +1,18 @@
package app.revanced.patches package app.revanced.patches
import app.revanced.patcher.patch.Patch import app.revanced.patcher.data.base.Data
import app.revanced.patches.music.audio.EnableAudioOnlyPatch import app.revanced.patcher.patch.base.Patch
import app.revanced.patches.music.layout.RemoveUpgradeTabPatch
import app.revanced.patches.music.layout.RemoveTasteBuilderPatch
import app.revanced.patches.music.premium.BackgroundPlayPatch
import app.revanced.patches.music.audio.CodecsUnlockPatch 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.HomeAdsPatch
import app.revanced.patches.youtube.ad.HomePromoPatch import app.revanced.patches.youtube.ad.HomePromoPatch
import app.revanced.patches.youtube.ad.VideoAdsPatch import app.revanced.patches.youtube.ad.VideoAdsPatch
import app.revanced.patches.youtube.interaction.EnableSeekbarTappingPatch import app.revanced.patches.youtube.interaction.EnableSeekbarTappingPatch
import app.revanced.patches.youtube.layout.* import app.revanced.patches.youtube.layout.*
import app.revanced.patches.youtube.misc.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.IntegrationsPatch import app.revanced.patches.youtube.misc.IntegrationsPatch
/** /**
@ -22,8 +24,9 @@ object Index {
* Array of patches. * Array of patches.
* New patches should be added to the array. * New patches should be added to the array.
*/ */
val patches: List<() -> Patch> = listOf( val patches: List<() -> Patch<Data>> = listOf(
::IntegrationsPatch, ::IntegrationsPatch,
::FixLocaleConfigErrorPatch,
::HomeAdsPatch, ::HomeAdsPatch,
::VideoAdsPatch, ::VideoAdsPatch,
::HomePromoPatch, ::HomePromoPatch,

View File

@ -1,14 +1,18 @@
package app.revanced.patches.music.audio 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
import app.revanced.patcher.signature.PatternScanMethod import app.revanced.patcher.signature.PatternScanMethod
import app.revanced.patcher.smali.toInstruction import app.revanced.patcher.smali.toInstruction
import app.revanced.patcher.toMethodWalker
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@ -27,7 +31,7 @@ private val patchMetadata = PatchMetadata(
"0.0.1" "0.0.1"
) )
class CodecsUnlockPatch : Patch( class CodecsUnlockPatch : BytecodePatch(
patchMetadata, patchMetadata,
listOf( listOf(
MethodSignature( 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!! var result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
@ -138,7 +142,7 @@ class CodecsUnlockPatch : Patch(
val instructionIndex = result.scanData.startIndex val instructionIndex = result.scanData.startIndex
result = signatures.last().result!! result = signatures.last().result!!
val codecMethod = patcherData val codecMethod = data
.toMethodWalker(result.immutableMethod) .toMethodWalker(result.immutableMethod)
.walk(result.scanData.startIndex) .walk(result.scanData.startIndex)
.getMethod() .getMethod()

View File

@ -1,8 +1,13 @@
package app.revanced.patches.music.audio 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -18,7 +23,7 @@ private val compatiblePackages = listOf(
) )
) )
class EnableAudioOnlyPatch : Patch( class EnableAudioOnlyPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"audio-only-playback-patch", "audio-only-playback-patch",
"Audio Only Mode 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( val result = signatures.first().result!!.findParentMethod(
MethodSignature( MethodSignature(
MethodSignatureMetadata( MethodSignatureMetadata(

View File

@ -1,9 +1,13 @@
package app.revanced.patches.music.layout 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -20,7 +24,7 @@ private val compatiblePackages = listOf(
) )
) )
class RemoveTasteBuilderPatch : Patch( class RemoveTasteBuilderPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"tasteBuilder-remover", "tasteBuilder-remover",
"Remove TasteBuilder Patch", "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 result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!

View File

@ -1,9 +1,13 @@
package app.revanced.patches.music.layout 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -22,7 +26,7 @@ private val compatiblePackages = listOf(
) )
) )
class RemoveUpgradeTabPatch : Patch( class RemoveUpgradeTabPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"upgrade-tab-remover", "upgrade-tab-remover",
"Remove Upgrade Tab Patch", "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 result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!

View File

@ -1,9 +1,13 @@
package app.revanced.patches.music.premium 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -19,7 +23,7 @@ private val compatiblePackages = listOf(
) )
) )
class BackgroundPlayPatch : Patch( class BackgroundPlayPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"background-play", "background-play",
"Enable Background Playback Patch", "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( signatures.first().result!!.method.implementation!!.addInstructions(
0, 0,
""" """

View File

@ -1,9 +1,13 @@
package app.revanced.patches.youtube.ad package app.revanced.patches.youtube.ad
import app.revanced.extensions.injectHideCall 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata 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." private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38."
class HomeAdsPatch : Patch( class HomeAdsPatch : BytecodePatch(
patchMetadata, patchMetadata,
listOf( listOf(
MethodSignature( 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()) { for (i in 0 until signatures.count()) {
val signature = signatures.elementAt(i) val signature = signatures.elementAt(i)
val result = signature.result!! val result = signature.result!!

View File

@ -1,15 +1,20 @@
package app.revanced.patches.youtube.ad package app.revanced.patches.youtube.ad
import app.revanced.extensions.injectHideCall 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.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.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
import app.revanced.patcher.signature.PatternScanMethod import app.revanced.patcher.signature.PatternScanMethod
import app.revanced.patcher.toMethodWalker
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction11x 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." private val signatureDescription = "Required signature for ${patchMetadata.name}. Discovered in version 17.03.38."
class HomePromoPatch : Patch( class HomePromoPatch : BytecodePatch(
patchMetadata, patchMetadata,
listOf( listOf(
MethodSignature( MethodSignature(
@ -137,7 +142,7 @@ class HomePromoPatch : Patch(
) )
) )
) { ) {
override fun execute(patcherData: PatcherData): PatchResult { override fun execute(data: BytecodeData): PatchResult {
for (signature in signatures) { for (signature in signatures) {
val result = signature.result!! val result = signature.result!!
@ -162,7 +167,7 @@ class HomePromoPatch : Patch(
val toBePatchedInvokeOffset = val toBePatchedInvokeOffset =
requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT } requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT }
val toBePatchedMethod = patcherData val toBePatchedMethod = data
.toMethodWalker(requiredMethod.immutableMethod) .toMethodWalker(requiredMethod.immutableMethod)
.walk(toBePatchedInvokeOffset, true) .walk(toBePatchedInvokeOffset, true)
.getMethod() as MutableMethod .getMethod() as MutableMethod

View File

@ -1,9 +1,14 @@
package app.revanced.patches.youtube.ad 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -27,7 +32,7 @@ private val patchMetadata = PatchMetadata(
"0.0.1" "0.0.1"
) )
class VideoAdsPatch : Patch( class VideoAdsPatch : BytecodePatch(
patchMetadata, patchMetadata,
listOf( listOf(
MethodSignature( 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!! var result = signatures.first().result!!
val responsibleMethodSignature = MethodSignature( val responsibleMethodSignature = MethodSignature(
@ -104,5 +109,4 @@ class VideoAdsPatch : Patch(
return PatchResultSuccess() return PatchResultSuccess()
} }
} }

View File

@ -1,9 +1,14 @@
package app.revanced.patches.youtube.interaction 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -23,7 +28,7 @@ private val compatiblePackages = listOf(
) )
) )
class EnableSeekbarTappingPatch : Patch( class EnableSeekbarTappingPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"seekbar-tapping", "seekbar-tapping",
"Enable seekbar tapping patch", "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!! var result = signatures.first().result!!
val tapSeekMethods = mutableMapOf<String, Method>() val tapSeekMethods = mutableMapOf<String, Method>()

View File

@ -1,8 +1,13 @@
package app.revanced.patches.youtube.layout 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -19,7 +24,7 @@ private val compatiblePackages = listOf(
) )
) )
class CreateButtonRemoverPatch : Patch( class CreateButtonRemoverPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"create-button", "create-button",
"Create button patch", "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!! val result = signatures.first().result!!
// Get the required register which holds the view object we need to pass to the method hideCreateButton // Get the required register which holds the view object we need to pass to the method hideCreateButton

View File

@ -1,8 +1,12 @@
package app.revanced.patches.youtube.layout 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -18,7 +22,7 @@ private val compatiblePackages = listOf(
) )
) )
class HideReelsPatch : Patch( class HideReelsPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"hide-reels", "hide-reels",
"Hide reels patch", "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 result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!

View File

@ -1,9 +1,13 @@
package app.revanced.patches.youtube.layout 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -19,7 +23,7 @@ private val compatiblePackages = listOf(
) )
) )
class MinimizedPlaybackPatch : Patch( class MinimizedPlaybackPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"minimized-playback", "minimized-playback",
"Minimized Playback Patch", "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, // Instead of removing all instructions like Vanced,
// we return the method at the beginning instead // we return the method at the beginning instead
signatures.first().result!!.method.implementation!!.addInstructions( signatures.first().result!!.method.implementation!!.addInstructions(

View File

@ -1,9 +1,14 @@
package app.revanced.patches.youtube.layout 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.addInstructions
import app.revanced.patcher.extensions.or 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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -20,7 +25,7 @@ private val compatiblePackages = listOf(
) )
) )
class OldQualityLayoutPatch : Patch( class OldQualityLayoutPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"old-quality-layout", "old-quality-layout",
"Old Quality Layout Patch", "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!! var result = signatures.first().result!!
result = result.findParentMethod( result = result.findParentMethod(

View File

@ -1,8 +1,12 @@
package app.revanced.patches.youtube.layout 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.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.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata import app.revanced.patcher.signature.MethodSignatureMetadata
@ -19,7 +23,7 @@ private val compatiblePackages = listOf(
) )
) )
class ShortsButtonRemoverPatch : Patch( class ShortsButtonRemoverPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"shorts-button", "shorts-button",
"Shorts button patch", "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 result1 = signatures.first().result!!
val implementation1 = result1.method.implementation!! val implementation1 = result1.method.implementation!!
val moveEnumInstruction = implementation1.instructions[result1.scanData.endIndex] val moveEnumInstruction = implementation1.instructions[result1.scanData.endIndex]

View File

@ -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()
}
}

View File

@ -1,9 +1,13 @@
package app.revanced.patches.youtube.misc 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.addInstructions
import app.revanced.patcher.extensions.or 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.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.signature.MethodMetadata import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature import app.revanced.patcher.signature.MethodSignature
@ -22,7 +26,7 @@ private val compatiblePackages = listOf(
) )
) )
class IntegrationsPatch : Patch( class IntegrationsPatch : BytecodePatch(
PatchMetadata( PatchMetadata(
"integrations", "integrations",
"Inject Integrations Patch", "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 result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!