Skip to content

Commit

Permalink
feat(YouTube - Hide layout components): Add option to hide horizontal…
Browse files Browse the repository at this point in the history
… shelves (#2951)

Co-authored-by: oSumAtrIX <[email protected]>
Co-authored-by: LisoUseInAIKyrios <[email protected]>
  • Loading branch information
3 people authored Apr 6, 2024
1 parent abbc372 commit 9ae0650
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,73 +1,13 @@
package app.revanced.patches.youtube.layout.hide.breakingnews

import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.hide.breakingnews.fingerprints.BreakingNewsFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import app.revanced.patches.youtube.layout.hide.general.HideLayoutComponentsPatch

@Patch(
name = "Hide breaking news shelf",
description = "Adds an option to hide the breaking news shelf on the homepage tab.",
dependencies = [
IntegrationsPatch::class,
BreakingNewsResourcePatch::class
],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"18.32.39",
"18.37.36",
"18.38.44",
"18.43.45",
"18.44.41",
"18.45.43",
"18.48.39",
"18.49.37",
"19.01.34",
"19.02.39",
"19.03.36",
"19.04.38",
"19.05.36",
"19.06.39",
"19.07.40",
"19.08.36",
"19.09.37"
]
)
]
)
@Suppress("unused")
@Deprecated("This patch has been merged to HideLayoutComponentsPatch.")
object BreakingNewsPatch : BytecodePatch(
setOf(BreakingNewsFingerprint)
dependencies = setOf(HideLayoutComponentsPatch::class),
) {
override fun execute(context: BytecodeContext) {
BreakingNewsFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
val moveResultIndex = insertIndex - 1

it.mutableMethod.apply {
val breakingNewsViewRegister =
getInstruction<OneRegisterInstruction>(moveResultIndex).registerA

addInstruction(
insertIndex,
"""
invoke-static {v$breakingNewsViewRegister},
Lapp/revanced/integrations/youtube/patches/HideBreakingNewsPatch;
->
hideBreakingNews(Landroid/view/View;)V
"""
)
}

} ?: throw BreakingNewsFingerprint.exception

}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
SettingsPatch::class,
AddResourcesPatch::class,
HideLayoutComponentsResourcePatch::class,
NavigationBarHookPatch::class // Used by Keyword Content filter.
NavigationBarHookPatch::class,
],
compatiblePackages = [
CompatiblePackage(
Expand Down Expand Up @@ -117,6 +117,7 @@ object HideLayoutComponentsPatch : BytecodePatch(
SwitchPreference("revanced_hide_compact_banner"),
SwitchPreference("revanced_hide_feed_survey"),
SwitchPreference("revanced_hide_for_you_shelf"),
SwitchPreference("revanced_hide_horizontal_shelves"),
SwitchPreference("revanced_hide_image_shelf"),
SwitchPreference("revanced_hide_latest_posts_ads"),
SwitchPreference("revanced_hide_mix_playlists"),
Expand All @@ -133,9 +134,9 @@ object HideLayoutComponentsPatch : BytecodePatch(
SwitchPreference("revanced_hide_keyword_content_subscriptions"),
SwitchPreference("revanced_hide_keyword_content_search"),
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
NonInteractivePreference("revanced_hide_keyword_content_about")
)
)
NonInteractivePreference("revanced_hide_keyword_content_about"),
),
),
)

SettingsPatch.PreferenceScreen.GENERAL_LAYOUT.addPreferences(
Expand Down Expand Up @@ -216,7 +217,7 @@ object HideLayoutComponentsPatch : BytecodePatch(
addInstruction(
insertIndex,
"invoke-static { v$viewRegister }, " +
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V"
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideShowMoreButton(Landroid/view/View;)V",
)
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<string name="revanced_hide_channel_watermark_title">Hide channel watermark</string>
<string name="revanced_hide_channel_watermark_summary_on">Watermark is hidden</string>
<string name="revanced_hide_channel_watermark_summary_off">Watermark is shown</string>
<string name="revanced_hide_horizontal_shelves_title">Hide horizontal shelves</string>
<string name="revanced_hide_horizontal_shelves_summary_on">Shelves are hidden such as:\n• Breaking news\n• Continue watching\n• Explore more channels\n• Shopping\n• Watch it Again</string>
<string name="revanced_hide_horizontal_shelves_summary_off">Shelves are shown</string>
<!-- 'Join' should be translated using the same localized wording YouTube displays.
This appears in the video player for certain videos. -->
<string name="revanced_hide_join_membership_button_title">Hide \'Join\' button</string>
Expand Down Expand Up @@ -483,11 +486,6 @@
<string name="revanced_hide_album_cards_summary_on">Album cards are hidden</string>
<string name="revanced_hide_album_cards_summary_off">Album cards are shown</string>
</patch>
<patch id="layout.hide.breakingnews.BreakingNewsResourcePatch">
<string name="revanced_hide_breaking_news_title">Hide breaking news</string>
<string name="revanced_hide_breaking_news_summary_on">Breaking news are hidden</string>
<string name="revanced_hide_breaking_news_summary_off">Breaking news are shown</string>
</patch>
<patch id="layout.hide.comments.CommentsPatch">
<string name="revanced_comments_screen_title">Comments</string>
<string name="revanced_comments_screen_summary">Hide or show comments section components</string>
Expand Down

0 comments on commit 9ae0650

Please sign in to comment.