mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
fix(YouTube/Overlay buttons): various bugs that have not been fixed for a long time
This commit is contained in:
@ -66,8 +66,7 @@ object OverlayButtonsPatch : BaseResourcePatch(
|
|||||||
"ExternalDownload;",
|
"ExternalDownload;",
|
||||||
"SpeedDialog;"
|
"SpeedDialog;"
|
||||||
).forEach { className ->
|
).forEach { className ->
|
||||||
PlayerControlsPatch.initializeControl("$OVERLAY_BUTTONS_PATH/$className")
|
PlayerControlsPatch.hookOverlayButtons("$OVERLAY_BUTTONS_PATH/$className")
|
||||||
PlayerControlsPatch.injectVisibility("$OVERLAY_BUTTONS_PATH/$className")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,41 +2,29 @@ package app.revanced.patches.youtube.player.collapsebutton
|
|||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patches.youtube.utils.fingerprints.PlayerButtonsResourcesFingerprint
|
||||||
import app.revanced.patches.youtube.player.collapsebutton.fingerprints.LiveChatFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.findMutableMethodOf
|
import app.revanced.util.findMutableMethodOf
|
||||||
import app.revanced.util.patch.BaseBytecodePatch
|
import app.revanced.util.patch.BaseBytecodePatch
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
|
|
||||||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object CollapseButtonPatch : BaseBytecodePatch(
|
object CollapseButtonPatch : BaseBytecodePatch(
|
||||||
name = "Hide collapse button",
|
name = "Hide collapse button",
|
||||||
description = "Adds an option to hide the collapse button in the video player.",
|
description = "Adds an option to hide the collapse button in the video player.",
|
||||||
dependencies = setOf(
|
dependencies = setOf(SettingsPatch::class),
|
||||||
SettingsPatch::class,
|
|
||||||
SharedResourceIdPatch::class
|
|
||||||
),
|
|
||||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||||
fingerprints = setOf(LiveChatFingerprint)
|
fingerprints = setOf(PlayerButtonsResourcesFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
LiveChatFingerprint.resultOrThrow().let {
|
PlayerButtonsResourcesFingerprint.resultOrThrow().mutableClass.apply {
|
||||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
for (method in methods) {
|
||||||
val instructions = it.mutableMethod.getInstruction(endIndex)
|
findMutableMethodOf(method).apply {
|
||||||
val imageButtonClass = context
|
|
||||||
.findClass((instructions as BuilderInstruction21c).reference.toString())!!
|
|
||||||
.mutableClass
|
|
||||||
|
|
||||||
for (method in imageButtonClass.methods) {
|
|
||||||
imageButtonClass.findMutableMethodOf(method).apply {
|
|
||||||
var jumpInstruction = true
|
var jumpInstruction = true
|
||||||
|
|
||||||
implementation!!.instructions.forEachIndexed { index, instructions ->
|
implementation!!.instructions.forEachIndexed { index, instructions ->
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.player.collapsebutton.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.LiveChatButton
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object LiveChatFingerprint : LiteralValueFingerprint(
|
|
||||||
opcodes = listOf(Opcode.NEW_INSTANCE),
|
|
||||||
literalSupplier = { LiveChatButton }
|
|
||||||
)
|
|
@ -3,7 +3,7 @@ package app.revanced.patches.youtube.player.previousnextbutton
|
|||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.PlayerControlsVisibilityModelFingerprint
|
import app.revanced.patches.youtube.player.previousnextbutton.fingerprints.PlayerControlsVisibilityModelFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.utils.fingerprints
|
package app.revanced.patches.youtube.player.previousnextbutton.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patches.youtube.seekbar.thumbnailpreview
|
package app.revanced.patches.youtube.seekbar.thumbnailpreview
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.ThumbnailPreviewConfigFingerprint
|
import app.revanced.patches.youtube.seekbar.thumbnailpreview.fingerprints.ThumbnailPreviewConfigFingerprint
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.youtube.utils.integrations.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.youtube.utils.integrations.Constants.SEEKBAR_CLASS_DESCRIPTOR
|
import app.revanced.patches.youtube.utils.integrations.Constants.SEEKBAR_CLASS_DESCRIPTOR
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.utils.fingerprints
|
package app.revanced.patches.youtube.seekbar.thumbnailpreview.fingerprints
|
||||||
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
|
||||||
|
internal object PlayerButtonsResourcesFingerprint : LiteralValueFingerprint(
|
||||||
|
returnType = "I",
|
||||||
|
parameters = listOf("Landroid/content/res/Resources;"),
|
||||||
|
literalSupplier = { 17694721 }
|
||||||
|
)
|
@ -3,214 +3,115 @@ package app.revanced.patches.youtube.utils.playercontrols
|
|||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprintResult
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchException
|
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.PlayerControlsVisibilityModelFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.ThumbnailPreviewConfigFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.BottomControlsInflateFingerprint
|
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.BottomControlsInflateFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.ControlsLayoutInflateFingerprint
|
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.ControlsLayoutInflateFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.FullscreenEngagementSpeedEduVisibleFingerprint
|
import app.revanced.patches.youtube.utils.fingerprints.PlayerButtonsResourcesFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.FullscreenEngagementSpeedEduVisibleToStringFingerprint
|
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerButtonsVisibilityFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsPatchFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
|
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.QuickSeekVisibleFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.SeekEDUVisibleFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.playercontrols.fingerprints.UserScrubbingFingerprint
|
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.util.getStringInstructionIndex
|
|
||||||
import app.revanced.util.getTargetIndexWithReference
|
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
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.TwoRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
|
||||||
|
|
||||||
@Patch(dependencies = [SharedResourceIdPatch::class])
|
@Patch(dependencies = [SharedResourceIdPatch::class])
|
||||||
object PlayerControlsPatch : BytecodePatch(
|
object PlayerControlsPatch : BytecodePatch(
|
||||||
setOf(
|
setOf(
|
||||||
|
PlayerButtonsResourcesFingerprint,
|
||||||
|
PlayerControlsPatchFingerprint,
|
||||||
BottomControlsInflateFingerprint,
|
BottomControlsInflateFingerprint,
|
||||||
ControlsLayoutInflateFingerprint,
|
ControlsLayoutInflateFingerprint,
|
||||||
FullscreenEngagementSpeedEduVisibleToStringFingerprint,
|
|
||||||
PlayerControlsVisibilityModelFingerprint,
|
|
||||||
ThumbnailPreviewConfigFingerprint,
|
|
||||||
YouTubeControlsOverlayFingerprint
|
YouTubeControlsOverlayFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||||
|
"$UTILS_PATH/PlayerControlsPatch;"
|
||||||
|
|
||||||
|
private lateinit var changeVisibilityMethod: MutableMethod
|
||||||
|
private lateinit var initializeOverlayButtonsMethod: MutableMethod
|
||||||
|
private lateinit var initializeSponsorBlockButtonsMethod: MutableMethod
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
val playerControlsVisibilityModelClass =
|
// new method
|
||||||
PlayerControlsVisibilityModelFingerprint.resultOrThrow().mutableClass
|
PlayerButtonsVisibilityFingerprint.resolve(
|
||||||
|
context,
|
||||||
val youTubeControlsOverlayClass =
|
PlayerButtonsResourcesFingerprint.resultOrThrow().mutableClass
|
||||||
YouTubeControlsOverlayFingerprint.resultOrThrow().mutableClass
|
)
|
||||||
|
PlayerButtonsVisibilityFingerprint.resultOrThrow().let {
|
||||||
QuickSeekVisibleFingerprint.resolve(context, playerControlsVisibilityModelClass)
|
|
||||||
SeekEDUVisibleFingerprint.resolve(context, playerControlsVisibilityModelClass)
|
|
||||||
UserScrubbingFingerprint.resolve(context, playerControlsVisibilityModelClass)
|
|
||||||
|
|
||||||
PlayerControlsVisibilityFingerprint.resolve(context, youTubeControlsOverlayClass)
|
|
||||||
|
|
||||||
quickSeekVisibleMutableMethod = QuickSeekVisibleFingerprint.resultOrThrow().mutableMethod
|
|
||||||
|
|
||||||
seekEDUVisibleMutableMethod = SeekEDUVisibleFingerprint.resultOrThrow().mutableMethod
|
|
||||||
|
|
||||||
userScrubbingMutableMethod = UserScrubbingFingerprint.resultOrThrow().mutableMethod
|
|
||||||
|
|
||||||
playerControlsVisibilityMutableMethod = PlayerControlsVisibilityFingerprint.resultOrThrow().mutableMethod
|
|
||||||
|
|
||||||
controlsLayoutInflateResult = ControlsLayoutInflateFingerprint.resultOrThrow()
|
|
||||||
|
|
||||||
inflateResult = BottomControlsInflateFingerprint.resultOrThrow()
|
|
||||||
|
|
||||||
FullscreenEngagementSpeedEduVisibleToStringFingerprint.resultOrThrow().let {
|
|
||||||
FullscreenEngagementSpeedEduVisibleFingerprint.resolve(context, it.classDef)
|
|
||||||
fullscreenEngagementSpeedEduVisibleMutableMethod = FullscreenEngagementSpeedEduVisibleFingerprint.resultOrThrow().mutableMethod
|
|
||||||
|
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
fullscreenEngagementViewVisibleReference =
|
val viewIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||||
findReference(", isFullscreenEngagementViewVisible=")
|
val viewRegister = getInstruction<TwoRegisterInstruction>(viewIndex).registerA
|
||||||
speedEDUVisibleReference = findReference(", isSpeedmasterEDUVisible=")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThumbnailPreviewConfigFingerprint.resultOrThrow().let {
|
|
||||||
it.mutableMethod.apply {
|
|
||||||
bigBoardsVisibilityMutableMethod = this
|
|
||||||
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
0,
|
viewIndex + 1,
|
||||||
"const/4 v0, 0x1"
|
"invoke-static {p1, p2, v$viewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->changeVisibility(ZZLandroid/view/View;)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private lateinit var controlsLayoutInflateResult: MethodFingerprintResult
|
// legacy method
|
||||||
private lateinit var inflateResult: MethodFingerprintResult
|
PlayerControlsVisibilityFingerprint.resolve(
|
||||||
|
context,
|
||||||
|
YouTubeControlsOverlayFingerprint.resultOrThrow().mutableClass
|
||||||
|
)
|
||||||
|
PlayerControlsVisibilityFingerprint.resultOrThrow().mutableMethod.addInstruction(
|
||||||
|
0,
|
||||||
|
"invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->changeVisibility(Z)V"
|
||||||
|
)
|
||||||
|
|
||||||
private lateinit var bigBoardsVisibilityMutableMethod: MutableMethod
|
mapOf(
|
||||||
private lateinit var playerControlsVisibilityMutableMethod: MutableMethod
|
BottomControlsInflateFingerprint to "initializeOverlayButtons",
|
||||||
private lateinit var quickSeekVisibleMutableMethod: MutableMethod
|
ControlsLayoutInflateFingerprint to "initializeSponsorBlockButtons"
|
||||||
private lateinit var seekEDUVisibleMutableMethod: MutableMethod
|
).forEach { (fingerprint, methodName) ->
|
||||||
private lateinit var userScrubbingMutableMethod: MutableMethod
|
fingerprint.resultOrThrow().let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||||
|
val viewRegister = getInstruction<OneRegisterInstruction>(endIndex).registerA
|
||||||
|
|
||||||
private lateinit var fullscreenEngagementSpeedEduVisibleMutableMethod: MutableMethod
|
addInstruction(
|
||||||
private lateinit var fullscreenEngagementViewVisibleReference: Reference
|
endIndex + 1,
|
||||||
private lateinit var speedEDUVisibleReference: Reference
|
"invoke-static {v$viewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V"
|
||||||
|
)
|
||||||
private fun MutableMethod.findReference(targetString: String): Reference {
|
|
||||||
val stringIndex = getStringInstructionIndex(targetString)
|
|
||||||
if (stringIndex > 0) {
|
|
||||||
val appendIndex = getTargetIndexWithReference(
|
|
||||||
stringIndex,
|
|
||||||
"Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;"
|
|
||||||
)
|
|
||||||
if (appendIndex > 0) {
|
|
||||||
val booleanRegister = getInstruction<FiveRegisterInstruction>(appendIndex).registerD
|
|
||||||
|
|
||||||
for (index in appendIndex downTo 0) {
|
|
||||||
val opcode = getInstruction(index).opcode
|
|
||||||
if (opcode != Opcode.IGET_BOOLEAN)
|
|
||||||
continue
|
|
||||||
|
|
||||||
val register = getInstruction<TwoRegisterInstruction>(index).registerA
|
|
||||||
if (register != booleanRegister)
|
|
||||||
continue
|
|
||||||
|
|
||||||
return getInstruction<ReferenceInstruction>(index).reference
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw PatchException("Reference not found: $targetString")
|
PlayerControlsPatchFingerprint.resultOrThrow().let {
|
||||||
}
|
changeVisibilityMethod = it.mutableMethod
|
||||||
|
|
||||||
private fun injectBigBoardsVisibilityCall(descriptor: String) {
|
initializeOverlayButtonsMethod =
|
||||||
bigBoardsVisibilityMutableMethod.addInstruction(
|
it.mutableClass.methods.find { method -> method.name == "initializeOverlayButtons" }!!
|
||||||
1,
|
|
||||||
"invoke-static {v0}, $descriptor->changeVisibilityNegatedImmediate(Z)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun injectFullscreenEngagementSpeedEduViewVisibilityCall(
|
initializeSponsorBlockButtonsMethod =
|
||||||
reference: Reference,
|
it.mutableClass.methods.find { method -> method.name == "initializeSponsorBlockButtons" }!!
|
||||||
descriptor: String
|
|
||||||
) {
|
|
||||||
fullscreenEngagementSpeedEduVisibleMutableMethod.apply {
|
|
||||||
val index = getTargetIndexWithReference(reference.toString())
|
|
||||||
val register = getInstruction<TwoRegisterInstruction>(index).registerA
|
|
||||||
|
|
||||||
addInstruction(
|
|
||||||
index,
|
|
||||||
"invoke-static {v$register}, $descriptor->changeVisibilityNegatedImmediate(Z)V"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MutableMethod.injectVisibilityCall(
|
private fun MutableMethod.initializeHook(classDescriptor: String) =
|
||||||
descriptor: String,
|
|
||||||
fieldName: String
|
|
||||||
) {
|
|
||||||
addInstruction(
|
addInstruction(
|
||||||
0,
|
0,
|
||||||
"invoke-static {p1}, $descriptor->$fieldName(Z)V"
|
"invoke-static {p0}, $classDescriptor->initialize(Landroid/view/View;)V"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun changeVisibilityHook(classDescriptor: String) =
|
||||||
|
changeVisibilityMethod.addInstruction(
|
||||||
|
0,
|
||||||
|
"invoke-static {p0, p1}, $classDescriptor->changeVisibility(ZZ)V"
|
||||||
|
)
|
||||||
|
|
||||||
|
internal fun hookOverlayButtons(classDescriptor: String) {
|
||||||
|
initializeOverlayButtonsMethod.initializeHook(classDescriptor)
|
||||||
|
changeVisibilityHook(classDescriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MethodFingerprintResult.injectCalls(
|
internal fun hookSponsorBlockButtons(classDescriptor: String) {
|
||||||
descriptor: String
|
initializeSponsorBlockButtonsMethod.initializeHook(classDescriptor)
|
||||||
) {
|
changeVisibilityHook(classDescriptor)
|
||||||
mutableMethod.apply {
|
|
||||||
val endIndex = scanResult.patternScanResult!!.endIndex
|
|
||||||
val viewRegister = getInstruction<OneRegisterInstruction>(endIndex).registerA
|
|
||||||
|
|
||||||
addInstruction(
|
|
||||||
endIndex + 1,
|
|
||||||
"invoke-static {v$viewRegister}, $descriptor->initialize(Landroid/view/View;)V"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun injectVisibility(descriptor: String) {
|
|
||||||
playerControlsVisibilityMutableMethod.injectVisibilityCall(
|
|
||||||
descriptor,
|
|
||||||
"changeVisibility"
|
|
||||||
)
|
|
||||||
quickSeekVisibleMutableMethod.injectVisibilityCall(
|
|
||||||
descriptor,
|
|
||||||
"changeVisibilityNegatedImmediate"
|
|
||||||
)
|
|
||||||
seekEDUVisibleMutableMethod.injectVisibilityCall(
|
|
||||||
descriptor,
|
|
||||||
"changeVisibilityNegatedImmediate"
|
|
||||||
)
|
|
||||||
userScrubbingMutableMethod.injectVisibilityCall(
|
|
||||||
descriptor,
|
|
||||||
"changeVisibilityNegatedImmediate"
|
|
||||||
)
|
|
||||||
|
|
||||||
injectBigBoardsVisibilityCall(descriptor)
|
|
||||||
|
|
||||||
injectFullscreenEngagementSpeedEduViewVisibilityCall(
|
|
||||||
fullscreenEngagementViewVisibleReference,
|
|
||||||
descriptor
|
|
||||||
)
|
|
||||||
injectFullscreenEngagementSpeedEduViewVisibilityCall(
|
|
||||||
speedEDUVisibleReference,
|
|
||||||
descriptor
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun initializeSB(descriptor: String) {
|
|
||||||
controlsLayoutInflateResult.injectCalls(descriptor)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun initializeControl(descriptor: String) {
|
|
||||||
inflateResult.injectCalls(descriptor)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.utils.playercontrols.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
|
||||||
|
|
||||||
internal object FullscreenEngagementSpeedEduVisibleToStringFingerprint : MethodFingerprint(
|
|
||||||
returnType = "Ljava/lang/String;",
|
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
|
||||||
strings = listOf(
|
|
||||||
", isSpeedmasterEDUVisible=",
|
|
||||||
", isFullscreenEngagementViewVisible="
|
|
||||||
)
|
|
||||||
)
|
|
@ -5,8 +5,13 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
|
|||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
internal object FullscreenEngagementSpeedEduVisibleFingerprint : MethodFingerprint(
|
internal object PlayerButtonsVisibilityFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
||||||
opcodes = listOf(Opcode.IPUT_BOOLEAN)
|
opcodes = listOf(
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.INVOKE_INTERFACE
|
||||||
|
),
|
||||||
|
parameters = listOf("Z", "Z")
|
||||||
)
|
)
|
@ -0,0 +1,16 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.playercontrols.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object PlayerControlsPatchFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC,
|
||||||
|
parameters = listOf("Z", "Z"),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass == "$UTILS_PATH/PlayerControlsPatch;"
|
||||||
|
&& methodDef.name == "changeVisibility"
|
||||||
|
}
|
||||||
|
)
|
@ -1,11 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.utils.playercontrols.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object QuickSeekVisibleFingerprint : LiteralValueFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("Z"),
|
|
||||||
opcodes = listOf(Opcode.OR_INT_LIT16),
|
|
||||||
literalSupplier = { 128 }
|
|
||||||
)
|
|
@ -1,11 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.utils.playercontrols.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object SeekEDUVisibleFingerprint : LiteralValueFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("Z"),
|
|
||||||
opcodes = listOf(Opcode.OR_INT_LIT8),
|
|
||||||
literalSupplier = { 32 }
|
|
||||||
)
|
|
@ -1,11 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.utils.playercontrols.fingerprints
|
|
||||||
|
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
internal object UserScrubbingFingerprint : LiteralValueFingerprint(
|
|
||||||
returnType = "V",
|
|
||||||
parameters = listOf("Z"),
|
|
||||||
opcodes = listOf(Opcode.OR_INT_LIT8),
|
|
||||||
literalSupplier = { 64 }
|
|
||||||
)
|
|
@ -55,7 +55,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var InlineTimeBarPlayedNotHighlightedColor = -1L
|
var InlineTimeBarPlayedNotHighlightedColor = -1L
|
||||||
var InsetOverlayViewLayout = -1L
|
var InsetOverlayViewLayout = -1L
|
||||||
var InterstitialsContainer = -1L
|
var InterstitialsContainer = -1L
|
||||||
var LiveChatButton = -1L
|
|
||||||
var MenuItemView = -1L
|
var MenuItemView = -1L
|
||||||
var MusicAppDeeplinkButtonView = -1L
|
var MusicAppDeeplinkButtonView = -1L
|
||||||
var PosterArtWidthDefault = -1L
|
var PosterArtWidthDefault = -1L
|
||||||
@ -134,7 +133,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
getId(COLOR, "inline_time_bar_played_not_highlighted_color")
|
getId(COLOR, "inline_time_bar_played_not_highlighted_color")
|
||||||
InsetOverlayViewLayout = getId(ID, "inset_overlay_view_layout")
|
InsetOverlayViewLayout = getId(ID, "inset_overlay_view_layout")
|
||||||
InterstitialsContainer = getId(ID, "interstitials_container")
|
InterstitialsContainer = getId(ID, "interstitials_container")
|
||||||
LiveChatButton = getId(ID, "live_chat_overlay_button")
|
|
||||||
MenuItemView = getId(ID, "menu_item_view")
|
MenuItemView = getId(ID, "menu_item_view")
|
||||||
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
|
MusicAppDeeplinkButtonView = getId(ID, "music_app_deeplink_button_view")
|
||||||
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")
|
PosterArtWidthDefault = getId(DIMEN, "poster_art_width_default")
|
||||||
|
@ -109,8 +109,7 @@ object SponsorBlockBytecodePatch : BytecodePatch(
|
|||||||
|
|
||||||
// Voting & Shield button
|
// Voting & Shield button
|
||||||
arrayOf("CreateSegmentButtonController;", "VotingButtonController;").forEach { className ->
|
arrayOf("CreateSegmentButtonController;", "VotingButtonController;").forEach { className ->
|
||||||
PlayerControlsPatch.initializeSB("$INTEGRATIONS_SPONSOR_BLOCK_UI_PATH/$className")
|
PlayerControlsPatch.hookSponsorBlockButtons("$INTEGRATIONS_SPONSOR_BLOCK_UI_PATH/$className")
|
||||||
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_SPONSOR_BLOCK_UI_PATH/$className")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append timestamp
|
// Append timestamp
|
||||||
|
Reference in New Issue
Block a user