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 repeat
patch (ReVanced#2722)
Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
1 parent
c5928b2
commit 506d49c
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...revanced/patches/music/interaction/permanentrepeat/fingerprints/RepeatTrackFingerprint.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,22 @@ | ||
package app.revanced.patches.music.interaction.permanentrepeat.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 RepeatTrackFingerprint : MethodFingerprint( | ||
"V", | ||
AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
listOf("L", "L"), | ||
listOf( | ||
Opcode.CHECK_CAST, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.IGET_OBJECT, | ||
Opcode.IGET_OBJECT, | ||
Opcode.SGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT, | ||
Opcode.IF_NEZ | ||
) | ||
) |
40 changes: 40 additions & 0 deletions
40
...tlin/app/revanced/patches/music/interaction/permanentrepeat/patch/PermanentRepeatPatch.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,40 @@ | ||
package app.revanced.patches.music.interaction.permanentrepeat.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.addInstructionsWithLabels | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
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.patcher.util.smali.ExternalLabel | ||
import app.revanced.patches.music.annotations.MusicCompatibility | ||
import app.revanced.patches.music.interaction.permanentrepeat.fingerprints.RepeatTrackFingerprint | ||
|
||
@Patch(false) | ||
@Name("Permanent repeat") | ||
@Description("Permanently remember your repeating preference even if the playlist ends or another track is played.") | ||
@MusicCompatibility | ||
class PermanentRepeatPatch : BytecodePatch( | ||
listOf(RepeatTrackFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
RepeatTrackFingerprint.result?.let { | ||
val startIndex = it.scanResult.patternScanResult!!.endIndex | ||
val repeatIndex = startIndex + 3 | ||
|
||
it.mutableMethod.apply { | ||
addInstructionsWithLabels( | ||
startIndex, | ||
"goto :repeat", | ||
ExternalLabel("repeat", getInstruction(repeatIndex)) | ||
) | ||
} | ||
} ?: return RepeatTrackFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |