mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 13:20:19 +02:00
add hide-home-button
, hide-subscriptions-button
patch
This commit is contained in:
parent
2ef68b09f6
commit
42365c0bdb
@ -0,0 +1,44 @@
|
||||
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,25 +1,17 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.shortsbutton.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.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.layout.navigation.shortsbutton.fingerprints.PivotBarEnumFingerprint
|
||||
import app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.misc.lastpivottab.patch.LastPivotTabHookPatch
|
||||
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
|
||||
|
||||
@Patch
|
||||
@Name("hide-shorts-button")
|
||||
@ -27,51 +19,14 @@ import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
LastPivotTabHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class ShortsButtonRemoverPatch : BytecodePatch(
|
||||
listOf(PivotBarCreateButtonViewFingerprint)
|
||||
) {
|
||||
class ShortsButtonRemoverPatch : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
|
||||
with (
|
||||
arrayOf(
|
||||
PivotBarEnumFingerprint,
|
||||
PivotBarShortsButtonViewFingerprint
|
||||
).onEach {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.mutableMethod,
|
||||
parentResult.mutableClass
|
||||
)
|
||||
}.map {
|
||||
it.result?.scanResult?.patternScanResult ?: return it.toErrorResult()
|
||||
}
|
||||
) {
|
||||
val enumScanResult = this[0]
|
||||
val buttonViewResult = this[1]
|
||||
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
mapOf(
|
||||
buttonHook to buttonHookInsertIndex,
|
||||
enumHook to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
parentResult.mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
}
|
||||
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
@ -86,15 +41,4 @@ class ShortsButtonRemoverPatch : BytecodePatch(
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
private companion object {
|
||||
const val enumHook =
|
||||
"sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $NAVIGATION" +
|
||||
"->" +
|
||||
"lastPivotTab:Ljava/lang/Enum;"
|
||||
|
||||
const val buttonHook =
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideShortsButton(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
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,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.shortsbutton.fingerprints
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
@ -0,0 +1,78 @@
|
||||
package app.revanced.patches.youtube.misc.lastpivottab.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
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.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.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.util.integrations.Constants.NAVIGATION
|
||||
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
|
||||
@Name("last-pivot-tab-hook")
|
||||
@DependsOn([SharedResourceIdPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class LastPivotTabHookPatch : BytecodePatch(
|
||||
listOf(PivotBarCreateButtonViewFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { parentResult ->
|
||||
with (
|
||||
arrayOf(
|
||||
PivotBarEnumFingerprint,
|
||||
PivotBarShortsButtonViewFingerprint
|
||||
).onEach {
|
||||
it.resolve(
|
||||
context,
|
||||
parentResult.mutableMethod,
|
||||
parentResult.mutableClass
|
||||
)
|
||||
}.map {
|
||||
it.result?.scanResult?.patternScanResult ?: return it.toErrorResult()
|
||||
}
|
||||
) {
|
||||
val enumScanResult = this[0]
|
||||
val buttonViewResult = this[1]
|
||||
|
||||
val enumHookInsertIndex = enumScanResult.startIndex + 2
|
||||
val buttonHookInsertIndex = buttonViewResult.endIndex
|
||||
|
||||
mapOf(
|
||||
buttonHook to buttonHookInsertIndex,
|
||||
enumHook to enumHookInsertIndex
|
||||
).forEach { (hook, insertIndex) ->
|
||||
parentResult.mutableMethod.injectHook(hook, insertIndex)
|
||||
}
|
||||
}
|
||||
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
private companion object {
|
||||
const val enumHook =
|
||||
"sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $NAVIGATION" +
|
||||
"->" +
|
||||
"lastPivotTab:Ljava/lang/Enum;"
|
||||
|
||||
const val buttonHook =
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideNavigationButton(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
@ -279,6 +279,9 @@ Please do not report any issues you encounter while using this feature."</string
|
||||
<string name="revanced_hide_fullscreen_panels_summary_off">Fullscreen panels are shown</string>
|
||||
<string name="revanced_hide_fullscreen_panels_summary_on">Fullscreen panels are hidden</string>
|
||||
<string name="revanced_hide_fullscreen_panels_title">Hide fullscreen panels</string>
|
||||
<string name="revanced_hide_home_button_summary_off">Home button is shown</string>
|
||||
<string name="revanced_hide_home_button_summary_on">Home button is hidden</string>
|
||||
<string name="revanced_hide_home_button_title">Hide home button</string>
|
||||
<string name="revanced_hide_image_shelf_summary_off">Image shelves are shown</string>
|
||||
<string name="revanced_hide_image_shelf_summary_on">Image shelves are hidden</string>
|
||||
<string name="revanced_hide_image_shelf_title">Hide image shelf</string>
|
||||
|
@ -43,6 +43,10 @@
|
||||
<string name="revanced_hide_shorts_player_thanks_button_summary_on">@string/revanced_hide_button_thanks_summary_on</string>
|
||||
<string name="revanced_hide_shorts_player_thanks_button_title">@string/revanced_hide_button_thanks_title</string>
|
||||
|
||||
<string name="revanced_hide_subscriptions_button_summary_off">@string/revanced_hide_shorts_player_subscriptions_button_summary_off</string>
|
||||
<string name="revanced_hide_subscriptions_button_summary_on">@string/revanced_hide_shorts_player_subscriptions_button_summary_on</string>
|
||||
<string name="revanced_hide_subscriptions_button_title">@string/revanced_hide_shorts_player_subscriptions_button_title</string>
|
||||
|
||||
<string name="revanced_whitelisting_speed_button">@string/camera_speed_button_label</string>
|
||||
|
||||
<string name="revanced_icons_blue">afn / blue</string>
|
||||
|
@ -320,9 +320,15 @@
|
||||
<!-- SETTINGS: HIDE_CREATE_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_create_button_title" android:key="revanced_hide_create_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_create_button_summary_on" android:summaryOff="@string/revanced_hide_create_button_summary_off" />SETTINGS: HIDE_CREATE_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_HOME_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_home_button_title" android:key="revanced_hide_home_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_home_button_summary_on" android:summaryOff="@string/revanced_hide_home_button_summary_off" />SETTINGS: HIDE_HOME_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_SHORTS_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_shorts_button_title" android:key="revanced_hide_shorts_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shorts_button_summary_on" android:summaryOff="@string/revanced_hide_shorts_button_summary_off" />SETTINGS: HIDE_SHORTS_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_SUBSCRIPTIONS_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_subscriptions_button_title" android:key="revanced_hide_subscriptions_button" android:defaultValue="false" android:summaryOn="@string/revanced_hide_subscriptions_button_summary_on" android:summaryOff="@string/revanced_hide_subscriptions_button_summary_off" />SETTINGS: HIDE_SUBSCRIPTIONS_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_SHORTS_NAVIGATION_BAR
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_experimental_flag" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />SETTINGS: HIDE_SHORTS_NAVIGATION_BAR -->
|
||||
@ -515,7 +521,9 @@
|
||||
<Preference android:title="enable-tablet-navigation-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="switch-create-notification" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-create-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-home-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-shorts-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-subscriptions-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-shorts-navbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_seekbar" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user