mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(youtube/custom-speed-overlay): change patch name hide-speed-overlay
→ custom-speed-overlay
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object SpeedOverlayHookFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(
|
||||
Opcode.CMPL_FLOAT,
|
||||
Opcode.IF_GEZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
),
|
||||
strings = listOf("Failed to easy seek haptics vibrate."),
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "run" }
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object YouTubeTextViewFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(Opcode.INVOKE_SUPER),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/YouTubeTextView;")
|
||||
&& methodDef.name == "setText"
|
||||
}
|
||||
)
|
@ -1,55 +0,0 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayConfigFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide speed overlay")
|
||||
@Description("Hide speed overlay in player.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
class HideSpeedOverlayPatch : BytecodePatch(
|
||||
listOf(SpeedOverlayConfigFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SpeedOverlayConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $PLAYER->hideSpeedOverlay(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayConfigFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: HIDE_SPEED_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-speed-overlay")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.patch
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayConfigFingerprint
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayHookFingerprint
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.YouTubeTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.SpeedOverlayText
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
|
||||
@Patch
|
||||
@Name("Custom speed overlay")
|
||||
@Description("Customize 'Play at 2x speed' while holding down.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
class SpeedOverlayPatch : BytecodePatch(
|
||||
listOf(
|
||||
SpeedOverlayConfigFingerprint,
|
||||
SpeedOverlayHookFingerprint,
|
||||
YouTubeTextViewFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SpeedOverlayConfigFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.size - 1
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableSpeedOverlay(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayConfigFingerprint.exception
|
||||
|
||||
SpeedOverlayHookFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = implementation!!.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CMPL_FLOAT
|
||||
} + 3
|
||||
val insertRegister = getInstruction<Instruction35c>(insertIndex).registerD
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSpeed(F)F
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw SpeedOverlayHookFingerprint.exception
|
||||
|
||||
YouTubeTextViewFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val targetInstruction = getInstruction<Instruction35c>(targetIndex)
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
const v0, $SpeedOverlayText
|
||||
invoke-static {v${targetInstruction.registerC}, v${targetInstruction.registerD}, v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSpeedText(Landroid/widget/TextView;Ljava/lang/CharSequence;I)Ljava/lang/CharSequence;
|
||||
move-result-object v${targetInstruction.registerD}
|
||||
invoke-super {v${targetInstruction.registerC}, v${targetInstruction.registerD}, v${targetInstruction.registerE}}, $targetReference
|
||||
"""
|
||||
)
|
||||
removeInstruction(targetIndex)
|
||||
}
|
||||
} ?: throw YouTubeTextViewFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: CUSTOM_SPEED_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("custom-speed-overlay")
|
||||
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$UTILS_PATH/SpeedOverlayPatch;"
|
||||
}
|
||||
}
|
@ -73,6 +73,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var ScrimOverlay: Long = -1
|
||||
var Scrubbing: Long = -1
|
||||
var SettingsBooleanTimeRangeDialog: Long = -1
|
||||
var SpeedOverlayText: Long = -1
|
||||
var SubtitleMenuSettingsFooterInfo: Long = -1
|
||||
var SuggestedAction: Long = -1
|
||||
var ToolBarPaddingHome: Long = -1
|
||||
@ -154,6 +155,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
ScrimOverlay = find(ID, "scrim_overlay")
|
||||
Scrubbing = find(DIMEN, "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
SettingsBooleanTimeRangeDialog = find(LAYOUT, "setting_boolean_time_range_dialog")
|
||||
SpeedOverlayText = find(ID, "speedmaster_edu_text")
|
||||
SubtitleMenuSettingsFooterInfo = find(STRING, "subtitle_menu_settings_footer_info")
|
||||
SuggestedAction = find(LAYOUT, "suggested_action")
|
||||
ToolBarPaddingHome = find(DIMEN, "toolbar_padding_home_action_up")
|
||||
|
Reference in New Issue
Block a user