Skip to content

Commit

Permalink
feat(youtube): remove-player-button-background patch (#855)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
johnconner122 and oSumAtrIX committed Nov 23, 2022
1 parent 4416a85 commit fa9c291
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.revanced.patches.youtube.layout.playerbuttonbackground.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package

@Compatibility(
[
Package("com.google.android.youtube", arrayOf("17.34.36","17.36.37", "17.36.39", "17.38.36", "17.39.35", "17.40.41", "17.42.35", "17.43.36", "17.45.36"))
]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class PlayerButtonBackgroundCompatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package app.revanced.patches.youtube.layout.playerbuttonbackground.patch

import app.revanced.extensions.doRecursively
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patches.youtube.layout.playerbuttonbackground.annotations.PlayerButtonBackgroundCompatibility
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import org.w3c.dom.Element

@Patch
@DependsOn([FixLocaleConfigErrorPatch::class])
@Name("remove-player-button-background")
@Description("Removes the background from the video player buttons.")
@PlayerButtonBackgroundCompatibility
@Version("0.0.1")
class PlayerButtonBackgroundPatch : ResourcePatch {
private companion object {
const val RESOURCE_FILE_PATH = "res/drawable/player_button_circle_background.xml"
}

override fun execute(context: ResourceContext): PatchResult {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
editor.file.doRecursively node@{ node ->
if (node !is Element) return@node

node.getAttributeNode("android:color")?.let { attribute ->
attribute.textContent = "@android:color/transparent"
}
}
}

return PatchResultSuccess()
}
}

0 comments on commit fa9c291

Please sign in to comment.