|
1 | 1 | package app.revanced.patches.youtube.misc.playercontrols |
2 | 2 |
|
3 | 3 | import app.revanced.patcher.data.ResourceContext |
4 | | -import app.revanced.patcher.patch.PatchException |
5 | 4 | import app.revanced.patcher.patch.ResourcePatch |
6 | 5 | import app.revanced.patcher.patch.annotation.Patch |
7 | 6 | import app.revanced.patcher.util.DomFileEditor |
@@ -69,29 +68,17 @@ object PlayerControlsResourcePatch : ResourcePatch(), Closeable { |
69 | 68 | resourceContext.xmlEditor[hostingResourceStream], |
70 | 69 | editor, |
71 | 70 | ).use { |
72 | | - val document = editor.file |
73 | | - val children = document.getElementsByTagName("RelativeLayout").item(0).childNodes |
74 | | - |
75 | | - // Replace the startOf with the voting button view so that the button does not overlap |
76 | | - for (index in 1 until children.length) { |
77 | | - val view = children.item(index) |
78 | | - |
79 | | - // FIXME: This uses hard coded values that only works with SponsorBlock. |
80 | | - // If other top buttons are added by other patches, this code must be changed. |
81 | | - if (view.hasAttributes() && view.attributes.getNamedItem("android:id") |
82 | | - .nodeValue.endsWith("live_chat_overlay_button") |
83 | | - ) { |
84 | | - // voting button id from the voting button view from the youtube_controls_layout.xml host file |
85 | | - val votingButtonId = "@+id/revanced_sb_voting_button" |
86 | | - view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = |
87 | | - votingButtonId |
88 | | - |
89 | | - return |
90 | | - } |
91 | | - } |
| 71 | + val element = editor.file.childNodes.findElementByAttributeValueOrThrow( |
| 72 | + "android:id", |
| 73 | + "@id/player_video_heading" |
| 74 | + ) |
| 75 | + |
| 76 | + // FIXME: This uses hard coded values that only works with SponsorBlock. |
| 77 | + // If other top buttons are added by other patches, this code must be changed. |
| 78 | + // voting button id from the voting button view from the youtube_controls_layout.xml host file |
| 79 | + val votingButtonId = "@+id/revanced_sb_voting_button" |
| 80 | + element.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId |
92 | 81 | } |
93 | | - |
94 | | - throw PatchException("Could not find expected xml to modify") |
95 | 82 | } |
96 | 83 |
|
97 | 84 | /** |
|
0 commit comments