mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 05:10:20 +02:00
refactor: Disable pip mode in shorts player
(Experimental Flags) setting
This commit is contained in:
parent
c3118199a9
commit
d1f43b6a57
@ -5,13 +5,12 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object PiPParentFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
object DisableShortsPiPFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.NEW_INSTANCE
|
||||
Opcode.IGET_BOOLEAN
|
||||
),
|
||||
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/common/ui/pip/DefaultPipController;" }
|
||||
)
|
@ -1,16 +0,0 @@
|
||||
package app.revanced.patches.youtube.extended.shortspip.bytecode.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 PiPFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.IF_NE,
|
||||
Opcode.CONST_4
|
||||
)
|
||||
)
|
@ -1,15 +0,0 @@
|
||||
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,78 +3,46 @@ 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
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
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.resourceid.patch.SharedResourcdIdPatch
|
||||
import app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints.DisableShortsPiPFingerprint
|
||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||
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
|
||||
import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
|
||||
@Name("disable-shorts-pip-bytecode-patch")
|
||||
@DependsOn(
|
||||
[
|
||||
SharedResourcdIdPatch::class
|
||||
PlayerTypeHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
PiPParentFingerprint,
|
||||
StartVideoInformerFingerprint,
|
||||
ShortsPlayerConstructorFingerprint
|
||||
DisableShortsPiPFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
PiPParentFingerprint.result?.let { result ->
|
||||
val targetIndex = result.scanResult.patternScanResult!!.endIndex
|
||||
val targetTnstuction = result.mutableMethod.instruction(targetIndex)
|
||||
val imageButtonClass =
|
||||
context.findClass((targetTnstuction as BuilderInstruction21c)
|
||||
.reference.toString())!!
|
||||
.mutableClass
|
||||
|
||||
PiPFingerprint.also { it.resolve(context, imageButtonClass) }.result?.let { newResult ->
|
||||
with (newResult.mutableMethod) {
|
||||
val endIndex = newResult.scanResult.patternScanResult!!.endIndex
|
||||
val register = (implementation!!.instructions[endIndex] as OneRegisterInstruction).registerA
|
||||
DisableShortsPiPFingerprint.result?.let {
|
||||
with (it.mutableMethod) {
|
||||
val endIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val register = (implementation!!.instructions[endIndex] as TwoRegisterInstruction).registerA
|
||||
this.addInstructions(
|
||||
endIndex + 1, """
|
||||
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->disableShortsPlayerPiP(Z)Z
|
||||
invoke-static {v$register}, $EXTENDED_PATH/DisableShortsPiPPatch;->disableShortsPlayerPiP(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: 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 DisableShortsPiPFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
private companion object {
|
||||
const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$EXTENDED_PATH/DisableShortsPiPPatch;"
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ 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
|
||||
@ -63,7 +62,6 @@ 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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user