mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(hide-navigation-buttons): combined hide-create-button
, hide-home-button
, hide-shorts-button
, hide-subscriptions-button
, switch-create-notification
patches into one
This commit is contained in:
@ -1,74 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.createbutton.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
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.NAVIGATION
|
||||
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Patch
|
||||
@Name("hide-create-button")
|
||||
@Description("Hides the create button in the navigation bar.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class CreateButtonRemoverPatch : BytecodePatch(
|
||||
listOf(
|
||||
PivotBarCreateButtonViewFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { result ->
|
||||
with (result.mutableMethod) {
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = result.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_STATIC
|
||||
}
|
||||
}
|
||||
injectHook(hook, insertIndex)
|
||||
}
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_CREATE_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-create-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val hook =
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideCreateButton(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.homebutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
|
||||
@Patch
|
||||
@Name("hide-home-button")
|
||||
@Description("Hides the home button in the navigation bar.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
LastPivotTabHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class HomeButtonRemoverPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_HOME_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-home-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.switchbutton.fingerprints
|
||||
package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.fingerprints
|
||||
package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.fingerprints
|
||||
package app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
@ -1,37 +1,53 @@
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.patch
|
||||
package app.revanced.patches.youtube.layout.navigation.navigationbuttons.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
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.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.fingerprints.PivotBarEnumFingerprint
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.fingerprints.PivotBarShortsButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.layout.navigation.navigationbuttons.fingerprints.*
|
||||
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.NAVIGATION
|
||||
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("last-pivot-tab-hook")
|
||||
@DependsOn([SharedResourceIdPatch::class])
|
||||
@Patch
|
||||
@Name("hide-navigation-buttons")
|
||||
@Description("Adds options to hide or change navigation buttons.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class LastPivotTabHookPatch : BytecodePatch(
|
||||
listOf(PivotBarCreateButtonViewFingerprint)
|
||||
class NavigationButtonsPatch : BytecodePatch(
|
||||
listOf(
|
||||
AutoMotiveFingerprint,
|
||||
PivotBarCreateButtonViewFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
|
||||
|
||||
/**
|
||||
* Home, Shorts, Subscriptions Button
|
||||
*/
|
||||
with (
|
||||
arrayOf(
|
||||
PivotBarEnumFingerprint,
|
||||
@ -60,8 +76,51 @@ class LastPivotTabHookPatch : BytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Button
|
||||
*/
|
||||
with (parentResult.mutableMethod) {
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = parentResult.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_STATIC
|
||||
}
|
||||
}
|
||||
injectHook(createButtonHook, insertIndex)
|
||||
}
|
||||
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Switch create button with notifications button
|
||||
*/
|
||||
AutoMotiveFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$register}, $NAVIGATION->switchCreateNotification(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return AutoMotiveFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_NAVIGATION_BUTTONS"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-navigation-buttons")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
private companion object {
|
||||
@ -74,5 +133,10 @@ class LastPivotTabHookPatch : BytecodePatch(
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideNavigationButton(Landroid/view/View;)V"
|
||||
|
||||
const val createButtonHook =
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideCreateButton(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.shortsbutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
|
||||
@Patch
|
||||
@Name("hide-shorts-button")
|
||||
@Description("Hides the shorts button in the navigation bar.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
LastPivotTabHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class ShortsButtonRemoverPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_SHORTS_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-shorts-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.subscriptionsbutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
|
||||
@Patch
|
||||
@Name("hide-subscriptions-button")
|
||||
@Description("Hides the subscriptions button in the navigation bar.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
LastPivotTabHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class SubscriptionsButtonRemoverPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_SUBSCRIPTIONS_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-subscriptions-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.switchbutton.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
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.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.layout.navigation.switchbutton.fingerprints.AutoMotiveFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.NAVIGATION
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("switch-create-notification")
|
||||
@Description("Switching the create button and notification button.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class SwitchCreateButtonPatch : BytecodePatch(
|
||||
listOf(AutoMotiveFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
AutoMotiveFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$register}, $NAVIGATION->switchCreateNotification(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return AutoMotiveFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: SWITCH_CREATE_NOTIFICATION"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("switch-create-notification")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user