Skip to content

Commit 1928e89

Browse files
author
LisoUseInAIKyrios
authored
fix(YouTube - SponsorBlock): Fade out SB buttons without overlapping other buttons (#3719)
1 parent 35973c7 commit 1928e89

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/PlayerControlsResourcePatch.kt

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package app.revanced.patches.youtube.misc.playercontrols
22

33
import app.revanced.patcher.data.ResourceContext
4-
import app.revanced.patcher.patch.PatchException
54
import app.revanced.patcher.patch.ResourcePatch
65
import app.revanced.patcher.patch.annotation.Patch
76
import app.revanced.patcher.util.DomFileEditor
@@ -69,29 +68,17 @@ object PlayerControlsResourcePatch : ResourcePatch(), Closeable {
6968
resourceContext.xmlEditor[hostingResourceStream],
7069
editor,
7170
).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
9281
}
93-
94-
throw PatchException("Could not find expected xml to modify")
9582
}
9683

9784
/**

src/main/resources/sponsorblock/host/layout/youtube_controls_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_alignParentTop="true"
2323
android:layout_marginTop="2dp"
2424
android:layout_marginEnd="4dp"
25-
android:layout_toStartOf="@+id/player_additional_view_container"
25+
android:layout_toStartOf="@id/music_app_deeplink_button"
2626
android:padding="@dimen/controls_overlay_action_button_padding"
2727
android:src="@drawable/revanced_sb_logo" />
2828
</RelativeLayout>

0 commit comments

Comments
 (0)