File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed
src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,14 @@ object HideShortsComponentsPatch : BytecodePatch(
8181 key = " hideShortsAppShortcut" ,
8282 default = false ,
8383 title = " Hide Shorts app shortcut" ,
84- description = " Permanently hides the shortcut to open Shorts from long pressing the app icon in your launcher."
84+ description = " Permanently hides the shortcut to open Shorts when long pressing the app icon in your launcher."
85+ )
86+
87+ internal val hideShortsWidget by booleanPatchOption(
88+ key = " hideShortsWidget" ,
89+ default = false ,
90+ title = " Hide Shorts widget" ,
91+ description = " Permanently hides the launcher widget Shorts button."
8592 )
8693
8794 override fun execute (context : BytecodeContext ) {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch
77import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
88import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
99import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsPatch.hideShortsAppShortcut
10+ import app.revanced.patches.youtube.layout.hide.shorts.HideShortsComponentsPatch.hideShortsWidget
1011import app.revanced.patches.youtube.misc.settings.SettingsPatch
1112import app.revanced.util.findElementByAttributeValueOrThrow
1213import org.w3c.dom.Element
@@ -57,12 +58,21 @@ object HideShortsComponentsResourcePatch : ResourcePatch() {
5758
5859 if (hideShortsAppShortcut == true ) {
5960 context.xmlEditor[" res/xml/main_shortcuts.xml" ].use { editor ->
60- val shortcuts = editor.file.getElementsByTagName(" shortcuts" ).item(0 ) as Element
61- val shortsItem =
62- shortcuts.getElementsByTagName(" shortcut" ).findElementByAttributeValueOrThrow(
63- " android:shortcutId" ,
64- " shorts-shortcut"
65- )
61+ val shortsItem = editor.file.childNodes.findElementByAttributeValueOrThrow(
62+ " android:shortcutId" ,
63+ " shorts-shortcut"
64+ )
65+
66+ shortsItem.parentNode.removeChild(shortsItem)
67+ }
68+ }
69+
70+ if (hideShortsWidget == true ) {
71+ context.xmlEditor[" res/layout/appwidget_two_rows.xml" ].use { editor ->
72+ val shortsItem = editor.file.childNodes.findElementByAttributeValueOrThrow(
73+ " android:id" ,
74+ " @id/button_shorts_container"
75+ )
6676
6777 shortsItem.parentNode.removeChild(shortsItem)
6878 }
You can’t perform that action at this time.
0 commit comments