mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat: hide-cast-button
patch
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.layout.castbutton.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf()
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class CastButtonCompatibility
|
@ -0,0 +1,44 @@
|
||||
package app.revanced.patches.youtube.layout.castbutton.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.implementation.BytecodeData
|
||||
import app.revanced.patcher.data.implementation.proxy
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.annotations.Dependencies
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patcher.util.smali.toInstructions
|
||||
import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
|
||||
@Patch
|
||||
@Dependencies(dependencies = [IntegrationsPatch::class])
|
||||
@Name("hide-cast-button")
|
||||
@Description("Patch to hide the cast button.")
|
||||
@CastButtonCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideCastButtonPatch : BytecodePatch(listOf()) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
data.classes.forEach { classDef ->
|
||||
classDef.methods.forEach { method ->
|
||||
if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") {
|
||||
val implementation =
|
||||
data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }.implementation!!
|
||||
|
||||
implementation.addInstructions(
|
||||
0, """
|
||||
invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I
|
||||
move-result p1
|
||||
""".trimIndent().toInstructions("I", 2, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user