mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 23:54:33 +02:00
refactor(hide-music-button): apply better patch method
This commit is contained in:
parent
1f95b63b45
commit
0c6a07bf82
@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.player.musicbutton.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object MusicAppDeeplinkButtonFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("Z", "Z"),
|
||||||
|
customFingerprint = { it.definingClass.endsWith("MusicAppDeeplinkButtonController;") }
|
||||||
|
)
|
@ -1,31 +1,46 @@
|
|||||||
package app.revanced.patches.youtube.layout.player.musicbutton.patch
|
package app.revanced.patches.youtube.layout.player.musicbutton.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.ResourceContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.ResourcePatch
|
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.patches.youtube.misc.playerbutton.patch.PlayerButtonPatch
|
import app.revanced.patches.youtube.layout.player.musicbutton.fingerprints.MusicAppDeeplinkButtonFingerprint
|
||||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||||
|
import app.revanced.util.integrations.Constants.PLAYER_LAYOUT
|
||||||
|
import org.jf.dexlib2.iface.instruction.Instruction
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@Name("hide-music-button")
|
@Name("hide-music-button")
|
||||||
@Description("Hides the YouTube Music button in the video player.")
|
@Description("Hides the YouTube Music button in the video player.")
|
||||||
@DependsOn(
|
@DependsOn([SettingsPatch::class])
|
||||||
[
|
|
||||||
PlayerButtonPatch::class,
|
|
||||||
SettingsPatch::class
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class HideMusicButtonPatch : ResourcePatch {
|
class HideMusicButtonPatch : BytecodePatch(
|
||||||
override fun execute(context: ResourceContext): PatchResult {
|
listOf(MusicAppDeeplinkButtonFingerprint)
|
||||||
|
){
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
|
MusicAppDeeplinkButtonFingerprint.result?.mutableMethod?.let {
|
||||||
|
with (it.implementation!!.instructions) {
|
||||||
|
val jumpInstruction = this[size - 1] as Instruction
|
||||||
|
it.addInstructions(
|
||||||
|
0, """
|
||||||
|
invoke-static {}, $PLAYER_LAYOUT->hideMusicButton()Z
|
||||||
|
move-result v0
|
||||||
|
if-nez v0, :hidden
|
||||||
|
""", listOf(ExternalLabel("hidden", jumpInstruction))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return MusicAppDeeplinkButtonFingerprint.toErrorResult()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add settings
|
* Add settings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user