fix(YouTube - Disable resuming Shorts on startup): Adjust patch name (#3281)

This commit is contained in:
LisoUseInAIKyrios 2023-11-17 12:22:02 +02:00 committed by GitHub
parent 554738d6fe
commit c3329527db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package app.revanced.patches.youtube.layout.startupshortsreset
import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.BytecodePatch
@ -12,8 +13,8 @@ import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@Patch(
name = "Disable Shorts on startup",
description = "Disables playing YouTube Shorts when launching YouTube.",
name = "Disable resuming Shorts on startup",
description = "Disables resuming the Shorts player on app startup if a Short was last opened.",
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
compatiblePackages = [
CompatiblePackage(
@ -33,33 +34,37 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
]
)
@Suppress("unused")
object DisableShortsOnStartupPatch : BytecodePatch(
object DisableResumingShortsOnStartupPatch : BytecodePatch(
setOf(UserWasInShortsFingerprint)
) {
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/patches/DisableResumingStartupShortsPlayerPatch;"
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_disable_resuming_shorts_player",
StringResource("revanced_disable_resuming_shorts_player_title", "Disable Shorts player at app startup"),
StringResource("revanced_disable_resuming_shorts_player_summary_on", "Shorts player is disabled at app startup"),
StringResource("revanced_disable_resuming_shorts_player_summary_off", "Shorts player is enabled at app startup")
StringResource("revanced_disable_resuming_shorts_player_title", "Disable resuming Shorts player"),
StringResource("revanced_disable_resuming_shorts_player_summary_on", "Shorts player will not resume on app startup"),
StringResource("revanced_disable_resuming_shorts_player_summary_off", "Shorts player will resume on app startup")
)
)
val userWasInShortsResult = UserWasInShortsFingerprint.result!!
val userWasInShortsMethod = userWasInShortsResult.mutableMethod
val moveResultIndex = userWasInShortsResult.scanResult.patternScanResult!!.endIndex
UserWasInShortsFingerprint.result?.apply {
val moveResultIndex = scanResult.patternScanResult!!.endIndex
userWasInShortsMethod.addInstructionsWithLabels(
moveResultIndex + 1,
"""
invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z
mutableMethod.addInstructionsWithLabels(
moveResultIndex + 1,
"""
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->disableResumingStartupShortsPlayer()Z
move-result v5
if-eqz v5, :disable_shorts_player
return-void
:disable_shorts_player
nop
"""
)
)
} ?: throw UserWasInShortsFingerprint.exception
}
}