mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
add hide-category-bar
patch
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
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 org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
object FilterBarHeightFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IPUT
|
||||
),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.filterBarHeightLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -0,0 +1,20 @@
|
||||
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 org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
object RelatedChipCloudFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
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
|
||||
}
|
||||
)
|
@ -0,0 +1,91 @@
|
||||
package app.revanced.patches.youtube.layout.general.categorybar.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.addInstruction
|
||||
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.general.categorybar.fingerprints.FilterBarHeightFingerprint
|
||||
import app.revanced.patches.youtube.layout.general.categorybar.fingerprints.RelatedChipCloudFingerprint
|
||||
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.GENERAL_LAYOUT
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("hide-category-bar")
|
||||
@Description("Hide the category bar at the top of the feed and at the top of related videos.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class CategoryBarPatch : BytecodePatch(
|
||||
listOf(
|
||||
FilterBarHeightFingerprint,
|
||||
RelatedChipCloudFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/**
|
||||
* Category Bar in feed
|
||||
* Home feed and subscriptions feed
|
||||
*/
|
||||
FilterBarHeightFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(insertIndex) as TwoRegisterInstruction).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInFeed(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return FilterBarHeightFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Category Bar in related video
|
||||
*/
|
||||
RelatedChipCloudFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (instruction(insertIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex + 1,
|
||||
"invoke-static {v$register}, $GENERAL_LAYOUT->hideCategoryBarInRelatedVideo(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
} ?: return RelatedChipCloudFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
|
||||
"SETTINGS: HIDE_CATEGORY_BAR"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-category-bar")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var donationCompanionResourceId: Long = -1
|
||||
var emptyColorLabelId: Long = -1
|
||||
var fabLabelId: Long = -1
|
||||
var filterBarHeightLabelId: Long = -1
|
||||
var floatyBarQueueLabelId: Long = -1
|
||||
var imageOnlyTabId: Long = -1
|
||||
var imageWithTextTabId: Long = -1
|
||||
@ -35,6 +36,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var layoutVideo: Long = -1
|
||||
var liveChatButtonId: Long = -1
|
||||
var reelPlayerFooterLabelId: Long = -1
|
||||
var relatedChipCloudMarginLabelId: Long = -1
|
||||
var scrubbingLabelId: Long = -1
|
||||
var timeStampsContainerLabelId: Long = -1
|
||||
var tooltipLabelId: Long = -1
|
||||
@ -58,6 +60,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
donationCompanionResourceId = findSharedResourceId("layout", "donation_companion")
|
||||
emptyColorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
||||
fabLabelId = findSharedResourceId("id", "fab")
|
||||
filterBarHeightLabelId = findSharedResourceId("dimen", "filter_bar_height")
|
||||
floatyBarQueueLabelId = findSharedResourceId("string", "floaty_bar_queue_status")
|
||||
imageOnlyTabId = findSharedResourceId("layout", "image_only_tab")
|
||||
imageWithTextTabId = findSharedResourceId("layout", "image_with_text_tab")
|
||||
@ -66,6 +69,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
layoutVideo = findSharedResourceId("layout", "endscreen_element_layout_video")
|
||||
liveChatButtonId = findSharedResourceId("id", "live_chat_overlay_button")
|
||||
reelPlayerFooterLabelId = findSharedResourceId("layout", "reel_player_dyn_footer_vert_stories3")
|
||||
relatedChipCloudMarginLabelId = findSharedResourceId("layout", "related_chip_cloud_reduced_margins")
|
||||
scrubbingLabelId = findSharedResourceId("dimen", "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
timeStampsContainerLabelId = findSharedResourceId("id", "timestamps_container")
|
||||
tooltipLabelId = findSharedResourceId("layout", "tooltip_content_view")
|
||||
|
@ -298,6 +298,10 @@ Is it ready to submit?"</string>
|
||||
<string name="revanced_hide_cast_button_summary_off">Cast button is shown</string>
|
||||
<string name="revanced_hide_cast_button_summary_on">Cast button is hidden</string>
|
||||
<string name="revanced_hide_cast_button_title">Hide cast button</string>
|
||||
<string name="revanced_hide_category_bar_in_feed_title">Hide category bar in feed</string>
|
||||
<string name="revanced_hide_category_bar_in_related_video_title">Hide category bar in related video</string>
|
||||
<string name="revanced_hide_category_bar_summary_off">Category bar is shown</string>
|
||||
<string name="revanced_hide_category_bar_summary_on">Category bar is hidden</string>
|
||||
<string name="revanced_hide_channel_watermark_summary_off">Channel watermark is shown</string>
|
||||
<string name="revanced_hide_channel_watermark_summary_on">Channel watermark is hidden</string>
|
||||
<string name="revanced_hide_channel_watermark_title">Hide channel watermark</string>
|
||||
@ -381,7 +385,7 @@ Is it ready to submit?"</string>
|
||||
<string name="revanced_hide_menu_stats_for_nerds_title">Hide stats for nerds menu</string>
|
||||
<string name="revanced_hide_menu_watch_in_vr_summary_off">Watch in VR menu is shown</string>
|
||||
<string name="revanced_hide_menu_watch_in_vr_summary_on">Watch in VR menu is hidden</string>
|
||||
<string name="revanced_hide_menu_watch_in_vr_title">Hide Watch in VR menu</string>
|
||||
<string name="revanced_hide_menu_watch_in_vr_title">Hide watch in VR menu</string>
|
||||
<string name="revanced_hide_mix_playlists_summary_off">Mix playlist is shown</string>
|
||||
<string name="revanced_hide_mix_playlists_summary_on">Mix playlist is hidden</string>
|
||||
<string name="revanced_hide_mix_playlists_title">Hide mix playlist</string>
|
||||
|
@ -116,6 +116,10 @@
|
||||
<!-- SETTINGS: HIDE_FLOATING_MICROPHONE
|
||||
<SwitchPreference android:title="@string/revanced_hide_floating_microphone_title" android:key="revanced_hide_floating_microphone" android:defaultValue="true" android:summaryOn="@string/revanced_hide_floating_microphone_summary_on" android:summaryOff="@string/revanced_hide_floating_microphone_summary_off" />SETTINGS: HIDE_FLOATING_MICROPHONE -->
|
||||
|
||||
<!-- SETTINGS: HIDE_CATEGORY_BAR
|
||||
<SwitchPreference android:title="@string/revanced_hide_category_bar_in_feed_title" android:key="revanced_hide_category_bar_in_feed" android:defaultValue="false" android:summaryOn="@string/revanced_hide_category_bar_summary_on" android:summaryOff="@string/revanced_hide_category_bar_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_category_bar_in_related_video_title" android:key="revanced_hide_category_bar_in_related_video" android:defaultValue="false" android:summaryOn="@string/revanced_hide_category_bar_summary_on" android:summaryOff="@string/revanced_hide_category_bar_summary_off" />SETTINGS: HIDE_CATEGORY_BAR -->
|
||||
|
||||
<!-- SETTINGS: HIDE_GENERAL_LAYOUT_ADS
|
||||
<SwitchPreference android:title="@string/revanced_adremover_merchandise_title" android:key="revanced_adremover_merchandise" android:defaultValue="true" android:summaryOn="@string/revanced_adremover_merchandise_summary_on" android:summaryOff="@string/revanced_adremover_merchandise_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_adremover_browse_store_button_title" android:key="revanced_adremover_browse_store_button" android:defaultValue="true" android:summaryOn="@string/revanced_adremover_browse_store_button_summary_on" android:summaryOff="@string/revanced_adremover_browse_store_button_summary_off" />
|
||||
@ -424,6 +428,7 @@
|
||||
<Preference android:title="hide-email-address" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-snackbar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-floating-microphone" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-category-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-account-menu" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="header-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
|
Reference in New Issue
Block a user