feat(youtube): add hide-feed-flyout-panel patch

This commit is contained in:
inotia00 2023-06-28 22:07:39 +09:00
parent f68c663584
commit 196a1acefa
5 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.flyoutpanel.feed.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object BottomSheetMenuItemBuilderFingerprint : MethodFingerprint(
returnType = "L",
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT
),
strings = listOf("ElementTransformer, ElementPresenter and InteractionLogger cannot be null")
)

View File

@ -0,0 +1,66 @@
package app.revanced.patches.youtube.flyoutpanel.feed.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.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.patches.youtube.flyoutpanel.feed.fingerprints.BottomSheetMenuItemBuilderFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.integrations.Constants.FLYOUT_PANEL
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@Patch
@Name("hide-feed-flyout-panel")
@Description("Hides feed flyout panel components.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class FeedFlyoutPanelPatch : BytecodePatch(
listOf(BottomSheetMenuItemBuilderFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
BottomSheetMenuItemBuilderFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
val targetParameter = getInstruction<ReferenceInstruction>(targetIndex - 1).reference
if (!targetParameter.toString().endsWith("Ljava/lang/CharSequence;"))
return PatchResultError("Method signature parameter did not match: $targetParameter")
addInstructions(
targetIndex + 1, """
invoke-static {v$targetRegister}, $FLYOUT_PANEL->hideFeedFlyoutPanel(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
move-result-object v$targetRegister
"""
)
}
} ?: return BottomSheetMenuItemBuilderFingerprint.toErrorResult()
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
"SETTINGS: HIDE_FEED_FLYOUT_PANEL"
)
)
SettingsPatch.updatePatchStatus("hide-feed-flyout-panel")
return PatchResultSuccess()
}
}

View File

@ -152,6 +152,7 @@
<string name="revanced_external_downloader_not_installed_warning" formatted="false">%s is not installed. Please install it.</string>
<string name="revanced_external_downloader_settings_summary">Settings for using an external downloader</string>
<string name="revanced_external_downloader_settings_title">External downloader settings</string>
<string name="revanced_feed_flyout_panel_title">Feed flyout panel</string>
<string name="revanced_flyout_menu">Flyout menu</string>
<string name="revanced_fullscreen">Fullscreen</string>
<string name="revanced_general">General</string>
@ -273,6 +274,10 @@
<string name="revanced_hide_expandable_chip_summary_off">Expandable chips are shown</string>
<string name="revanced_hide_expandable_chip_summary_on">Expandable chips are hidden</string>
<string name="revanced_hide_expandable_chip_title">Hide expandable chip under videos</string>
<string name="revanced_hide_feed_flyout_panel_custom_filter_strings_title">Edit feed flyout menus filter</string>
<string name="revanced_hide_feed_flyout_panel_summary_off">Feed flyout menus are shown</string>
<string name="revanced_hide_feed_flyout_panel_summary_on">Feed flyout menus are hidden</string>
<string name="revanced_hide_feed_flyout_panel_title">Hide feed flyout menu</string>
<string name="revanced_hide_feed_survey_summary_off">Feed surveys are shown</string>
<string name="revanced_hide_feed_survey_summary_on">Feed surveys are hidden</string>
<string name="revanced_hide_feed_survey_title">Hide feed surveys</string>

View File

@ -10,6 +10,7 @@
<string name="revanced_extended_settings_title">ReVanced Extended</string>
<string name="revanced_hide_account_menu_custom_filter_strings_summary">@string/revanced_custom_filter_strings_summary</string>
<string name="revanced_hide_feed_flyout_panel_custom_filter_strings_summary">@string/revanced_custom_filter_strings_summary</string>
<string name="revanced_hide_comments_thanks_button_summary_off">@string/revanced_hide_button_thanks_summary_off</string>
<string name="revanced_hide_comments_thanks_button_summary_on">@string/revanced_hide_button_thanks_summary_on</string>

View File

@ -60,6 +60,11 @@
<!-- PREFERENCE: FLYOUT_PANEL_SETTINGS
<PreferenceScreen android:title="@string/revanced_flyout_menu" android:key="flyout_menu">PREFERENCE: FLYOUT_PANEL_SETTINGS -->
<!-- SETTINGS: HIDE_FEED_FLYOUT_PANEL
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_feed_flyout_panel_title" />
<SwitchPreference android:title="@string/revanced_hide_feed_flyout_panel_title" android:key="revanced_hide_feed_flyout_panel" android:defaultValue="false" android:summaryOn="@string/revanced_hide_feed_flyout_panel_summary_on" android:summaryOff="@string/revanced_hide_feed_flyout_panel_summary_off" />
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:title="@string/revanced_hide_feed_flyout_panel_custom_filter_strings_title" android:key="revanced_hide_feed_flyout_panel_custom_filter_strings" android:summary="@string/revanced_hide_feed_flyout_panel_custom_filter_strings_summary" android:defaultValue="" android:inputType="textMultiLine" />SETTINGS: HIDE_FEED_FLYOUT_PANEL -->
<!-- SETTINGS: PLAYER_FLYOUT_PANEL_HEADER
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player_flyout_panel_title" />SETTINGS: PLAYER_FLYOUT_PANEL_HEADER -->
@ -277,6 +282,7 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_flyout_menu" />
<Preference android:title="enable-old-quality-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-feed-flyout-panel" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="hide-player-flyout-panel" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_fullscreen" />