mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 15:14:34 +02:00
refactor: Disable pip mode in shorts player
(Experimental Flags)
This commit is contained in:
parent
63c214823e
commit
f19f5db17e
@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ShortsPlayerConstructorFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.reelPlayerBadgeId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -3,6 +3,7 @@ package app.revanced.patches.youtube.extended.shortspip.bytecode.patch
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
@ -11,9 +12,10 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints.*
|
||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.fingerprints.StartVideoInformerFingerprint
|
||||
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -21,14 +23,16 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@Name("disable-shorts-pip-bytecode-patch")
|
||||
@DependsOn(
|
||||
[
|
||||
PlayerTypeHookPatch::class
|
||||
SharedResourcdIdPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
PiPParentFingerprint
|
||||
PiPParentFingerprint,
|
||||
StartVideoInformerFingerprint,
|
||||
ShortsPlayerConstructorFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
@ -47,7 +51,7 @@ class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||
val register = (implementation!!.instructions[endIndex] as OneRegisterInstruction).registerA
|
||||
this.addInstructions(
|
||||
endIndex + 1, """
|
||||
invoke-static {v$register}, $EXTENDED_PATH/DisableShortsPiPPatch;->disableShortsPlayerPiP(Z)Z
|
||||
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableShortsPlayerPiP(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
@ -55,6 +59,22 @@ class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||
} ?: return PiPFingerprint.toErrorResult()
|
||||
} ?: return PiPParentFingerprint.toErrorResult()
|
||||
|
||||
arrayOf(
|
||||
StartVideoInformerFingerprint to "generalPlayer",
|
||||
ShortsPlayerConstructorFingerprint to "shortsPlayer"
|
||||
).map { (fingerprint, descriptor) ->
|
||||
with(fingerprint.result ?: return fingerprint.toErrorResult()) {
|
||||
mutableMethod.addInstruction(
|
||||
0,
|
||||
"invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->$descriptor()V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$EXTENDED_PATH/DisableShortsPiPPatch;"
|
||||
}
|
||||
}
|
@ -10,10 +10,11 @@ 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.layout.general.autocaptions.bytecode.fingerprints.*
|
||||
import app.revanced.patches.youtube.layout.general.autocaptions.bytecode.fingerprints.SubtitleTrackFingerprint
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import app.revanced.shared.fingerprints.SubtitleButtonControllerFingerprint
|
||||
import app.revanced.shared.fingerprints.StartVideoInformerFingerprint
|
||||
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||
|
||||
@Name("hide-auto-captions-bytecode-patch")
|
||||
|
@ -33,6 +33,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
||||
var layoutIcon: Long = -1
|
||||
var layoutVideo: Long = -1
|
||||
var liveChatButtonId: Long = -1
|
||||
var reelPlayerBadgeId: Long = -1
|
||||
var scrubbingLabelId: Long = -1
|
||||
var timebarColorLabelId: Long = -1
|
||||
var tooltipLabelId: Long = -1
|
||||
@ -62,6 +63,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
||||
layoutIcon = findSharedResourceId("layout", "endscreen_element_layout_icon")
|
||||
layoutVideo = findSharedResourceId("layout", "endscreen_element_layout_video")
|
||||
liveChatButtonId = findSharedResourceId("id", "live_chat_overlay_button")
|
||||
reelPlayerBadgeId = findSharedResourceId("id", "reel_player_badge2")
|
||||
scrubbingLabelId = findSharedResourceId("dimen", "vertical_touch_offset_to_enter_fine_scrubbing")
|
||||
timebarColorLabelId = findSharedResourceId("color", "inline_time_bar_progress_color")
|
||||
tooltipLabelId = findSharedResourceId("layout", "tooltip_content_view")
|
||||
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.layout.general.autocaptions.bytecode.fingerprints
|
||||
package app.revanced.shared.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
@ -10,7 +10,7 @@ object StartVideoInformerFingerprint : MethodFingerprint(
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.RETURN_VOID,
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
strings = listOf("pc")
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user