mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
feat(YouTube): add Disable speed overlay
patch
This commit is contained in:
parent
e75b048328
commit
2a8256aa65
@ -0,0 +1,98 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
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.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.player.speedoverlay.fingerprints.SpeedOverlayFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Disable speed overlay",
|
||||
description = "Disable 'Play at 2x speed' while holding down.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.25.40",
|
||||
"18.27.36",
|
||||
"18.29.38",
|
||||
"18.30.37",
|
||||
"18.31.40",
|
||||
"18.32.39",
|
||||
"18.33.40",
|
||||
"18.34.38",
|
||||
"18.35.36",
|
||||
"18.36.39",
|
||||
"18.37.36",
|
||||
"18.38.44",
|
||||
"18.39.41",
|
||||
"18.40.34",
|
||||
"18.41.39"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object SpeedOverlayPatch : BytecodePatch(
|
||||
setOf(SpeedOverlayFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SpeedOverlayFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
for (index in endIndex downTo 0) {
|
||||
if (getInstruction(index).opcode != Opcode.RETURN_VOID) continue
|
||||
|
||||
val replaceIndex = index + 1
|
||||
|
||||
val replaceReference =
|
||||
getInstruction<ReferenceInstruction>(replaceIndex).reference
|
||||
|
||||
val replaceInstruction = getInstruction<TwoRegisterInstruction>(replaceIndex)
|
||||
val registerA = replaceInstruction.registerA
|
||||
val registerB = replaceInstruction.registerB
|
||||
|
||||
addInstructionsWithLabels(
|
||||
replaceIndex + 1, """
|
||||
invoke-static { }, $PLAYER->disableSpeedOverlay()Z
|
||||
move-result v$registerA
|
||||
if-eqz v$registerA, :show
|
||||
return-void
|
||||
:show
|
||||
iget-object v$registerA, v$registerB, $replaceReference
|
||||
"""
|
||||
)
|
||||
removeInstruction(replaceIndex)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
} ?: throw SpeedOverlayFingerprint.exception
|
||||
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: DISABLE_SPEED_OVERLAY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Disable speed overlay")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package app.revanced.patches.youtube.player.speedoverlay.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object SpeedOverlayFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IF_EQZ,
|
||||
Opcode.GOTO,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.IGET,
|
||||
Opcode.CMPL_FLOAT,
|
||||
Opcode.IF_GEZ,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "run" }
|
||||
)
|
@ -90,6 +90,10 @@
|
||||
<string name="revanced_disable_landscape_mode_title">Disable landscape mode</string>
|
||||
<string name="revanced_disable_quic_protocol_summary">"Disable CronetEngine's QUIC protocol"</string>
|
||||
<string name="revanced_disable_quic_protocol_title">Disable QUIC protocol</string>
|
||||
<string name="revanced_disable_speed_overlay_summary">"Disable 'Playing at 2x speed' while holding down
|
||||
|
||||
Note: Disabling the speed overlay does not restore the 'Slide to seek' behavior of the old layout"</string>
|
||||
<string name="revanced_disable_speed_overlay_title">Disable speed overlay</string>
|
||||
<string name="revanced_disable_startup_shorts_player_summary_off">Shorts player is enabled at app startup</string>
|
||||
<string name="revanced_disable_startup_shorts_player_summary_on">Shorts player is disabled at app startup</string>
|
||||
<string name="revanced_disable_startup_shorts_player_title">Disable shorts player at app startup</string>
|
||||
@ -542,6 +546,7 @@ Known issue: Official headers in search results are hidden"</string>
|
||||
<string name="revanced_hide_suggested_actions_summary_on">Suggested actions hidden</string>
|
||||
<string name="revanced_hide_suggested_actions_title">Hide suggested actions</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_summary">"Hides suggested video overlay to play next
|
||||
|
||||
Known issue: Autoplay does not work"</string>
|
||||
<string name="revanced_hide_suggested_video_overlay_title">Hide suggested video overlay</string>
|
||||
<string name="revanced_hide_suggestions_shelf_summary">"Hides following shelves:
|
||||
|
@ -401,6 +401,7 @@
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player" />
|
||||
<Preference android:title="Custom player overlay opacity" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Disable haptic feedback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Disable speed overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide autoplay button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide captions button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide cast button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
@ -504,6 +505,9 @@
|
||||
<!-- SETTINGS: CUSTOM_PLAYER_OVERLAY_OPACITY
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:hint="100" android:defaultValue="100" android:title="@string/revanced_custom_player_overlay_opacity_title" android:key="revanced_custom_player_overlay_opacity" android:summary="@string/revanced_custom_player_overlay_opacity_summary" android:inputType="number" />SETTINGS: CUSTOM_PLAYER_OVERLAY_OPACITY -->
|
||||
|
||||
<!-- SETTINGS: DISABLE_SPEED_OVERLAY
|
||||
<SwitchPreference android:title="@string/revanced_disable_speed_overlay_title" android:key="revanced_disable_speed_overlay" android:defaultValue="false" android:summary="@string/revanced_disable_speed_overlay_summary" />SETTINGS: DISABLE_SPEED_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: HIDE_AUDIO_TRACK_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_audio_track_button_title" android:key="revanced_hide_audio_track_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_audio_track_button_summary_on" android:summaryOff="@string/revanced_hide_audio_track_button_summary_off" />SETTINGS: HIDE_AUDIO_TRACK_BUTTON -->
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user