mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
add disable-shorts-player-pip
patch
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
package app.revanced.patches.youtube.layout.general.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object DisableShortsPiPFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/common/ui/pip/DefaultPipController;" }
|
||||
)
|
@ -0,0 +1,78 @@
|
||||
package app.revanced.patches.youtube.layout.general.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.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.extensions.removeInstruction
|
||||
import app.revanced.patcher.extensions.replaceInstruction
|
||||
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.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.layout.general.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.util.integrations.Constants.GENERAL_LAYOUT
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("disable-shorts-pip-bytecode-patch")
|
||||
@DependsOn(
|
||||
[
|
||||
PlayerTypeHookPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
DisableShortsPiPFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
DisableShortsPiPFingerprint.result?.mutableMethod?.let { method ->
|
||||
|
||||
with (method.implementation!!) {
|
||||
val invokeIndex = this.instructions.indexOfFirst {
|
||||
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
|
||||
((it as? BuilderInstruction35c)?.reference.toString() ==
|
||||
"$REFERENCE_DESCRIPTOR")
|
||||
}
|
||||
val registerA = (method.instruction(invokeIndex + 1) as OneRegisterInstruction).registerA
|
||||
|
||||
val registerC = (method.instruction(invokeIndex) as BuilderInstruction35c).registerC
|
||||
val registerE = (method.instruction(invokeIndex) as BuilderInstruction35c).registerE
|
||||
|
||||
method.addInstructions(
|
||||
invokeIndex + 1,"""
|
||||
invoke-static {}, $GENERAL_LAYOUT->disableShortsPlayerPiP()Z
|
||||
move-result v$registerA
|
||||
if-eqz v$registerA, :pip
|
||||
goto :disablepip
|
||||
:pip
|
||||
invoke-virtual {v${registerC}, v${registerE}}, $REFERENCE_DESCRIPTOR
|
||||
move-result v$registerA
|
||||
""", listOf(ExternalLabel("disablepip", method.instruction(invokeIndex + 1)))
|
||||
)
|
||||
method.removeInstruction(invokeIndex)
|
||||
method.replaceInstruction(
|
||||
invokeIndex + 6, "nop"
|
||||
)
|
||||
|
||||
}
|
||||
} ?: return DisableShortsPiPFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val REFERENCE_DESCRIPTOR =
|
||||
"Landroid/app/Activity;->enterPictureInPictureMode(Landroid/app/PictureInPictureParams;)Z"
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package app.revanced.patches.youtube.layout.general.resource.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patches.youtube.layout.general.bytecode.patch.DisableShortsPiPBytecodePatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.util.resources.ResourceHelper
|
||||
|
||||
@Patch
|
||||
@Name("disable-shorts-player-pip")
|
||||
@Description("Disable PiP mode in YouTube Shorts player.")
|
||||
@DependsOn(
|
||||
[
|
||||
DisableShortsPiPBytecodePatch::class,
|
||||
SettingsPatch::class
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class DisableShortsPiPPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
/*
|
||||
add settings
|
||||
*/
|
||||
ResourceHelper.addSettings4(
|
||||
context,
|
||||
"PREFERENCE_CATEGORY: REVANCED_SETTINGS",
|
||||
"PREFERENCE: LAYOUT_SETTINGS",
|
||||
"PREFERENCE_HEADER: GENERAL",
|
||||
"SETTINGS: SHORTS_COMPONENT.PARENT",
|
||||
"SETTINGS: SHORTS_COMPONENT_PARENT.B",
|
||||
"SETTINGS: DISABLE_SHORTS_PLAYER_PIP"
|
||||
)
|
||||
|
||||
ResourceHelper.patchSuccess(
|
||||
context,
|
||||
"disable-shorts-player-pip"
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user