forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Merge branch
feat/yt-sleep-timer
to dev
- Loading branch information
1 parent
bd1f336
commit 1a9c126
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n/kotlin/app/revanced/patches/youtube/layout/buttons/player/flyout/SleepTimerMenuPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
] | ||
) | ||
] | ||
) | ||
@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" | ||
) | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...patches/youtube/layout/buttons/player/flyout/fingerprints/SleepTimerFeatureFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
) |
15 changes: 15 additions & 0 deletions
15
...utube/layout/buttons/player/flyout/fingerprints/SleepTimerFlyoutMenuFeatureFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
) |