2022-09-29 23:53:58 +02:00
|
|
|
package app.revanced.patches.youtube.layout.startupshortsreset.patch
|
|
|
|
|
|
|
|
import app.revanced.patcher.annotation.Description
|
|
|
|
import app.revanced.patcher.annotation.Name
|
|
|
|
import app.revanced.patcher.annotation.Version
|
|
|
|
import app.revanced.patcher.data.impl.BytecodeData
|
|
|
|
import app.revanced.patcher.extensions.addInstructions
|
|
|
|
import app.revanced.patcher.patch.PatchResult
|
|
|
|
import app.revanced.patcher.patch.PatchResultSuccess
|
|
|
|
import app.revanced.patcher.patch.annotations.DependsOn
|
|
|
|
import app.revanced.patcher.patch.annotations.Patch
|
|
|
|
import app.revanced.patcher.patch.impl.BytecodePatch
|
|
|
|
import app.revanced.patches.youtube.layout.startupshortsreset.annotations.StartupShortsResetCompatibility
|
2022-10-04 01:40:11 +02:00
|
|
|
import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint
|
2022-09-29 23:53:58 +02:00
|
|
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
|
|
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
|
|
|
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
2022-10-04 07:43:01 +02:00
|
|
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
2022-09-29 23:53:58 +02:00
|
|
|
|
|
|
|
@Patch
|
|
|
|
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
|
|
|
|
@Name("disable-startup-shorts-player")
|
|
|
|
@Description("Disables playing YouTube Shorts when launching YouTube.")
|
|
|
|
@StartupShortsResetCompatibility
|
|
|
|
@Version("0.0.1")
|
|
|
|
class DisableShortsOnStartupPatch : BytecodePatch(
|
|
|
|
listOf(
|
2022-10-04 01:40:11 +02:00
|
|
|
UserWasInShortsFingerprint
|
2022-09-29 23:53:58 +02:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
override fun execute(data: BytecodeData): PatchResult {
|
|
|
|
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
|
|
|
SwitchPreference(
|
|
|
|
"revanced_startup_shorts_player_enabled",
|
|
|
|
StringResource("revanced_startup_shorts_player_title", "Disable shorts player at app startup"),
|
|
|
|
false,
|
|
|
|
StringResource("revanced_startup_shorts_player_summary_on", "Shorts player is disabled at app startup"),
|
|
|
|
StringResource("revanced_startup_shorts_player_summary_off", "Shorts player is enabled at app startup")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-10-04 07:43:01 +02:00
|
|
|
val userWasInShortsResult = UserWasInShortsFingerprint.result!!
|
|
|
|
val userWasInShortsMethod = userWasInShortsResult.mutableMethod
|
|
|
|
val moveResultIndex = userWasInShortsResult.scanResult.patternScanResult!!.endIndex
|
2022-09-29 23:53:58 +02:00
|
|
|
|
2022-10-04 01:40:11 +02:00
|
|
|
userWasInShortsMethod.addInstructions(
|
2022-10-04 07:43:01 +02:00
|
|
|
moveResultIndex + 1, """
|
2022-09-29 23:53:58 +02:00
|
|
|
invoke-static { }, Lapp/revanced/integrations/patches/DisableStartupShortsPlayerPatch;->disableStartupShortsPlayer()Z
|
2022-10-04 07:43:01 +02:00
|
|
|
move-result v5
|
|
|
|
if-eqz v5, :disable_shorts_player
|
2022-10-04 01:40:11 +02:00
|
|
|
return-void
|
2022-10-04 07:43:01 +02:00
|
|
|
:disable_shorts_player
|
2022-09-29 23:53:58 +02:00
|
|
|
nop
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
return PatchResultSuccess()
|
|
|
|
}
|
|
|
|
}
|