Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(YouTube): Remove sleep timer menu restrictions #3637

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,12 @@ public final class app/revanced/patches/youtube/layout/buttons/navigation/Naviga
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/buttons/player/flyout/SleepTimerMenuPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/player/flyout/SleepTimerMenuPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/buttons/player/hide/HidePlayerButtonsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints.SleepTimerFeatureFingerprint
import app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints.SleepTimerFlyoutMenuFeatureFingerprint
import app.revanced.util.resultOrThrow
import app.revanced.util.returnEarly

@Patch(
name = "Remove sleep timer menu restrictions",
description = "Show sleep timer options in player flyout menu.",
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
[
"19.30.39", // Only enable this patch on 19.30+ for now.
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
]
)
]
)
@Suppress("unused")
object SleepTimerMenuPatch : BytecodePatch(
setOf(SleepTimerFeatureFingerprint, SleepTimerFlyoutMenuFeatureFingerprint)
) {
override fun execute(context: BytecodeContext) {
SleepTimerFeatureFingerprint.returnEarly(true)

// Feature is experimental, and this fingerprint may change in the future.
SleepTimerFlyoutMenuFeatureFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex

addInstruction(
targetIndex, "const/4 p1, 0x1"
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

internal object SleepTimerFeatureFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "Z",
parameters = listOf(),
literalSupplier = { 45630421 }
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.revanced.patches.youtube.layout.buttons.player.flyout.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

internal object SleepTimerFlyoutMenuFeatureFingerprint : LiteralValueFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
opcodes = listOf(
Opcode.IPUT_BOOLEAN,
Opcode.RETURN_VOID
),
literalSupplier = { 45640654 }
)
Loading