mirror of
https://github.com/revanced/revanced-patches
synced 2024-08-22 23:30:39 +02:00
fix(youtube/hide-layout-components): hide mix playlists
This commit is contained in:
parent
23c95b0940
commit
33a87bd6ea
@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.youtube.layout.hide.general.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object ConvertElementToFlatBufferFingerprint : MethodFingerprint(
|
||||
strings = listOf("Failed to convert Element to Flatbuffers: %s"),
|
||||
opcodes = listOf(Opcode.IGET_OBJECT) // Patched at this opcodes index
|
||||
)
|
@ -1,18 +1,24 @@
|
||||
package app.revanced.patches.youtube.layout.hide.general.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
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.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.shared.settings.preference.impl.TextPreference
|
||||
import app.revanced.patches.youtube.layout.hide.general.annotations.HideLayoutComponentsCompatibility
|
||||
import app.revanced.patches.youtube.layout.hide.general.fingerprints.ConvertElementToFlatBufferFingerprint
|
||||
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen
|
||||
@ -23,8 +29,10 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.P
|
||||
@DependsOn([LithoFilterPatch::class, SettingsPatch::class])
|
||||
@HideLayoutComponentsCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideLayoutComponentsPatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
class HideLayoutComponentsPatch : BytecodePatch(
|
||||
listOf(ConvertElementToFlatBufferFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_gray_separator",
|
||||
@ -237,6 +245,35 @@ class HideLayoutComponentsPatch : ResourcePatch {
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
// region Mix playlists
|
||||
|
||||
ConvertElementToFlatBufferFingerprint.result?.let {
|
||||
val returnEmptyComponentIndex = it.scanResult.stringsScanResult!!.matches.first().index + 2
|
||||
|
||||
it.mutableMethod.apply {
|
||||
// The last virtual register (not parameter). Used to store the byte array
|
||||
// that may contain information about a mix playlist.
|
||||
val freeRegister = (implementation!!.registerCount - 1) - parameterTypes.size - 1
|
||||
|
||||
// Check if the byte array contains anything about a mix playlist.
|
||||
addInstructionsWithLabels(
|
||||
it.scanResult.patternScanResult!!.startIndex,
|
||||
"""
|
||||
invoke-static {v$freeRegister}, $FILTER_CLASS_DESCRIPTOR->filterMixPlaylists([B)Z
|
||||
move-result v$freeRegister
|
||||
if-nez v$freeRegister, :return_empty_component
|
||||
""",
|
||||
ExternalLabel("return_empty_component", getInstruction(returnEmptyComponentIndex))
|
||||
)
|
||||
|
||||
// Move the byte array to a free register.
|
||||
addInstruction(0, "move-object/from16 v$freeRegister, p3")
|
||||
}
|
||||
|
||||
} ?: return ConvertElementToFlatBufferFingerprint.toErrorResult()
|
||||
|
||||
// endregion
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user