2023-09-20 05:33:02 +02:00
|
|
|
package app.revanced.patches.youtube.layout.startupshortsreset
|
2022-09-29 23:53:58 +02:00
|
|
|
|
2023-12-02 22:35:13 +01:00
|
|
|
import app.revanced.util.exception
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
2023-06-07 03:46:13 +02:00
|
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
2022-10-05 04:03:10 +02:00
|
|
|
import app.revanced.patcher.patch.BytecodePatch
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|
|
|
import app.revanced.patcher.patch.annotation.Patch
|
2023-02-19 23:54:29 +01:00
|
|
|
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
|
|
|
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
2022-10-04 01:40:11 +02:00
|
|
|
import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint
|
2023-09-20 05:33:02 +02:00
|
|
|
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
2022-09-29 23:53:58 +02:00
|
|
|
|
2023-09-20 05:33:02 +02:00
|
|
|
@Patch(
|
2023-11-17 11:22:02 +01:00
|
|
|
name = "Disable resuming Shorts on startup",
|
2024-01-01 16:30:04 +01:00
|
|
|
description = "Adds an option to disable the Shorts player from resuming on app startup when Shorts were last being watched.",
|
2023-09-20 05:33:02 +02:00
|
|
|
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
|
|
|
compatiblePackages = [
|
|
|
|
CompatiblePackage(
|
|
|
|
"com.google.android.youtube", [
|
2023-09-28 01:28:25 +02:00
|
|
|
"18.32.39",
|
2023-10-08 03:37:42 +02:00
|
|
|
"18.37.36",
|
2023-11-12 16:43:11 +01:00
|
|
|
"18.38.44",
|
2023-11-12 17:01:49 +01:00
|
|
|
"18.43.45",
|
|
|
|
"18.44.41",
|
2024-01-16 19:54:06 +01:00
|
|
|
"18.45.43",
|
|
|
|
"18.48.39",
|
|
|
|
"18.49.37",
|
2024-01-17 21:24:55 +01:00
|
|
|
"19.01.34",
|
2024-01-24 14:19:02 +01:00
|
|
|
"19.02.39",
|
|
|
|
"19.03.35"
|
2023-09-20 05:33:02 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
|
|
|
@Suppress("unused")
|
2023-11-17 11:22:02 +01:00
|
|
|
object DisableResumingShortsOnStartupPatch : BytecodePatch(
|
2023-09-20 05:33:02 +02:00
|
|
|
setOf(UserWasInShortsFingerprint)
|
2022-09-29 23:53:58 +02:00
|
|
|
) {
|
2023-11-17 11:22:02 +01:00
|
|
|
|
|
|
|
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
2024-01-01 16:33:07 +01:00
|
|
|
"Lapp/revanced/integrations/youtube/patches/DisableResumingStartupShortsPlayerPatch;"
|
2023-11-17 11:22:02 +01:00
|
|
|
|
2023-08-27 21:40:49 +02:00
|
|
|
override fun execute(context: BytecodeContext) {
|
2022-09-29 23:53:58 +02:00
|
|
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
|
|
SwitchPreference(
|
2023-05-15 09:51:43 +02:00
|
|
|
"revanced_disable_resuming_shorts_player",
|
2023-11-17 11:22:02 +01:00
|
|
|
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")
|
2022-09-29 23:53:58 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-11-17 11:22:02 +01:00
|
|
|
UserWasInShortsFingerprint.result?.apply {
|
|
|
|
val moveResultIndex = scanResult.patternScanResult!!.endIndex
|
2022-09-29 23:53:58 +02:00
|
|
|
|
2023-11-17 11:22:02 +01:00
|
|
|
mutableMethod.addInstructionsWithLabels(
|
|
|
|
moveResultIndex + 1,
|
|
|
|
"""
|
2023-11-17 19:43:13 +01:00
|
|
|
invoke-static { }, $INTEGRATIONS_CLASS_DESCRIPTOR->disableResumingStartupShortsPlayer()Z
|
2023-06-07 03:46:13 +02:00
|
|
|
move-result v5
|
|
|
|
if-eqz v5, :disable_shorts_player
|
|
|
|
return-void
|
|
|
|
:disable_shorts_player
|
|
|
|
nop
|
|
|
|
"""
|
2023-11-17 11:22:02 +01:00
|
|
|
)
|
|
|
|
} ?: throw UserWasInShortsFingerprint.exception
|
2022-09-29 23:53:58 +02:00
|
|
|
}
|
|
|
|
}
|