add hide-channel-avatar-section patch

This commit is contained in:
inotia00
2023-04-01 17:51:54 +09:00
parent 3a40a4740a
commit 359e6e4dae
5 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,21 @@
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 org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object ChannelListSubMenuFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.CONST,
Opcode.CONST_4,
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
}
)

View File

@ -0,0 +1,66 @@
package app.revanced.patches.youtube.layout.general.channellistsubmenu.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.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.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint
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
@Patch
@Name("hide-channel-avatar-section")
@Description("Hides the channel avatar section of the subscription feed.")
@DependsOn(
[
SettingsPatch::class,
SharedResourceIdPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class ChannelListSubMenuPatch : BytecodePatch(
listOf(
ChannelListSubMenuFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
ChannelListSubMenuFingerprint.result?.let {
with (it.mutableMethod) {
val endIndex = it.scanResult.patternScanResult!!.endIndex
val register = (instruction(endIndex) as OneRegisterInstruction).registerA
addInstruction(
endIndex + 1,
"invoke-static {v$register}, $GENERAL_LAYOUT->hideChannelListSubMenu(Landroid/view/View;)V"
)
}
} ?: return ChannelListSubMenuFingerprint.toErrorResult()
/*
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_LAYOUT_SETTINGS",
"SETTINGS: HIDE_CHANNEL_LIST_SUBMENU"
)
)
SettingsPatch.updatePatchStatus("hide-channel-avatar-section")
return PatchResultSuccess()
}
}

View File

@ -22,6 +22,7 @@ class SharedResourceIdPatch : ResourcePatch {
var backgroundCategoryLabelId: Long = -1
var barContainerHeightLabelId: Long = -1
var bottomUiContainerResourceId: Long = -1
var channelListSubMenuLabelId: Long = -1
var chapterRepeatOnResourceId: Long = -1
var compactLinkLabelId: Long = -1
var controlsLayoutStubResourceId: Long = -1
@ -56,6 +57,7 @@ class SharedResourceIdPatch : ResourcePatch {
backgroundCategoryLabelId = findSharedResourceId("string", "pref_background_and_offline_category")
barContainerHeightLabelId = findSharedResourceId("dimen", "bar_container_height")
bottomUiContainerResourceId = findSharedResourceId("id", "bottom_ui_container_stub")
channelListSubMenuLabelId = findSharedResourceId("layout", "channel_list_sub_menu")
chapterRepeatOnResourceId = findSharedResourceId("string", "chapter_repeat_on")
compactLinkLabelId = findSharedResourceId("layout", "compact_link")
controlsLayoutStubResourceId = findSharedResourceId("id", "controls_layout_stub")

View File

@ -326,6 +326,9 @@ Please do not report any issues you encounter while using this feature."</string
<string name="revanced_hide_category_bar_in_search_results_title">Hide category bar in search results</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_list_submenu_summary_off">Channel avatar section of the subscriptions feed is shown</string>
<string name="revanced_hide_channel_list_submenu_summary_on">Channel avatar section of the subscriptions feed is hidden</string>
<string name="revanced_hide_channel_list_submenu_title">Hide channel avatar section</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>

View File

@ -121,6 +121,9 @@
<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" />
<SwitchPreference android:title="@string/revanced_hide_category_bar_in_search_results_title" android:key="revanced_hide_category_bar_in_search_results" 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_CHANNEL_LIST_SUBMENU
<SwitchPreference android:title="@string/revanced_hide_channel_list_submenu_title" android:key="revanced_hide_channel_list_submenu" android:defaultValue="true" android:summaryOn="@string/revanced_hide_channel_list_submenu_summary_on" android:summaryOff="@string/revanced_hide_channel_list_submenu_summary_off" />SETTINGS: HIDE_CHANNEL_LIST_SUBMENU -->
<!-- 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" />
@ -439,6 +442,7 @@
<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-channel-avatar-section" 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"/>