refactor: simplify casting instructions

This commit is contained in:
inotia00 2023-05-10 21:31:51 +09:00
parent 0f5350e691
commit 2b70050200
144 changed files with 888 additions and 1272 deletions

View File

@ -9,7 +9,5 @@ object ClientInfoFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.OR_INT_LIT16
)
opcodes = listOf(Opcode.OR_INT_LIT16)
)

View File

@ -4,11 +4,6 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object OnBackPressedFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.RETURN_VOID
),
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("WatchWhileActivity;")
&& methodDef.name == "onBackPressed"
}
opcodes = listOf(Opcode.RETURN_VOID),
customFingerprint = { it.definingClass.endsWith("WatchWhileActivity;") && it.name == "onBackPressed" }
)

View File

@ -30,13 +30,13 @@ class DoubleBackToClosePatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext): PatchResult {
/*
Hook onBackPressed method inside WatchWhileActivity
/**
* Hook onBackPressed method inside WatchWhileActivity
*/
OnBackPressedFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
with(it.mutableMethod) {
addInstruction(
insertIndex,
"invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR" +
@ -47,8 +47,8 @@ class DoubleBackToClosePatch : BytecodePatch(
} ?: return OnBackPressedFingerprint.toErrorResult()
/*
Inject the methods which start of ScrollView
/**
* Inject the methods which start of ScrollView
*/
ScrollPositionFingerprint.result?.let {
val insertMethod = context.toMethodWalker(it.method)
@ -57,19 +57,18 @@ class DoubleBackToClosePatch : BytecodePatch(
val insertIndex = insertMethod.implementation!!.instructions.size - 1 - 1
injectScrollView(insertMethod, insertIndex, "onStartScrollView")
insertMethod.injectScrollView(insertIndex, "onStartScrollView")
} ?: return ScrollPositionFingerprint.toErrorResult()
/*
Inject the methods which stop of ScrollView
/**Inject the methods which stop of ScrollView
*/
ScrollTopParentFingerprint.result?.let { parentResult ->
ScrollTopFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
val insertMethod = it.mutableMethod
val insertIndex = it.scanResult.patternScanResult!!.endIndex
injectScrollView(insertMethod, insertIndex, "onStopScrollView")
insertMethod.injectScrollView(insertIndex, "onStopScrollView")
} ?: return ScrollTopFingerprint.toErrorResult()
} ?: return ScrollTopParentFingerprint.toErrorResult()
@ -80,12 +79,11 @@ class DoubleBackToClosePatch : BytecodePatch(
const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$UTILS_PATH/DoubleBackToClosePatch;"
fun injectScrollView(
method: MutableMethod,
fun MutableMethod.injectScrollView(
index: Int,
descriptor: String
) {
method.addInstruction(
addInstruction(
index,
"invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->$descriptor()V"
)

View File

@ -5,48 +5,44 @@ import app.revanced.extensions.injectHideCall
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.adAttributionId
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@Name("hide-general-ads-bytecode-patch")
@DependsOn([SharedResourceIdPatch::class])
@Version("0.0.1")
@Suppress("LABEL_NAME_CLASH")
class GeneralAdsBytecodePatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
context.classes.forEach { classDef ->
classDef.methods.forEach { method ->
with(method.implementation) {
this?.instructions?.forEachIndexed { index, instruction ->
if (instruction.opcode != org.jf.dexlib2.Opcode.CONST)
return@forEachIndexed
// Instruction to store the id adAttribution into a register
if ((instruction as Instruction31i).wideLiteral != SharedResourceIdPatch.adAttributionLabelId)
return@forEachIndexed
if (!method.isWideLiteralExists(adAttributionId))
return@forEach
val insertIndex = index + 1
// Call to get the view with the id adAttribution
with(instructions.elementAt(insertIndex)) {
if (opcode != org.jf.dexlib2.Opcode.INVOKE_VIRTUAL)
return@forEachIndexed
// Hide the view
val viewRegister = (this as Instruction35c).registerC
context.proxy(classDef)
.mutableClass
.findMutableMethodOf(method)
.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideAdAttributionView")
}
}
.apply {
val insertIndex = method.getWideLiteralIndex(adAttributionId) + 1
if (instruction(insertIndex).opcode != org.jf.dexlib2.Opcode.INVOKE_VIRTUAL)
return@forEach
val viewRegister = instruction<Instruction35c>(insertIndex).registerC
this.implementation!!.injectHideCall(insertIndex, viewRegister, "ads/GeneralAdsPatch", "hideAdAttributionView")
}
}
}
context.updatePatchStatus("GeneralAds")
return PatchResultSuccess()

View File

@ -14,6 +14,7 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch
import app.revanced.patches.youtube.ads.getpremium.patch.HideGetPremiumPatch
import app.revanced.patches.youtube.misc.litho.patch.ByteBufferFilterPatch
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import org.w3c.dom.Element
@ -23,9 +24,9 @@ import org.w3c.dom.Element
@Description("Removes general ads.")
@DependsOn(
[
HideGetPremiumPatch::class,
ByteBufferFilterPatch::class,
GeneralAdsBytecodePatch::class,
LithoFilterPatch::class,
HideGetPremiumPatch::class,
SettingsPatch::class
]
)

View File

@ -17,17 +17,15 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@Name("hide-get-premium")
@Version("0.0.1")
class HideGetPremiumPatch : BytecodePatch(
listOf(
CompactYpcOfferModuleViewFingerprint
)
listOf(CompactYpcOfferModuleViewFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
CompactYpcOfferModuleViewFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val measuredWidthRegister = (instruction(startIndex) as TwoRegisterInstruction).registerA
val measuredHeightInstruction = instruction(startIndex + 1) as TwoRegisterInstruction
val measuredWidthRegister = instruction<TwoRegisterInstruction>(startIndex).registerA
val measuredHeightInstruction = instruction<TwoRegisterInstruction>(startIndex + 1)
val measuredHeightRegister = measuredHeightInstruction.registerA
val tempRegister = measuredHeightInstruction.registerB

View File

@ -15,5 +15,5 @@ object SwipeRefreshLayoutFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT,
Opcode.RETURN
),
customFingerprint = { it.definingClass == "Landroidx/swiperefreshlayout/widget/SwipeRefreshLayout;" }
customFingerprint = { it.definingClass.endsWith("SwipeRefreshLayout;") }
)

View File

@ -19,16 +19,14 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class SwipeRefreshPatch : BytecodePatch(
listOf(
SwipeRefreshLayoutFingerprint
)
listOf(SwipeRefreshLayoutFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
SwipeRefreshLayoutFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,

View File

@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.videoads.GeneralVideoAdsPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import app.revanced.util.integrations.Constants.ADS_PATH
@Patch
@ -32,8 +31,6 @@ class VideoAdsPatch : BytecodePatch() {
GeneralVideoAdsPatch.injectLegacyAds(INTEGRATIONS_CLASS_DESCRIPTOR)
GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR)
context.updatePatchStatus("VideoAds")
/*
* Add settings
*/

View File

@ -15,7 +15,5 @@ object RepeatListenerFingerprint : MethodFingerprint(
Opcode.CHECK_CAST,
Opcode.CONST_WIDE_32
),
strings = listOf(
"ppoobsa"
)
strings = listOf("ppoobsa")
)

View File

@ -8,5 +8,5 @@ object VideoEndFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
customFingerprint = { methodDef -> methodDef.implementation!!.instructions.count() == 3 && methodDef.annotations.isEmpty()}
customFingerprint = { it.implementation!!.instructions.count() == 3 && it.annotations.isEmpty()}
)

View File

@ -16,6 +16,7 @@ import app.revanced.util.integrations.Constants.UTILS_PATH
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@Name("always-autorepeat")
@ -45,22 +46,23 @@ class AutoRepeatPatch : BytecodePatch(
} ?: return VideoEndParentFingerprint.toErrorResult()
RepeatListenerFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex - 1
val endIndex = it.scanResult.patternScanResult!!.endIndex
with (it.mutableMethod) {
val targetReference = (instruction(targetIndex) as BuilderInstruction35c).reference.toString()
val firstRegister = (instruction(targetIndex) as BuilderInstruction35c).registerC
val secondRegister = (instruction(targetIndex) as BuilderInstruction35c).registerD
val registerC = instruction<BuilderInstruction35c>(targetIndex).registerC
val registerD = instruction<BuilderInstruction35c>(targetIndex).registerD
val dummyRegister = (instruction(endIndex) as Instruction31i).registerA
val targetReference = instruction<ReferenceInstruction>(targetIndex).reference
addInstructions(
targetIndex + 1, """
invoke-static {}, $UTILS_PATH/EnableAutoRepeatPatch;->shouldAutoRepeat()Z
move-result v$dummyRegister
if-nez v$dummyRegister, :bypass
invoke-virtual {v$firstRegister, v$secondRegister}, $targetReference
invoke-virtual {v$registerC, v$registerD}, $targetReference
""", listOf(ExternalLabel("bypass", instruction(targetIndex + 1)))
)
removeInstruction(targetIndex)
@ -68,17 +70,15 @@ class AutoRepeatPatch : BytecodePatch(
} ?: return RepeatListenerFingerprint.toErrorResult()
AutoNavInformerFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
val index = this.size - 1 - 1
val register = (this[index] as OneRegisterInstruction).registerA
val index = it.implementation!!.instructions.size - 1 - 1
val register = it.instruction<OneRegisterInstruction>(index).registerA
it.addInstructions(
index + 1, """
invoke-static {v$register}, $UTILS_PATH/EnableAutoRepeatPatch;->enableAutoRepeat(Z)Z
move-result v0
"""
)
}
} ?: return AutoNavInformerFingerprint.toErrorResult()
return PatchResultSuccess()

View File

@ -25,14 +25,14 @@ class OverlayButtonsBytecodePatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
arrayOf(
"$BUTTON_PATH/Download;",
"$BUTTON_PATH/AutoRepeat;",
"$BUTTON_PATH/CopyWithTimeStamp;",
"$BUTTON_PATH/Copy;",
"$BUTTON_PATH/Speed;"
).forEach { descriptor ->
PlayerControlsPatch.initializeControl(descriptor)
PlayerControlsPatch.injectVisibility(descriptor)
"Download",
"AutoRepeat",
"CopyWithTimeStamp",
"Copy",
"Speed"
).forEach {
PlayerControlsPatch.initializeControl("$BUTTON_PATH/$it;")
PlayerControlsPatch.injectVisibility("$BUTTON_PATH/$it;")
}
return PatchResultSuccess()

View File

@ -4,17 +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.ResourceContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.litho.patch.ByteBufferFilterPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.BOTTOM_PLAYER
@ -23,8 +19,7 @@ import app.revanced.util.integrations.Constants.BOTTOM_PLAYER
@Description("Adds the options to hide action buttons under a video.")
@DependsOn(
[
LithoFilterPatch::class,
PlayerTypeHookPatch::class,
ByteBufferFilterPatch::class,
SettingsPatch::class
]
)
@ -33,32 +28,9 @@ import app.revanced.util.integrations.Constants.BOTTOM_PLAYER
class ButtonContainerPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
val instructionList =
"""
move-object/from16 v3, p2
invoke-static {v3, v10}, $BOTTOM_PLAYER->hideActionButtons(Ljava/lang/Object;Ljava/nio/ByteBuffer;)Z
move-result v10
if-eqz v10, :do_not_block
move-object/from16 v15, p1
invoke-static {v15}, ${LithoFilterPatch.builderMethodDescriptor}
move-result-object v0
iget-object v0, v0, ${LithoFilterPatch.emptyComponentFieldDescriptor}
return-object v0
"""
ByteBufferFilterPatch.inject("$BOTTOM_PLAYER->hideActionButtons")
with(LithoFilterPatch.lithoMethod) {
addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type}
if-eqz v10, :do_not_block
check-cast v10, ${LithoFilterPatch.bufferReference}
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
class CommentComponentPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -21,18 +21,11 @@ import org.w3c.dom.Element
@YouTubeCompatibility
@Version("0.0.1")
class PlayerButtonBackgroundPatch : ResourcePatch {
private companion object {
const val RESOURCE_FILE_PATH = "res/drawable/player_button_circle_background.xml"
val replacements = arrayOf(
"color"
)
}
override fun execute(context: ResourceContext): PatchResult {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
context.xmlEditor["res/drawable/player_button_circle_background.xml"].use { editor ->
editor.file.doRecursively { node ->
replacements.forEach replacement@{ replacement ->
arrayOf("color").forEach replacement@{ replacement ->
if (node !is Element) return@replacement
node.getAttributeNode("android:$replacement")?.let { attribute ->

View File

@ -14,9 +14,9 @@ import app.revanced.patches.youtube.layout.etc.theme.patch.GeneralThemePatch
import app.revanced.patches.youtube.layout.etc.theme.patch.GeneralThemePatch.Companion.isMonetPatchIncluded
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.resources.ResourceHelper.updatePatchStatusTheme
import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources
import app.revanced.util.resources.ResourceUtils.copyXmlNode
import java.nio.file.Files
import java.nio.file.StandardCopyOption
@Patch(false)
@Name("materialyou")
@ -32,35 +32,28 @@ import java.nio.file.StandardCopyOption
class MaterialYouPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
val drawables1 = "drawable-night-v31" to arrayOf(
arrayOf(
ResourceUtils.ResourceGroup(
"drawable-night-v31",
"new_content_dot_background.xml"
)
val drawables2 = "drawable-v31" to arrayOf(
),
ResourceUtils.ResourceGroup(
"drawable-v31",
"new_content_count_background.xml",
"new_content_dot_background.xml"
)
val layout1 = "layout-v31" to arrayOf(
),
ResourceUtils.ResourceGroup(
"layout-v31",
"new_content_count.xml"
)
arrayOf(drawables1, drawables2, layout1).forEach { (path, resourceNames) ->
Files.createDirectory(context["res"].resolve(path).toPath())
resourceNames.forEach { name ->
val monetPath = "$path/$name"
Files.copy(
this.javaClass.classLoader.getResourceAsStream("youtube/materialyou/$monetPath")!!,
context["res"].resolve(monetPath).toPath(),
StandardCopyOption.REPLACE_EXISTING
)
}
).forEach {
context["res/${it.resourceDirectoryName}"].mkdirs()
context.copyResources("youtube/materialyou", it)
}
context.copyXmlNode("youtube/materialyou/host", "values-v31/colors.xml", "resources")
/*
/**
* Add settings
*/
context.updatePatchStatusTheme("materialyou")

View File

@ -29,7 +29,7 @@ class RedundantResourcePatch : ResourcePatch {
WHITELIST_XHDPI,
WHITELIST_XXXHDPI
).forEach { (path, array) ->
val tmpDirectory = path + "-v21"
val tmpDirectory = "$path-v21"
Files.createDirectory(context["res"].resolve(tmpDirectory).toPath())
(WHITELIST_GENERAL + array).forEach { name ->

View File

@ -2,19 +2,13 @@ package app.revanced.patches.youtube.layout.etc.tooltip.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.toolTipId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object TooltipContentViewFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.tooltipLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(toolTipId) }
)

View File

@ -39,7 +39,7 @@ class TooltipContentViewPatch : BytecodePatch(
"return-void"
) ?: return TooltipContentViewFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.updatePatchStatus("hide-tooltip-content")

View File

@ -10,7 +10,7 @@ import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
@Patch
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
@Description("Adds options to hide player settings flyout panel.")
@DependsOn(
[
LithoFilterPatch::class,
GeneralAdsPatch::class,
SettingsPatch::class
]
)
@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
class FlyoutPanelPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,8 +1,8 @@
package app.revanced.patches.youtube.layout.flyoutpanel.oldqualitylayout.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.videoQualityFragmentId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object QualityMenuViewInflateFingerprint : MethodFingerprint(
@ -22,10 +22,5 @@ object QualityMenuViewInflateFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.videoQualityFragmentLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(videoQualityFragmentId) }
)

View File

@ -38,9 +38,10 @@ class OldQualityLayoutPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
QualityMenuViewInflateFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(endIndex).registerA
addInstruction(
endIndex + 1,
"invoke-static { v$register }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/ListView;)V"
@ -48,7 +49,7 @@ class OldQualityLayoutPatch : BytecodePatch(
}
} ?: return QualityMenuViewInflateFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
@ -14,15 +15,15 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.autoNavPreviewId
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getStringIndex
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.FULLSCREEN
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
import org.jf.dexlib2.iface.reference.FieldReference
@Patch
@ -30,53 +31,38 @@ import org.jf.dexlib2.iface.reference.FieldReference
@Description("Hides the autoplay preview container in the fullscreen.")
@DependsOn(
[
ResourceMappingPatch::class,
SettingsPatch::class
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class HideAutoplayPreviewPatch : BytecodePatch(
listOf(
LayoutConstructorFingerprint
)
listOf(LayoutConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
// resolve the offsets such as ...
val autoNavPreviewStubId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "autonav_preview_stub"
}.id
LayoutConstructorFingerprint.result?.mutableMethod?.let {
val insertInstruction = it.implementation!!.instructions
LayoutConstructorFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val registerIndex = indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "1.0x"
}
val dummyRegister = (this[registerIndex] as Instruction21c).registerA
val dummyRegister = it.instruction<OneRegisterInstruction>(it.getStringIndex("1.0x")).registerA
val insertIndex = it.getWideLiteralIndex(autoNavPreviewId)
// where to insert the branch instructions and ...
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == autoNavPreviewStubId
}
val branchIndex = this.subList(insertIndex + 1, this.size - 1).indexOfFirst {
((it as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
val branchIndex = insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1).indexOfFirst { instruction ->
((instruction as? ReferenceInstruction)?.reference as? FieldReference)?.type == "Lcom/google/android/apps/youtube/app/player/autonav/AutonavToggleController;"
} + 1
val jumpInstruction = this[insertIndex + branchIndex] as Instruction
val jumpInstruction = it.instruction<Instruction>(insertIndex + branchIndex)
method.addInstructions(
it.addInstructions(
insertIndex, """
invoke-static {}, $FULLSCREEN->hideAutoPlayPreview()Z
move-result v$dummyRegister
if-nez v$dummyRegister, :hidden
""", listOf(ExternalLabel("hidden", jumpInstruction))
)
}
} ?: return LayoutConstructorFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.accessibilityVideoTimeId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object ScrubbingLabelAlternativeFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.IF_NEZ,
Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_BOOLEAN,
Opcode.RETURN_VOID
),
customFingerprint = { it.isWideLiteralExists(accessibilityVideoTimeId) }
)

View File

@ -1,16 +1,14 @@
package app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.scrubbingId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object ScrubbingLabelFingerprint : MethodFingerprint(
opcodes = listOf(Opcode.IPUT_BOOLEAN),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.scrubbingLabelId
} == true
}
opcodes = listOf(
Opcode.IPUT_BOOLEAN,
Opcode.CONST_WIDE_32
),
customFingerprint = { it.isWideLiteralExists(scrubbingId) }
)

View File

@ -6,57 +6,52 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints.ScrubbingLabelAlternativeFingerprint
import app.revanced.patches.youtube.layout.fullscreen.flimstripoverlay.fingerprints.ScrubbingLabelFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.FULLSCREEN
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.reference.FieldReference
@Patch
@Name("hide-filmstrip-overlay")
@Description("Hide flimstrip overlay on swipe controls.")
@DependsOn([SettingsPatch::class])
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class HideFilmstripOverlayPatch : BytecodePatch(
listOf(
ScrubbingLabelFingerprint
ScrubbingLabelFingerprint,
ScrubbingLabelAlternativeFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
ScrubbingLabelFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
for ((index, instruction) in this.withIndex()) {
if (instruction.opcode != Opcode.IPUT_BOOLEAN) continue
val primaryRegister = (instruction as TwoRegisterInstruction).registerA
val secondaryRegister = (instruction as TwoRegisterInstruction).registerB
val dummyRegister = primaryRegister + 2
val fieldReference = (instruction as ReferenceInstruction).reference as FieldReference
it.addInstructions(
index + 1, """
invoke-static {}, $FULLSCREEN->hideFilmstripOverlay()Z
move-result v$dummyRegister
if-eqz v$dummyRegister, :show
const/4 v$primaryRegister, 0x0
:show
iput-boolean v$primaryRegister, v$secondaryRegister, ${fieldReference.definingClass}->${fieldReference.name}:${fieldReference.type}
"""
)
val result = try {
ScrubbingLabelFingerprint.result!!
} catch (_: Exception) {
ScrubbingLabelAlternativeFingerprint.result
?: return ScrubbingLabelAlternativeFingerprint.toErrorResult()
}
it.removeInstruction(index)
result.mutableMethod.hook(result.scanResult.patternScanResult!!.endIndex - 1)
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -70,9 +65,21 @@ class HideFilmstripOverlayPatch : BytecodePatch(
return PatchResultSuccess()
}
}
} ?: return ScrubbingLabelFingerprint.toErrorResult()
private companion object {
fun MutableMethod.hook(index: Int) {
val targetInstruction = instruction<TwoRegisterInstruction>(index)
val fieldReference = instruction<ReferenceInstruction>(index).reference
replaceInstruction(
index,
"invoke-static {v${targetInstruction.registerA}}, $FULLSCREEN->hideFilmstripOverlay(Z)Z"
)
return PatchResultError("Could not find the method to hook.")
addInstructions(
index + 1, """
move-result v${targetInstruction.registerA}
iput-boolean v${targetInstruction.registerA}, v${targetInstruction.registerB}, $fieldReference
"""
)
}
}
}

View File

@ -19,11 +19,11 @@ import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.youtube.layout.fullscreen.fullscreenpanels.fingerprints.FullscreenViewAdderFingerprint
import app.revanced.patches.youtube.layout.fullscreen.quickactions.patch.QuickActionsPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getStringIndex
import app.revanced.util.integrations.Constants.FULLSCREEN
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@Patch
@ -45,9 +45,9 @@ class HideFullscreenPanelsPatch : BytecodePatch(
) {
override fun execute(context: BytecodeContext): PatchResult {
FullscreenViewAdderFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = (implementation!!.instructions[endIndex] as Instruction35c).registerD
val register = instruction<Instruction35c>(endIndex).registerD
for (i in 1..3) removeInstruction(endIndex - i)
@ -60,30 +60,26 @@ class HideFullscreenPanelsPatch : BytecodePatch(
}
} ?: return FullscreenViewAdderFingerprint.toErrorResult()
LayoutConstructorFingerprint.result?.mutableMethod?.let { method ->
val instructions = method.implementation!!.instructions
val registerIndex = instructions.indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "1.0x"
}
val dummyRegister = (instructions[registerIndex] as Instruction21c).registerA
LayoutConstructorFingerprint.result?.mutableMethod?.let {
val instructions = it.implementation!!.instructions
val dummyRegister = it.instruction<OneRegisterInstruction>(it.getStringIndex("1.0x")).registerA
val invokeIndex = method.implementation!!.instructions.indexOfFirst {
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
((it as? BuilderInstruction35c)?.reference.toString() ==
val invokeIndex = instructions.indexOfFirst { instruction ->
instruction.opcode == Opcode.INVOKE_VIRTUAL &&
((instruction as ReferenceInstruction).reference.toString() ==
"Landroid/widget/FrameLayout;->addView(Landroid/view/View;)V")
}
method.addInstructions(
it.addInstructions(
invokeIndex, """
invoke-static {}, $FULLSCREEN->showFullscreenTitle()Z
move-result v$dummyRegister
if-eqz v$dummyRegister, :hidden
""", listOf(ExternalLabel("hidden", method.instruction(invokeIndex + 1)))
""", listOf(ExternalLabel("hidden", it.instruction(invokeIndex + 1)))
)
} ?: return LayoutConstructorFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -51,7 +51,7 @@ class HapticFeedBackPatch : BytecodePatch(
} ?: return fingerprint.toErrorResult()
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -68,13 +68,13 @@ class HapticFeedBackPatch : BytecodePatch(
private companion object {
fun MethodFingerprintResult.disableHaptics(targetMethodName: String) {
mutableMethod.apply {
val startIndex = scanResult.patternScanResult!!.startIndex
val endIndex = scanResult.patternScanResult!!.endIndex
val insertIndex = endIndex + 4
val targetRegister = (method.implementation!!.instructions.elementAt(insertIndex) as OneRegisterInstruction).registerA
val targetRegister = instruction<OneRegisterInstruction>(insertIndex).registerA
val dummyRegister = targetRegister + 1
with (mutableMethod) {
removeInstruction(insertIndex)
addInstructions(
@ -86,7 +86,7 @@ class HapticFeedBackPatch : BytecodePatch(
goto :exit
:vibrate
const-wide/16 v$targetRegister, 0x19
""", listOf(ExternalLabel("exit", mutableMethod.instruction(insertIndex)))
""", listOf(ExternalLabel("exit", instruction(insertIndex)))
)
addInstructions(
@ -95,7 +95,7 @@ class HapticFeedBackPatch : BytecodePatch(
move-result v$dummyRegister
if-eqz v$dummyRegister, :vibrate
return-void
""", listOf(ExternalLabel("vibrate", mutableMethod.instruction(startIndex)))
""", listOf(ExternalLabel("vibrate", instruction(startIndex)))
)
}
}

View File

@ -27,21 +27,19 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class LandScapeModePatch : BytecodePatch(
listOf(
OrientationParentFingerprint
)
listOf(OrientationParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
OrientationParentFingerprint.result?.classDef?.let { classDef ->
arrayOf(
OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint
).forEach { fingerprint ->
fingerprint.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return fingerprint.toErrorResult()
).forEach {
it.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return it.toErrorResult()
}
} ?: return OrientationParentFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -61,9 +59,9 @@ class LandScapeModePatch : BytecodePatch(
"$FULLSCREEN->disableLandScapeMode(Z)Z"
fun MethodFingerprintResult.injectOverride() {
with (mutableMethod) {
mutableMethod.apply {
val index = scanResult.patternScanResult!!.endIndex
val register = (instruction(index) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(index).registerA
addInstructions(
index +1, """

View File

@ -4,27 +4,21 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.FULLSCREEN
@Patch
@Name("hide-quick-actions")
@Description("Adds the options to hide quick actions components in the fullscreen.")
@DependsOn(
[
LithoFilterPatch::class,
PlayerTypeHookPatch::class,
GeneralAdsPatch::class,
SettingsPatch::class
]
)
@ -33,32 +27,7 @@ import app.revanced.util.integrations.Constants.FULLSCREEN
class QuickActionsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
val instructionList =
"""
move-object/from16 v3, p2
invoke-static {v3, v10}, $FULLSCREEN->hideQuickActionButtons(Ljava/lang/Object;Ljava/nio/ByteBuffer;)Z
move-result v10
if-eqz v10, :do_not_block
move-object/from16 v15, p1
invoke-static {v15}, ${LithoFilterPatch.builderMethodDescriptor}
move-result-object v0
iget-object v0, v0, ${LithoFilterPatch.emptyComponentFieldDescriptor}
return-object v0
"""
with(LithoFilterPatch.lithoMethod) {
addInstructions(
0, """
move-object/from16 v10, p3
iget-object v10, v10, ${LithoFilterPatch.objectReference.definingClass}->${LithoFilterPatch.objectReference.name}:${LithoFilterPatch.objectReference.type}
if-eqz v10, :do_not_block
check-cast v10, ${LithoFilterPatch.bufferReference}
iget-object v10, v10, ${LithoFilterPatch.bufferReference}->b:Ljava/nio/ByteBuffer;
""" + instructionList,listOf(ExternalLabel("do_not_block", LithoFilterPatch.lithoMethod.instruction(0)))
)
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,16 +1,10 @@
package app.revanced.patches.youtube.layout.fullscreen.seekmessage.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.Opcode
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.easySeekEduContainerId
import app.revanced.util.bytecode.isWideLiteralExists
object SeekEduContainerFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.easySeekEduContainerId
} == true
}
customFingerprint = { it.isWideLiteralExists(easySeekEduContainerId) }
)

View File

@ -30,9 +30,7 @@ import app.revanced.util.integrations.Constants.FULLSCREEN
@YouTubeCompatibility
@Version("0.0.1")
class SeekMessagePatch : BytecodePatch(
listOf(
SeekEduContainerFingerprint
)
listOf(SeekEduContainerFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.accountmenu.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.compactLinkId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object AccountMenuParentFingerprint : MethodFingerprint(
opcodes = listOf(
@ -12,10 +12,5 @@ object AccountMenuParentFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.compactLinkLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(compactLinkId) }
)

View File

@ -33,17 +33,15 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class AccountMenuPatch : BytecodePatch(
listOf(
AccountMenuParentFingerprint
)
listOf(AccountMenuParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
AccountMenuParentFingerprint.result?.let { parentResult ->
AccountMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val register = (instruction(targetIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
@ -52,9 +50,9 @@ class AccountMenuPatch : BytecodePatch(
}
} ?: return AccountMenuFingerprint.toErrorResult()
with (parentResult.mutableMethod) {
parentResult.mutableMethod.apply {
val endIndex = parentResult.scanResult.patternScanResult!!.endIndex
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(endIndex).registerA
addInstruction(
endIndex + 1,
@ -63,7 +61,7 @@ class AccountMenuPatch : BytecodePatch(
}
} ?: return AccountMenuParentFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -70,7 +70,7 @@ class AutoCaptionsPatch : BytecodePatch(
)
} ?: return SubtitleTrackFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -25,9 +25,7 @@ import app.revanced.util.integrations.Constants.GENERAL
@YouTubeCompatibility
@Version("0.0.1")
class PlayerPopupPanelsPatch : BytecodePatch(
listOf(
EngagementPanelControllerFingerprint
)
listOf(EngagementPanelControllerFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -44,7 +42,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
)
} ?: return EngagementPanelControllerFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.breakingnews.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.horizontalCardListId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object BreakingNewsFingerprint : MethodFingerprint(
opcodes = listOf(
@ -12,10 +12,5 @@ object BreakingNewsFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any { instruction ->
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.horizontalCardListId
} == true
}
customFingerprint = { it.isWideLiteralExists(horizontalCardListId) }
)

View File

@ -39,7 +39,7 @@ class BreakingNewsPatch : BytecodePatch(
BreakingNewsFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
val targetRegister = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $GENERAL->hideBreakingNewsShelf(Landroid/view/View;)V"

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.categorybar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.filterBarHeightId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object FilterBarHeightFingerprint : MethodFingerprint(
opcodes = listOf(
@ -12,10 +12,5 @@ object FilterBarHeightFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT,
Opcode.IPUT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.filterBarHeightLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(filterBarHeightId) }
)

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.categorybar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.relatedChipCloudMarginId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object RelatedChipCloudFingerprint : MethodFingerprint(
opcodes = listOf(
@ -11,10 +11,5 @@ object RelatedChipCloudFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.relatedChipCloudMarginLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(relatedChipCloudMarginId) }
)

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.categorybar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.barContainerHeightId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object SearchResultsChipBarFingerprint : MethodFingerprint(
opcodes = listOf(
@ -13,10 +13,5 @@ object SearchResultsChipBarFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.barContainerHeightLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(barContainerHeightId) }
)

View File

@ -48,9 +48,9 @@ class CategoryBarPatch : BytecodePatch(
* Home feed and subscriptions feed
*/
FilterBarHeightFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
val register = instruction<TwoRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex, """
@ -65,9 +65,9 @@ class CategoryBarPatch : BytecodePatch(
* Category Bar in related video
*/
RelatedChipCloudFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex + 1,
@ -80,9 +80,9 @@ class CategoryBarPatch : BytecodePatch(
* Category Bar in search results
*/
SearchResultsChipBarFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2
val register = (instruction(targetIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(
targetIndex + 1, """
@ -93,7 +93,7 @@ class CategoryBarPatch : BytecodePatch(
}
} ?: return SearchResultsChipBarFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.channellistsubmenu.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.channelListSubMenuId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object ChannelListSubMenuFingerprint : MethodFingerprint(
opcodes = listOf(
@ -12,10 +12,5 @@ object ChannelListSubMenuFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.channelListSubMenuLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(channelListSubMenuId) }
)

View File

@ -31,16 +31,14 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class ChannelListSubMenuPatch : BytecodePatch(
listOf(
ChannelListSubMenuFingerprint
)
listOf(ChannelListSubMenuFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ChannelListSubMenuFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(endIndex).registerA
addInstruction(
endIndex + 1,
@ -49,7 +47,7 @@ class ChannelListSubMenuPatch : BytecodePatch(
}
} ?: return ChannelListSubMenuFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.crowdfundingbox.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.donationCompanionResourceId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object CrowdfundingBoxFingerprint : MethodFingerprint(
opcodes = listOf(
@ -11,10 +11,5 @@ object CrowdfundingBoxFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.donationCompanionResourceId
} == true
}
customFingerprint = { it.isWideLiteralExists(donationCompanionResourceId) }
)

View File

@ -31,16 +31,14 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class CrowdfundingBoxPatch : BytecodePatch(
listOf(
CrowdfundingBoxFingerprint
)
listOf(CrowdfundingBoxFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
CrowdfundingBoxFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
val register = instruction<TwoRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,
@ -49,7 +47,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
}
} ?: return CrowdfundingBoxFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.floatingmicrophone.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.fabId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object FloatingMicrophoneFingerprint : MethodFingerprint(
opcodes = listOf(
@ -11,10 +11,5 @@ object FloatingMicrophoneFingerprint : MethodFingerprint(
Opcode.IF_EQZ,
Opcode.RETURN_VOID
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.fabLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(fabId) }
)

View File

@ -31,16 +31,14 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class FloatingMicrophonePatch : BytecodePatch(
listOf(
FloatingMicrophoneFingerprint
)
listOf(FloatingMicrophoneFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
FloatingMicrophoneFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
val register = instruction<TwoRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex + 1, """

View File

@ -76,7 +76,7 @@ class HeaderSwitchPatch : BytecodePatch() {
val errorIndex: Int = patchSuccessArray.indexOf(false)
if (errorIndex == -1) {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.loadmorebutton.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.expandButtonId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object LoadMoreButtonFingerprint : MethodFingerprint(
opcodes = listOf(
@ -12,10 +12,5 @@ object LoadMoreButtonFingerprint : MethodFingerprint(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any { instruction ->
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.expandButtonId
} == true
}
customFingerprint = { it.isWideLiteralExists(expandButtonId) }
)

View File

@ -31,15 +31,13 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class LoadMoreButtonPatch : BytecodePatch(
listOf(
LoadMoreButtonFingerprint,
)
listOf(LoadMoreButtonFingerprint,)
) {
override fun execute(context: BytecodeContext): PatchResult {
LoadMoreButtonFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
val targetRegister = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $GENERAL->hideLoadMoreButton(Landroid/view/View;)V"

View File

@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.litho.patch.ByteBufferFilterPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
@Patch
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
@Description("Removes mix playlists from home feed and video player.")
@DependsOn(
[
LithoFilterPatch::class,
ByteBufferFilterPatch::class,
SettingsPatch::class
]
)
@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
class MixPlaylistsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,9 +1,9 @@
package app.revanced.patches.youtube.layout.general.personalinformation.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.accountSwitcherAccessibilityId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint(
opcodes = listOf(
@ -15,10 +15,5 @@ object AccountSwitcherAccessibilityLabelFingerprint : MethodFingerprint(
Opcode.APUT_OBJECT,
Opcode.CONST
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any { it ->
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.accountSwitcherAccessibilityLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(accountSwitcherAccessibilityId) }
)

View File

@ -25,16 +25,14 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class HideEmailAddressPatch : BytecodePatch(
listOf(
AccountSwitcherAccessibilityLabelFingerprint
)
listOf(AccountSwitcherAccessibilityLabelFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
AccountSwitcherAccessibilityLabelFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex - 2) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(insertIndex - 2).registerA
addInstructions(
insertIndex, """
@ -45,7 +43,7 @@ class HideEmailAddressPatch : BytecodePatch(
}
} ?: return AccountSwitcherAccessibilityLabelFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.general.searchterms.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.searchSuggestionEntryId
import app.revanced.util.bytecode.isWideLiteralExists
object SearchSuggestionEntryFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.searchSuggestionEntryLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(searchSuggestionEntryId) }
)

View File

@ -16,10 +16,11 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.searchterms.fingerprints.*
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.searchSuggestionEntryId
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Patch
@Name("hide-search-terms")
@ -42,9 +43,9 @@ class SearchTermsPatch : BytecodePatch(
SearchEndpointParentFingerprint.result?.let { parentResult ->
SearchEndpointFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex + 1
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
val targetRegister = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
@ -54,27 +55,22 @@ class SearchTermsPatch : BytecodePatch(
} ?: return SearchEndpointFingerprint.toErrorResult()
} ?: return SearchEndpointParentFingerprint.toErrorResult()
SearchSuggestionEntryFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val targetIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.searchSuggestionEntryLabelId
} + 2
SearchSuggestionEntryFingerprint.result?.mutableMethod?.let {
val targetIndex = it.getWideLiteralIndex(searchSuggestionEntryId) + 2
val targetRegister = it.instruction<OneRegisterInstruction>(targetIndex).registerA
val targetRegister = (elementAt(targetIndex) as OneRegisterInstruction).registerA
method.addInstruction(
it.addInstruction(
targetIndex + 4,
"invoke-static {v$targetRegister}, $GENERAL->hideSearchTerms(Landroid/view/View;)V"
)
method.addInstruction(
it.addInstruction(
targetIndex + 2,
"invoke-static {v$targetRegister}, $GENERAL->hideSearchTerms(Landroid/view/View;)V"
)
}
} ?: return SearchSuggestionEntryFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -25,9 +25,7 @@ import app.revanced.util.integrations.Constants.GENERAL
@YouTubeCompatibility
@Version("0.0.1")
class HideSnackBarPatch : BytecodePatch(
listOf(
HideSnackBarFingerprint
)
listOf(HideSnackBarFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -42,7 +40,7 @@ class HideSnackBarPatch : BytecodePatch(
)
} ?: return HideSnackBarFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -2,18 +2,12 @@ package app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.floatyBarTopMarginId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.floatyBarTopMarginLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(floatyBarTopMarginId) }
)

View File

@ -7,6 +7,7 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
@ -19,9 +20,9 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.general.tabletminiplayer.fingerprints.*
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getStringIndex
import app.revanced.util.integrations.Constants.GENERAL
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@ -52,21 +53,17 @@ class TabletMiniPlayerPatch : BytecodePatch(
} ?: return MiniPlayerDimensionsCalculatorFingerprint.toErrorResult()
MiniPlayerOverrideFingerprint.result?.let {
val targetIndex = it.mutableMethod.implementation!!.instructions.indexOfFirst { instruction ->
instruction.opcode == Opcode.CONST_STRING &&
(instruction as BuilderInstruction21c).reference.toString() == "appName"
} + 2
(context.toMethodWalker(it.method)
.nextMethod(targetIndex, true)
it.mutableMethod.apply {
(context.toMethodWalker(this)
.nextMethod(getStringIndex("appName") + 2, true)
.getMethod() as MutableMethod)
.instructionProxyCall()
}
} ?: return MiniPlayerOverrideFingerprint.toErrorResult()
MiniPlayerResponseModelSizeCheckFingerprint.result?.let {
val (_, _, _) = it.addProxyCall()
} ?: return MiniPlayerResponseModelSizeCheckFingerprint.toErrorResult()
MiniPlayerResponseModelSizeCheckFingerprint.result?.addProxyCall() ?: return MiniPlayerResponseModelSizeCheckFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -104,7 +101,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
val insertInstructions = this.implementation!!.instructions
for ((index, instruction) in insertInstructions.withIndex()) {
if (instruction.opcode != Opcode.RETURN) continue
val parameterRegister = (instruction as OneRegisterInstruction).registerA
val parameterRegister = this.instruction<OneRegisterInstruction>(index).registerA
this.insertOverride(index, parameterRegister)
this.insertOverride(insertInstructions.size - 1, parameterRegister)
break
@ -114,8 +111,7 @@ class TabletMiniPlayerPatch : BytecodePatch(
fun MethodFingerprintResult.unwrap(): Triple<MutableMethod, Int, Int> {
val scanIndex = this.scanResult.patternScanResult!!.endIndex
val method = this.mutableMethod
val instructions = method.implementation!!.instructions
val parameterRegister = (instructions[scanIndex] as OneRegisterInstruction).registerA
val parameterRegister = method.instruction<OneRegisterInstruction>(scanIndex).registerA
return Triple(method, scanIndex, parameterRegister)
}

View File

@ -54,12 +54,12 @@ class WideSearchbarPatch : BytecodePatch(
.nextMethod(index, true)
.getMethod() as MutableMethod
injectSearchBarHook(targetMethod)
targetMethod.injectSearchBarHook()
} ?: return fingerprint.toErrorResult()
} ?: return parentFingerprint.toErrorResult()
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -74,10 +74,9 @@ class WideSearchbarPatch : BytecodePatch(
return PatchResultSuccess()
}
private fun injectSearchBarHook(method: MutableMethod) {
val index = method.implementation!!.instructions.size - 1
method.addInstructions(
index, """
private fun MutableMethod.injectSearchBarHook() {
addInstructions(
implementation!!.instructions.size - 1, """
invoke-static {}, $GENERAL->enableWideSearchbar()Z
move-result p0
"""

View File

@ -43,8 +43,9 @@ class ChangeHomePagePatch : BytecodePatch(
} ?: return LauncherActivityFingerprint.toErrorResult()
IntentExceptionFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val index = it.scanResult.patternScanResult!!.endIndex + 1
addInstructions(
index, """
invoke-static {}, $NAVIGATION->changeHomePage()Z
@ -56,7 +57,7 @@ class ChangeHomePagePatch : BytecodePatch(
}
} ?: return IntentExceptionFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -26,19 +26,17 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@YouTubeCompatibility
@Version("0.0.1")
class NavigationLabelPatch : BytecodePatch(
listOf(
PivotBarSetTextFingerprint
)
listOf(PivotBarSetTextFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
PivotBarSetTextFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2
val targetReference = (instruction(targetIndex) as ReferenceInstruction).reference.toString()
val targetReference = instruction<ReferenceInstruction>(targetIndex).reference.toString()
if (targetReference != "Landroid/widget/TextView;")
return PivotBarSetTextFingerprint.toErrorResult()
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
val targetRegister = instruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $NAVIGATION->hideNavigationLabel(Landroid/widget/TextView;)V"

View File

@ -92,13 +92,13 @@ class NavigationButtonsPatch : BytecodePatch(
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
/*
/**
* Switch create button with notifications button
*/
AutoMotiveFingerprint.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex, """

View File

@ -44,10 +44,9 @@ class ShortsNavBarPatch : BytecodePatch(
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
SetPivotBarFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
with (it.mutableMethod) {
it.mutableMethod.apply {
val startIndex = it.scanResult.patternScanResult!!.startIndex
val instructions = implementation!!.instructions
val register = (instructions[startIndex] as OneRegisterInstruction).registerA
val register = instruction<OneRegisterInstruction>(startIndex).registerA
addInstruction(
startIndex + 1,
@ -58,11 +57,11 @@ class ShortsNavBarPatch : BytecodePatch(
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
ReelWatchBundleFingerprint.result?.let {
with (context
(context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.endIndex, true)
.getMethod() as MutableMethod
) {
).apply {
addInstruction(
0,
"invoke-static {}, $NAVIGATION->hideShortsPlayerNavBar()V"
@ -88,7 +87,7 @@ class ShortsNavBarPatch : BytecodePatch(
}.forEach { instruction ->
val insertIndex = indexOf(instruction) + 4
val targetRegister =
(navigationEndpointMethod.instruction(insertIndex) as OneRegisterInstruction).registerA
navigationEndpointMethod.instruction<OneRegisterInstruction>(insertIndex).registerA
navigationEndpointMethod.addInstructions(
insertIndex,
@ -102,7 +101,7 @@ class ShortsNavBarPatch : BytecodePatch(
} ?: return NavigationEndpointFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -9,6 +9,5 @@ object PivotBarChangedFingerprint : MethodFingerprint(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT
),
customFingerprint = { it.definingClass.endsWith("PivotBar;")
&& it.name == "onConfigurationChanged" }
customFingerprint = { it.definingClass.endsWith("PivotBar;") && it.name == "onConfigurationChanged" }
)

View File

@ -40,7 +40,7 @@ class TabletNavigationBarPatch : BytecodePatch(
it.result?.insertHook() ?: return it.toErrorResult()
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(
@ -57,7 +57,7 @@ class TabletNavigationBarPatch : BytecodePatch(
companion object {
private fun MethodFingerprintResult.insertHook() {
val targetIndex = this.scanResult.patternScanResult!!.startIndex + 1
val register = (mutableMethod.instruction(targetIndex) as OneRegisterInstruction).registerA
val register = mutableMethod.instruction<OneRegisterInstruction>(targetIndex).registerA
mutableMethod.addInstructions(
targetIndex + 1, """

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
@ -14,15 +15,15 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.fingerprints.LayoutConstructorFingerprint
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.autoNavPreviewId
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getStringIndex
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.PLAYER
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
import org.jf.dexlib2.iface.reference.MethodReference
@Patch
@ -30,53 +31,39 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Description("Hides the autoplay button in the video player.")
@DependsOn(
[
ResourceMappingPatch::class,
SettingsPatch::class
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class HideAutoplayButtonPatch : BytecodePatch(
listOf(
LayoutConstructorFingerprint
)
listOf(LayoutConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
// resolve the offsets such as ...
val autoNavToggleId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "autonav_toggle"
}.id
LayoutConstructorFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val registerIndex = indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "1.0x"
}
val dummyRegister = (this[registerIndex] as Instruction21c).registerA
LayoutConstructorFingerprint.result?.mutableMethod?.let {
val insertInstruction = it.implementation!!.instructions
// where to insert the branch instructions and ...
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == autoNavToggleId
}
// where to branch away
val branchIndex = this.subList(insertIndex + 1, this.size - 1).indexOfFirst {
((it as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener"
val dummyRegister = it.instruction<OneRegisterInstruction>(it.getStringIndex("1.0x")).registerA
val insertIndex = it.getWideLiteralIndex(autoNavPreviewId)
val branchIndex = insertInstruction.subList(insertIndex + 1, insertInstruction.size - 1).indexOfFirst { instruction ->
((instruction as? ReferenceInstruction)?.reference as? MethodReference)?.name == "addOnLayoutChangeListener"
} + 2
val jumpInstruction = this[insertIndex + branchIndex] as Instruction
val jumpInstruction = it.instruction<Instruction>(insertIndex + branchIndex)
method.addInstructions(
it.addInstructions(
insertIndex, """
invoke-static {}, $PLAYER->hideAutoPlayButton()Z
move-result v$dummyRegister
if-nez v$dummyRegister, :hidden
""", listOf(ExternalLabel("hidden", jumpInstruction))
)
}
} ?: return LayoutConstructorFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -24,14 +24,12 @@ import org.jf.dexlib2.Opcode
@YouTubeCompatibility
@Version("0.0.1")
class HideCaptionsButtonBytecodePatch : BytecodePatch(
listOf(
SubtitleButtonControllerFingerprint
)
listOf(SubtitleButtonControllerFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
SubtitleButtonControllerFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
it.implementation!!.instructions.apply {
for ((index, instruction) in this.withIndex()) {
if (instruction.opcode != Opcode.IGET_BOOLEAN) continue
@ -45,7 +43,7 @@ class HideCaptionsButtonBytecodePatch : BytecodePatch(
}
} ?: return SubtitleButtonControllerFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -38,7 +38,7 @@ class HideCastButtonPatch : BytecodePatch() {
}
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
class HideCollapseButtonPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,8 +1,8 @@
package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutCircleId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutCircleFingerprint : MethodFingerprint(
@ -13,10 +13,5 @@ object LayoutCircleFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.layoutCircle
} == true
}
customFingerprint = { it.isWideLiteralExists(layoutCircleId) }
)

View File

@ -1,8 +1,8 @@
package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutIconId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutIconFingerprint : MethodFingerprint(
@ -13,10 +13,5 @@ object LayoutIconFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.layoutIcon
} == true
}
customFingerprint = { it.isWideLiteralExists(layoutIconId) }
)

View File

@ -1,8 +1,8 @@
package app.revanced.patches.youtube.layout.player.endscreencards.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.layoutVideoId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.Opcode
object LayoutVideoFingerprint : MethodFingerprint(
@ -13,10 +13,5 @@ object LayoutVideoFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.layoutVideo
} == true
}
customFingerprint = { it.isWideLiteralExists(layoutVideoId) }
)

View File

@ -17,7 +17,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.player.endscreencards.fingerprints.*
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("hide-endscreen-cards")
@ -41,8 +41,8 @@ class HideEndscreenCardsPatch : BytecodePatch(
fun MethodFingerprintResult.injectHideCalls() {
val index = this.scanResult.patternScanResult!!.endIndex
with (this.mutableMethod) {
val register = (this.instruction(index) as Instruction21c).registerA
this.mutableMethod.apply {
val register = this.instruction<OneRegisterInstruction>(index).registerA
this.implementation!!.injectHideCall(index + 1, register, "layout/PlayerPatch", "hideEndscreen")
}
}
@ -55,7 +55,7 @@ class HideEndscreenCardsPatch : BytecodePatch(
it.result?.injectHideCalls() ?: return it.toErrorResult()
}
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -40,7 +40,7 @@ class HideInfocardsPatch : BytecodePatch(
) ?: return InfocardsIncognitoFingerprint.toErrorResult()
} ?: return InfocardsIncognitoParentFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -27,7 +27,7 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
class HideLiveChatButtonPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -30,7 +30,7 @@ class HideMusicButtonPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
MusicAppDeeplinkButtonFingerprint.result?.mutableMethod?.let {
with (it.implementation!!.instructions) {
it.implementation!!.instructions.apply {
val jumpInstruction = this[size - 1] as Instruction
it.addInstructions(
0, """
@ -42,7 +42,7 @@ class HideMusicButtonPatch : BytecodePatch(
}
} ?: return MusicAppDeeplinkButtonFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -15,6 +15,7 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.player.playerbuttonbg.fingerprints.HidePlayerButtonFingerprint
import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
@Patch
@Name("hide-player-button-background")
@ -28,18 +29,16 @@ import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
@YouTubeCompatibility
@Version("0.0.1")
class HidePlayerButtonBackgroundPatch : BytecodePatch(
listOf(
HidePlayerButtonFingerprint
)
listOf(HidePlayerButtonFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
HidePlayerButtonFingerprint.result?.mutableMethod?.addInstruction(
0,
"invoke-static { p0 }, Lapp/revanced/integrations/utils/ResourceHelper;->hidePlayerButtonBackground(Landroid/view/View;)V"
"invoke-static { p0 }, $INTEGRATIONS_PATH/utils/ResourceHelper;->hidePlayerButtonBackground(Landroid/view/View;)V"
) ?: return HidePlayerButtonFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -38,7 +38,7 @@ class HidePreviousNextButtonPatch : BytecodePatch(
) ?: return SupportsNextPreviousFingerprint.toErrorResult()
} ?: return ControlsOverlayStyleFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -14,7 +14,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.misc.litho.patch.ByteBufferFilterPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@ -27,7 +27,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@Description("Hide the suggested actions bar inside the player.")
@DependsOn(
[
LithoFilterPatch::class,
ByteBufferFilterPatch::class,
PlayerTypeHookPatch::class,
ResourceMappingPatch::class,
SettingsPatch::class

View File

@ -28,18 +28,16 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
@YouTubeCompatibility
@Version("0.0.1")
class HideChannelWatermarkBytecodePatch : BytecodePatch(
listOf(
HideWatermarkParentFingerprint
)
listOf(HideWatermarkParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
HideWatermarkParentFingerprint.result?.let { parentResult ->
HideWatermarkFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val register = instruction<TwoRegisterInstruction>(insertIndex).registerA
with (it.mutableMethod) {
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
removeInstruction(insertIndex)
addInstructions(
insertIndex, """
@ -51,7 +49,7 @@ class HideChannelWatermarkBytecodePatch : BytecodePatch(
} ?: return HideWatermarkFingerprint.toErrorResult()
} ?: return HideWatermarkParentFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -42,7 +42,7 @@ class HideSeekbarPatch : BytecodePatch() {
""", listOf(ExternalLabel("show_seekbar", insertMethod.instruction(0)))
)
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarColorizedBarPlayedColorDarkId
import app.revanced.util.bytecode.isWideLiteralExists
object SeekbarColorFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.inlineTimeBarColorizedBarPlayedColorDarkId
} == true
}
customFingerprint = { it.isWideLiteralExists(inlineTimeBarColorizedBarPlayedColorDarkId) }
)

View File

@ -18,10 +18,12 @@ import app.revanced.patches.shared.fingerprints.ControlsOverlayStyleFingerprint
import app.revanced.patches.youtube.layout.seekbar.seekbarcolor.bytecode.fingerprints.*
import app.revanced.patches.youtube.misc.litho.patch.LithoThemePatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarColorizedBarPlayedColorDarkId
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.inlineTimeBarPlayedNotHighlightedColorId
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
import app.revanced.util.integrations.Constants.SEEKBAR
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("custom-seekbar-color-bytecode-patch")
@DependsOn(
@ -40,20 +42,9 @@ class SeekbarColorBytecodePatch : BytecodePatch(
)
) {
override fun execute(context: BytecodeContext): PatchResult {
SeekbarColorFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val insertIndex = arrayOf(
SharedResourceIdPatch.inlineTimeBarColorizedBarPlayedColorDarkId,
SharedResourceIdPatch.inlineTimeBarPlayedNotHighlightedColorId
).map { id ->
this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == id
} + 2
}
method.hook(insertIndex[0])
method.hook(insertIndex[1])
}
SeekbarColorFingerprint.result?.mutableMethod?.let {
it.hook(it.getWideLiteralIndex(inlineTimeBarColorizedBarPlayedColorDarkId) + 2)
it.hook(it.getWideLiteralIndex(inlineTimeBarPlayedNotHighlightedColorId) + 2)
} ?: return SeekbarColorFingerprint.toErrorResult()
ControlsOverlayStyleFingerprint.result?.let { parentResult ->
@ -86,7 +77,7 @@ class SeekbarColorBytecodePatch : BytecodePatch(
private companion object {
fun MutableMethod.hook(insertIndex: Int) {
val insertRegister = (instruction(insertIndex) as OneRegisterInstruction).registerA
val insertRegister = instruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex + 1, """

View File

@ -2,9 +2,9 @@ package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.util.bytecode.isNarrowLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
object SeekbarTappingFingerprint : MethodFingerprint(
returnType = "Z",
@ -17,10 +17,5 @@ object SeekbarTappingFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.RETURN
),
customFingerprint = { methodDef ->
methodDef.name == "onTouchEvent"
&& methodDef.implementation!!.instructions.any {
((it as? NarrowLiteralInstruction)?.narrowLiteral == 2147483647)
}
}
customFingerprint = { it.name == "onTouchEvent" && it.isNarrowLiteralExists(2147483647) }
)

View File

@ -2,18 +2,12 @@ package app.revanced.patches.youtube.layout.seekbar.seekbartapping.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.accessibilityProgressTimeId
import app.revanced.util.bytecode.isWideLiteralExists
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object SeekbarTappingParentFingerprint : MethodFingerprint(
returnType = "L",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.accessibilityProgressTimeLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(accessibilityProgressTimeId)}
)

View File

@ -68,9 +68,8 @@ class SeekbarTappingPatch : BytecodePatch(
SeekbarTappingFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
with (it.mutableMethod) {
val instructions = implementation!!.instructions
val register = (instructions[insertIndex - 1] as Instruction35c).registerC
it.mutableMethod.apply {
val register = instruction<Instruction35c>(insertIndex - 1).registerC
val pMethod = tapSeekMethods["P"]!!
val oMethod = tapSeekMethods["O"]!!
@ -87,7 +86,7 @@ class SeekbarTappingPatch : BytecodePatch(
}
} ?: return SeekbarTappingFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -25,9 +25,7 @@ import app.revanced.util.integrations.Constants.SEEKBAR
@YouTubeCompatibility
@Version("0.0.1")
class HideTimeStampPatch : BytecodePatch(
listOf(
TimeCounterFingerprint
)
listOf(TimeCounterFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
@ -42,7 +40,7 @@ class HideTimeStampPatch : BytecodePatch(
)
} ?: return TimeCounterFingerprint.toErrorResult()
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.rightCommentId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsCommentFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.rightCommentLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(rightCommentId) }
)

View File

@ -1,16 +1,10 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerInfoPanelId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsInfoPanelFingerprint : MethodFingerprint(
returnType = "V",
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(reelPlayerInfoPanelId) }
)

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadgeId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsPaidContentFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerBadgeLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(reelPlayerBadgeId) }
)

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelRemixId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsRemixFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelRemixLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(reelRemixId) }
)

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerPausedId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsSubscriptionsFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerPausedLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(reelPlayerPausedId) }
)

View File

@ -1,15 +1,9 @@
package app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerFooterId
import app.revanced.util.bytecode.isWideLiteralExists
object ShortsSubscriptionsTabletParentFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerFooterLabelId
} == true
}
customFingerprint = { it.isWideLiteralExists(reelPlayerFooterId) }
)

View File

@ -5,38 +5,32 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsCommentFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.rightCommentId
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("hide-shorts-comment")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsCommentButtonPatch : BytecodePatch(
listOf(ShortsCommentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsCommentFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.rightCommentLabelId
} + 3
ShortsCommentFingerprint.result?.mutableMethod?.let {
val insertIndex = it.getWideLiteralIndex(rightCommentId) + 3
val insertRegister = it.instruction<OneRegisterInstruction>(insertIndex).registerA
val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA
method.addInstruction(
it.addInstruction(
insertIndex + 1,
"invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerCommentsButton(Landroid/view/View;)V"
)
}
} ?: return ShortsCommentFingerprint.toErrorResult()
return PatchResultSuccess()

View File

@ -11,8 +11,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import app.revanced.patches.youtube.ads.general.bytecode.patch.GeneralAdsBytecodePatch
import app.revanced.patches.youtube.misc.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.ads.general.resource.patch.GeneralAdsPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@ -22,8 +21,7 @@ import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
@Description("Hides other Shorts components.")
@DependsOn(
[
GeneralAdsBytecodePatch::class,
LithoFilterPatch::class,
GeneralAdsPatch::class,
ResourceMappingPatch::class,
SettingsPatch::class,
SharedResourceIdPatch::class,
@ -41,7 +39,7 @@ class ShortsComponentPatch : BytecodePatch() {
context.updatePatchStatus("ShortsComponent")
/*
/**
* Add settings
*/
SettingsPatch.addPreference(

View File

@ -5,40 +5,34 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsInfoPanelFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerInfoPanelId
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("hide-shorts-info-panel")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsInfoPanelPatch : BytecodePatch(
listOf(ShortsInfoPanelFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsInfoPanelFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerInfoPanelLabelId
} + 3
ShortsInfoPanelFingerprint.result?.mutableMethod?.let {
val insertIndex = it.getWideLiteralIndex(reelPlayerInfoPanelId) + 3
val insertRegister = it.instruction<OneRegisterInstruction>(insertIndex).registerA
val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA
method.addInstructions(
it.addInstructions(
insertIndex + 1, """
invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerInfoPanel(Landroid/view/ViewGroup;)Landroid/view/ViewGroup;
move-result-object v$insertRegister
"""
)
}
} ?: return ShortsInfoPanelFingerprint.toErrorResult()
return PatchResultSuccess()

View File

@ -9,40 +9,32 @@ import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsPaidContentFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadge2Id
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelPlayerBadgeId
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("hide-shorts-paid-content")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsPaidContentBannerPatch : BytecodePatch(
listOf(ShortsPaidContentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsPaidContentFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val primaryIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerBadgeLabelId
} + 3
val secondaryIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelPlayerBadge2LabelId
} + 3
ShortsPaidContentFingerprint.result?.mutableMethod?.let {
val primaryIndex = it.getWideLiteralIndex(reelPlayerBadgeId) + 3
val secondaryIndex = it.getWideLiteralIndex(reelPlayerBadge2Id) + 3
if (primaryIndex > secondaryIndex) {
method.insertHook(primaryIndex)
method.insertHook(secondaryIndex)
it.insertHook(primaryIndex)
it.insertHook(secondaryIndex)
} else {
method.insertHook(secondaryIndex)
method.insertHook(primaryIndex)
}
it.insertHook(secondaryIndex)
it.insertHook(primaryIndex)
}
} ?: return ShortsPaidContentFingerprint.toErrorResult()
@ -50,7 +42,8 @@ class ShortsPaidContentBannerPatch : BytecodePatch(
}
private companion object {
fun MutableMethod.insertHook(insertIndex: Int) {
val insertRegister = (instruction(insertIndex) as OneRegisterInstruction).registerA
val insertRegister = instruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex + 1, """
invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerPaidContent(Landroid/view/ViewStub;)Landroid/view/ViewStub;

View File

@ -5,38 +5,32 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.layout.shorts.shortscomponent.fingerprints.ShortsRemixFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch.Companion.reelRemixId
import app.revanced.util.bytecode.getWideLiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("hide-shorts-remix")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class ShortsRemixButtonPatch : BytecodePatch(
listOf(ShortsRemixFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ShortsRemixFingerprint.result?.mutableMethod?.let { method ->
with (method.implementation!!.instructions) {
val insertIndex = this.indexOfFirst {
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.reelRemixLabelId
} - 2
ShortsRemixFingerprint.result?.mutableMethod?.let {
val insertIndex = it.getWideLiteralIndex(reelRemixId) - 2
val insertRegister = it.instruction<OneRegisterInstruction>(insertIndex).registerA
val insertRegister = (elementAt(insertIndex) as OneRegisterInstruction).registerA
method.addInstruction(
it.addInstruction(
insertIndex,
"invoke-static {v$insertRegister}, $SHORTS->hideShortsPlayerRemixButton(Landroid/view/View;)V"
)
}
} ?: return ShortsRemixFingerprint.toErrorResult()
return PatchResultSuccess()

Some files were not shown because too many files have changed in this diff Show More