forked from ReVanced/revanced-patches-template
-
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(YouTube Music): Add
Permanent Shuffle
patch (ReVanced#2730)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
1 parent
e18a9bc
commit 86a271c
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...nced/patches/music/interaction/permanentshuffle/fingerprints/DisableShuffleFingerprint.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,20 @@ | ||
package app.revanced.patches.music.interaction.permanentshuffle.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
|
||
object DisableShuffleFingerprint : MethodFingerprint( | ||
"V", | ||
AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
listOf(), | ||
listOf( | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.SGET_OBJECT, | ||
Opcode.IPUT_OBJECT, | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL | ||
) | ||
) |
29 changes: 29 additions & 0 deletions
29
...in/app/revanced/patches/music/interaction/permanentshuffle/patch/PermanentShufflePatch.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,29 @@ | ||
package app.revanced.patches.music.interaction.permanentshuffle.patch | ||
|
||
import app.revanced.extensions.toErrorResult | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.music.annotations.MusicCompatibility | ||
import app.revanced.patches.music.interaction.permanentshuffle.fingerprints.DisableShuffleFingerprint | ||
|
||
@Patch(false) | ||
@Name("Permanent shuffle") | ||
@Description("Permanently remember your shuffle preference " + | ||
"even if the playlist ends or another track is played.") | ||
@MusicCompatibility | ||
class PermanentShuffleTogglePatch : BytecodePatch( | ||
listOf(DisableShuffleFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
DisableShuffleFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") | ||
?: return DisableShuffleFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |