mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube/PlayerTypeHook): add hooking on Shorts state (whether Shorts is open or not)
This commit is contained in:
@ -13,17 +13,21 @@ import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
|||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.ActionBarSearchResultsFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.BrowseIdClassFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.BrowseIdClassFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.PlayerTypeFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.ReelWatchPagerFingerprint
|
||||||
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
|
import app.revanced.patches.youtube.utils.playertype.fingerprint.VideoStateFingerprint
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||||
import app.revanced.util.addStaticFieldToIntegration
|
import app.revanced.util.addStaticFieldToIntegration
|
||||||
import app.revanced.util.alsoResolve
|
import app.revanced.util.alsoResolve
|
||||||
import app.revanced.util.findMethodOrThrow
|
import app.revanced.util.findMethodOrThrow
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
|
||||||
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.iface.instruction.FiveRegisterInstruction
|
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.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
@ -33,6 +37,7 @@ object PlayerTypeHookPatch : BytecodePatch(
|
|||||||
ActionBarSearchResultsFingerprint,
|
ActionBarSearchResultsFingerprint,
|
||||||
BrowseIdClassFingerprint,
|
BrowseIdClassFingerprint,
|
||||||
PlayerTypeFingerprint,
|
PlayerTypeFingerprint,
|
||||||
|
ReelWatchPagerFingerprint,
|
||||||
YouTubeControlsOverlayFingerprint
|
YouTubeControlsOverlayFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@ -46,14 +51,28 @@ object PlayerTypeHookPatch : BytecodePatch(
|
|||||||
|
|
||||||
// region patch for set player type
|
// region patch for set player type
|
||||||
|
|
||||||
PlayerTypeFingerprint.resultOrThrow().let {
|
PlayerTypeFingerprint.resultOrThrow().mutableMethod.addInstruction(
|
||||||
it.mutableMethod.apply {
|
0,
|
||||||
addInstruction(
|
"invoke-static {p1}, " +
|
||||||
0,
|
"$INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
|
||||||
"invoke-static {p1}, " +
|
)
|
||||||
"$INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V"
|
|
||||||
)
|
// endregion
|
||||||
|
|
||||||
|
// region patch for set shorts player state
|
||||||
|
|
||||||
|
ReelWatchPagerFingerprint.resultOrThrow().mutableMethod.apply {
|
||||||
|
val literIndex = indexOfFirstWideLiteralInstructionValueOrThrow(ReelWatchPlayer) + 2
|
||||||
|
val registerIndex = indexOfFirstInstructionOrThrow(literIndex) {
|
||||||
|
opcode == Opcode.MOVE_RESULT_OBJECT
|
||||||
}
|
}
|
||||||
|
val viewRegister = getInstruction<OneRegisterInstruction>(registerIndex).registerA
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
registerIndex + 1,
|
||||||
|
"invoke-static {v$viewRegister}, " +
|
||||||
|
"$INTEGRATIONS_PLAYER_TYPE_HOOK_CLASS_DESCRIPTOR->onShortsCreate(Landroid/view/View;)V"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.utils.playertype.fingerprint
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelWatchPlayer
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ReelWatchPagerFingerprint : LiteralValueFingerprint(
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
returnType = "Landroid/view/View;",
|
||||||
|
literalSupplier = { ReelWatchPlayer }
|
||||||
|
)
|
Reference in New Issue
Block a user