mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(youtube/overlay-buttons): launch external-downloader
by clicking the offline download button in the video action bar
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object DownloadActionsFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||
parameters = listOf("L", "L", "Z"),
|
||||
opcodes = listOf(Opcode.INVOKE_STATIC),
|
||||
strings = listOf("offline/get_download_action")
|
||||
)
|
@ -0,0 +1,44 @@
|
||||
package app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.fingerprints.DownloadActionsFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
|
||||
@Name("download-button-hook")
|
||||
@Description("Replace download button with external download button.")
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class DownloadButtonHookPatch : BytecodePatch(
|
||||
listOf(DownloadActionsFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
DownloadActionsFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
|
||||
addInstructionsWithLabels(
|
||||
targetIndex, """
|
||||
invoke-static {}, $UTILS_PATH/HookDownloadButtonPatch;->shouldHookDownloadButton()Z
|
||||
move-result v0
|
||||
if-eqz v0, :default
|
||||
invoke-static {}, $UTILS_PATH/HookDownloadButtonPatch;->startDownloadActivity()V
|
||||
return-void
|
||||
""", ExternalLabel("default", getInstruction(targetIndex))
|
||||
)
|
||||
}
|
||||
} ?: return DownloadActionsFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.overlaybutton.alwaysrepeat.patch.AlwaysRepeatPatch
|
||||
import app.revanced.patches.youtube.overlaybutton.downloadbuttonhook.patch.DownloadButtonHookPatch
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.overridespeed.patch.OverrideSpeedHookPatch
|
||||
import app.revanced.patches.youtube.utils.playerbutton.patch.PlayerButtonHookPatch
|
||||
@ -30,6 +31,7 @@ import org.w3c.dom.Element
|
||||
@DependsOn(
|
||||
[
|
||||
AlwaysRepeatPatch::class,
|
||||
DownloadButtonHookPatch::class,
|
||||
OverrideSpeedHookPatch::class,
|
||||
PlayerButtonHookPatch::class,
|
||||
PlayerControlsPatch::class,
|
||||
|
Reference in New Issue
Block a user