mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(YouTube): Add patch Disable resuming Miniplayer on startup
https://github.com/inotia00/ReVanced_Extended/issues/469
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.youtube.player.miniplayer
|
||||
package app.revanced.patches.youtube.player.miniplayer.general
|
||||
|
||||
import app.revanced.patches.youtube.utils.resourceid.floatyBarTopMargin
|
||||
import app.revanced.patches.youtube.utils.resourceid.miniplayerMaxSize
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.player.miniplayer
|
||||
package app.revanced.patches.youtube.player.miniplayer.general
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
@ -0,0 +1,26 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.youtube.player.miniplayer.startup
|
||||
|
||||
import app.revanced.util.fingerprint.legacyFingerprint
|
||||
import app.revanced.util.or
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
/**
|
||||
* Tested on YouTube 18.25.40 ~ 20.05.44
|
||||
*
|
||||
* This fingerprint is not compatible with YouTube 18.19.36 or earlier
|
||||
*/
|
||||
internal val showMiniplayerCommandFingerprint = legacyFingerprint(
|
||||
name = "showMiniplayerCommandFingerprint",
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "Ljava/util/Map;"),
|
||||
// Opcode pattern looks very weak, but it's not really.
|
||||
opcodes = listOf(
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.IF_EQZ,
|
||||
),
|
||||
literals = listOf(121253L, 164817L),
|
||||
)
|
@ -0,0 +1,55 @@
|
||||
package app.revanced.patches.youtube.player.miniplayer.startup
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.extension.Constants.PLAYER_PATH
|
||||
import app.revanced.patches.youtube.utils.patch.PatchList.DISABLE_RESUMING_MINIPLAYER_ON_STARTUP
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||
import app.revanced.util.fingerprint.matchOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"$PLAYER_PATH/MiniplayerPatch;"
|
||||
|
||||
// YT uses "Miniplayer" without a space between 'mini' and 'player: https://support.google.com/youtube/answer/9162927.
|
||||
@Suppress("unused", "SpellCheckingInspection")
|
||||
val resumingMiniplayerOnStartupPatch = bytecodePatch(
|
||||
DISABLE_RESUMING_MINIPLAYER_ON_STARTUP.title,
|
||||
DISABLE_RESUMING_MINIPLAYER_ON_STARTUP.summary,
|
||||
) {
|
||||
compatibleWith(COMPATIBLE_PACKAGE)
|
||||
|
||||
dependsOn(settingsPatch)
|
||||
|
||||
execute {
|
||||
|
||||
showMiniplayerCommandFingerprint.matchOrThrow().let {
|
||||
it.method.apply {
|
||||
val insertIndex = it.patternMatch!!.endIndex
|
||||
val insertRegister =
|
||||
getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$insertRegister}, $EXTENSION_CLASS_DESCRIPTOR->disableResumingStartupMiniPlayer(Z)Z
|
||||
move-result v$insertRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE_SCREEN: PLAYER",
|
||||
"SETTINGS: MINIPLAYER_COMPONENTS",
|
||||
"SETTINGS: DISABLE_RESUMING_MINIPLAYER"
|
||||
),
|
||||
DISABLE_RESUMING_MINIPLAYER_ON_STARTUP
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -81,6 +81,10 @@ internal enum class PatchList(
|
||||
"Disable haptic feedback",
|
||||
"Adds options to disable haptic feedback when swiping in the video player."
|
||||
),
|
||||
DISABLE_RESUMING_MINIPLAYER_ON_STARTUP(
|
||||
"Disable resuming Miniplayer on startup",
|
||||
"Adds an option to disable the Miniplayer 'Continue watching' from resuming on app startup."
|
||||
),
|
||||
DISABLE_RESUMING_SHORTS_ON_STARTUP(
|
||||
"Disable resuming Shorts on startup",
|
||||
"Adds an option to disable the Shorts player from resuming on app startup when Shorts were last being watched."
|
||||
|
Reference in New Issue
Block a user