diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/fingerprints/BottomSheetMenuItemBuilderFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/fingerprints/BottomSheetMenuItemBuilderFingerprint.kt new file mode 100644 index 000000000..c2baf0ad2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/fingerprints/BottomSheetMenuItemBuilderFingerprint.kt @@ -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") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/patch/FeedFlyoutPanelPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/patch/FeedFlyoutPanelPatch.kt new file mode 100644 index 000000000..53a47d8a7 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/youtube/flyoutpanel/feed/patch/FeedFlyoutPanelPatch.kt @@ -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(targetIndex).registerA + + val targetParameter = getInstruction(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() + } +} diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 0c8e4d908..b0dbcbc5d 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -152,6 +152,7 @@ %s is not installed. Please install it. Settings for using an external downloader External downloader settings + Feed flyout panel Flyout menu Fullscreen General @@ -273,6 +274,10 @@ Expandable chips are shown Expandable chips are hidden Hide expandable chip under videos + Edit feed flyout menus filter + Feed flyout menus are shown + Feed flyout menus are hidden + Hide feed flyout menu Feed surveys are shown Feed surveys are hidden Hide feed surveys diff --git a/src/main/resources/youtube/settings/values-v21/strings.xml b/src/main/resources/youtube/settings/values-v21/strings.xml index 978b46476..354d7b0ce 100644 --- a/src/main/resources/youtube/settings/values-v21/strings.xml +++ b/src/main/resources/youtube/settings/values-v21/strings.xml @@ -10,6 +10,7 @@ ReVanced Extended @string/revanced_custom_filter_strings_summary + @string/revanced_custom_filter_strings_summary @string/revanced_hide_button_thanks_summary_off @string/revanced_hide_button_thanks_summary_on diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 06f922cf5..42aa1eacf 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -60,6 +60,11 @@ + + @@ -277,6 +282,7 @@ +