mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-29 21:30:19 +02:00
feat(YouTube Music): add Disable dislike redirection
patch
This commit is contained in:
parent
600367bb1c
commit
516741593d
@ -0,0 +1,68 @@
|
|||||||
|
package app.revanced.patches.music.general.redirection
|
||||||
|
|
||||||
|
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.annotation.CompatiblePackage
|
||||||
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
|
import app.revanced.patches.music.general.redirection.fingerprints.DislikeButtonOnClickListenerFingerprint
|
||||||
|
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
|
||||||
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
|
import app.revanced.util.exception
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
@Patch(
|
||||||
|
name = "Disable dislike redirection",
|
||||||
|
description = "Adds an option to disable redirection to the next track when clicking dislike button.",
|
||||||
|
dependencies = [SettingsPatch::class],
|
||||||
|
compatiblePackages = [
|
||||||
|
CompatiblePackage(
|
||||||
|
"com.google.android.apps.youtube.music",
|
||||||
|
[
|
||||||
|
"6.21.52",
|
||||||
|
"6.22.52",
|
||||||
|
"6.23.56",
|
||||||
|
"6.25.53",
|
||||||
|
"6.26.51",
|
||||||
|
"6.27.54",
|
||||||
|
"6.28.53",
|
||||||
|
"6.29.58",
|
||||||
|
"6.31.55",
|
||||||
|
"6.33.52"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
@Suppress("unused")
|
||||||
|
object DislikeRedirectionPatch : BytecodePatch(
|
||||||
|
setOf(DislikeButtonOnClickListenerFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
DislikeButtonOnClickListenerFingerprint.result?.let {
|
||||||
|
it.mutableMethod.apply {
|
||||||
|
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||||
|
val jumpIndex = it.scanResult.patternScanResult!!.endIndex + 1
|
||||||
|
val freeRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
startIndex + 1, """
|
||||||
|
invoke-static {}, $GENERAL->disableDislikeRedirection()Z
|
||||||
|
move-result v$freeRegister
|
||||||
|
if-nez v$freeRegister, :disable
|
||||||
|
""", ExternalLabel("disable", getInstruction(jumpIndex))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: throw DislikeButtonOnClickListenerFingerprint.exception
|
||||||
|
|
||||||
|
SettingsPatch.addMusicPreference(
|
||||||
|
CategoryType.GENERAL,
|
||||||
|
"revanced_disable_dislike_redirection",
|
||||||
|
"false"
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package app.revanced.patches.music.general.redirection.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.util.containsWideLiteralInstructionIndex
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
|
internal object DislikeButtonOnClickListenerFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("Landroid/view/View;"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IF_EQZ,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.IGET_OBJECT,
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_INTERFACE
|
||||||
|
),
|
||||||
|
customFingerprint = handler@{ methodDef, _ ->
|
||||||
|
if (!methodDef.containsWideLiteralInstructionIndex(53465))
|
||||||
|
return@handler false
|
||||||
|
|
||||||
|
methodDef.name == "onClick"
|
||||||
|
}
|
||||||
|
)
|
@ -35,6 +35,8 @@
|
|||||||
<string name="revanced_custom_playback_speeds_warning" formatted="false">Custom speeds can\'t be more than %sx.</string>
|
<string name="revanced_custom_playback_speeds_warning" formatted="false">Custom speeds can\'t be more than %sx.</string>
|
||||||
<string name="revanced_disable_auto_captions_summary">Disables captions from being automatically enabled.</string>
|
<string name="revanced_disable_auto_captions_summary">Disables captions from being automatically enabled.</string>
|
||||||
<string name="revanced_disable_auto_captions_title">Disable forced auto captions</string>
|
<string name="revanced_disable_auto_captions_title">Disable forced auto captions</string>
|
||||||
|
<string name="revanced_disable_dislike_redirection_summary">Disables redirection to the next track when clicking dislike button.</string>
|
||||||
|
<string name="revanced_disable_dislike_redirection_title">Disable dislike redirection</string>
|
||||||
<string name="revanced_downloader_not_installed" formatted="false">%s is not installed. Please install it.</string>
|
<string name="revanced_downloader_not_installed" formatted="false">%s is not installed. Please install it.</string>
|
||||||
<string name="revanced_enable_black_navigation_bar_summary">Sets the navigation bar color to black.</string>
|
<string name="revanced_enable_black_navigation_bar_summary">Sets the navigation bar color to black.</string>
|
||||||
<string name="revanced_enable_black_navigation_bar_title">Enable black navigation bar</string>
|
<string name="revanced_enable_black_navigation_bar_title">Enable black navigation bar</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user