feat(YouTube Music): Add Hide layout components patch (#6365)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
156441d3cf
commit
71ce8230a9
43 changed files with 1114 additions and 952 deletions
|
|
@ -472,6 +472,10 @@ public final class app/revanced/patches/music/layout/compactheader/HideCategoryB
|
|||
public static final fun getHideCategoryBar ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/layout/hide/general/HideLayoutComponentsPatchKt {
|
||||
public static final fun getHideLayoutComponentsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/layout/miniplayercolor/ChangeMiniplayerColorKt {
|
||||
public static final fun getChangeMiniplayerColor ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
|
@ -521,6 +525,10 @@ public final class app/revanced/patches/music/misc/gms/GmsCoreSupportPatchKt {
|
|||
public static final fun getGmsCoreSupportPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/litho/filter/LithoFilterPatchKt {
|
||||
public static final fun getLithoFilterPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/privacy/SanitizeSharingLinksPatchKt {
|
||||
public static final fun getSanitizeSharingLinksPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
|
@ -932,6 +940,12 @@ public final class app/revanced/patches/shared/misc/hex/Replacement {
|
|||
public final fun getReplacementBytesPadded ()[B
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/shared/misc/litho/filter/LithoFilterPatchKt {
|
||||
public static final fun getAddLithoFilter ()Lkotlin/jvm/functions/Function1;
|
||||
public static final fun lithoFilterPatch (Lkotlin/jvm/functions/Function1;Lapp/revanced/patcher/Fingerprint;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
public static synthetic fun lithoFilterPatch$default (Lkotlin/jvm/functions/Function1;Lapp/revanced/patcher/Fingerprint;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/shared/misc/mapping/ResourceElement {
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun component2 ()Ljava/lang/String;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package app.revanced.patches.music.layout.hide.general
|
||||
|
||||
import app.revanced.patches.music.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.music.misc.settings.settingsPatch
|
||||
import app.revanced.patches.shared.layout.hide.general.hideLayoutComponentsPatch
|
||||
|
||||
val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
||||
lithoFilterPatch = lithoFilterPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
filterClasses = setOf("Lapp/revanced/extension/shared/patches/components/CustomFilter;"),
|
||||
compatibleWithPackages = arrayOf("com.google.android.apps.youtube.music" to setOf("7.29.52", "8.10.52"))
|
||||
)
|
||||
|
|
@ -7,20 +7,15 @@ import app.revanced.patches.shared.misc.debugging.enableDebuggingPatch
|
|||
|
||||
@Suppress("unused")
|
||||
val enableDebuggingPatch = enableDebuggingPatch(
|
||||
block = {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
sharedExtensionPatch = sharedExtensionPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.apps.youtube.music" to setOf(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.apps.youtube.music"(
|
||||
"7.29.52",
|
||||
"8.10.52"
|
||||
)
|
||||
)
|
||||
},
|
||||
),
|
||||
// String feature flag does not appear to be present with YT Music.
|
||||
hookStringFeatureFlag = false,
|
||||
preferenceScreen = PreferenceScreen.MISC
|
||||
preferenceScreen = PreferenceScreen.MISC,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package app.revanced.patches.music.misc.litho.filter
|
||||
|
||||
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.music.shared.conversionContextFingerprintToString
|
||||
import app.revanced.patches.shared.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
val lithoFilterPatch = lithoFilterPatch(
|
||||
componentCreateInsertionIndex = {
|
||||
// No supported version clobbers p2 so we can just do our things before the return instruction.
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
},
|
||||
conversionContextFingerprintToString = conversionContextFingerprintToString,
|
||||
) {
|
||||
dependsOn(sharedExtensionPatch)
|
||||
}
|
||||
|
|
@ -11,3 +11,19 @@ internal val mainActivityOnCreateFingerprint = fingerprint {
|
|||
method.name == "onCreate" && classDef.type == YOUTUBE_MUSIC_MAIN_ACTIVITY_CLASS_TYPE
|
||||
}
|
||||
}
|
||||
|
||||
internal val conversionContextFingerprintToString = fingerprint {
|
||||
parameters()
|
||||
strings(
|
||||
"ConversionContext{containerInternal=",
|
||||
", gridColumnCount=",
|
||||
", gridColumnIndex=",
|
||||
", templateLoggerFactory=",
|
||||
", rootDisposableContainer=",
|
||||
", elementId=",
|
||||
", identifierProperty="
|
||||
)
|
||||
custom { method, _ ->
|
||||
method.name == "toString"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package app.revanced.patches.shared.layout.hide.general
|
||||
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.music.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.settings.preference.InputType
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
|
||||
internal fun hideLayoutComponentsPatch(
|
||||
lithoFilterPatch: Patch<*>,
|
||||
settingsPatch: Patch<*>,
|
||||
additionalDependencies: Set<Patch<*>> = emptySet(),
|
||||
filterClasses: Set<String>,
|
||||
vararg compatibleWithPackages: Pair<String, Set<String>?>,
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
) = bytecodePatch(
|
||||
name = "Hide layout components",
|
||||
description = "Adds options to hide general layout components.",
|
||||
) {
|
||||
dependsOn(
|
||||
lithoFilterPatch,
|
||||
settingsPatch,
|
||||
*additionalDependencies.toTypedArray(),
|
||||
addResourcesPatch,
|
||||
)
|
||||
|
||||
compatibleWith(packages = compatibleWithPackages)
|
||||
|
||||
execute {
|
||||
addResources("shared", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
|
||||
PreferenceScreen.GENERAL.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_custom_filter_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_custom_filter"),
|
||||
TextPreference("revanced_custom_filter_strings", inputType = InputType.TEXT_MULTI_LINE),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
filterClasses.forEach { className ->
|
||||
addLithoFilter(className)
|
||||
}
|
||||
|
||||
executeBlock()
|
||||
}
|
||||
}
|
||||
|
|
@ -2,23 +2,14 @@ package app.revanced.patches.shared.misc.debugging
|
|||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchBuilder
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.NonInteractivePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.*
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference.Sorting
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.copyResources
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
|
|
@ -29,23 +20,27 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
|
|||
* Patch shared with YouTube and YT Music.
|
||||
*/
|
||||
internal fun enableDebuggingPatch(
|
||||
block: BytecodePatchBuilder.() -> Unit = {},
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
sharedExtensionPatch: Patch<*>,
|
||||
settingsPatch: Patch<*>,
|
||||
vararg compatibleWithPackages: Pair<String, Set<String>>,
|
||||
hookStringFeatureFlag: Boolean,
|
||||
preferenceScreen: BasePreferenceScreen.Screen,
|
||||
additionalDebugPreferences: List<BasePreference> = emptyList()
|
||||
) = bytecodePatch(
|
||||
name = "Enable debugging",
|
||||
description = "Adds options for debugging and exporting ReVanced logs to the clipboard.",
|
||||
) {
|
||||
compatibleWith(packages = compatibleWithPackages)
|
||||
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
resourcePatch {
|
||||
execute {
|
||||
copyResources(
|
||||
"settings",
|
||||
ResourceGroup("drawable",
|
||||
ResourceGroup(
|
||||
"drawable",
|
||||
// Action buttons.
|
||||
"revanced_settings_copy_all.xml",
|
||||
"revanced_settings_deselect_all.xml",
|
||||
|
|
@ -61,38 +56,29 @@ internal fun enableDebuggingPatch(
|
|||
}
|
||||
)
|
||||
|
||||
block()
|
||||
|
||||
execute {
|
||||
executeBlock()
|
||||
|
||||
addResources("shared", "misc.debugging.enableDebuggingPatch")
|
||||
|
||||
val preferences = mutableSetOf<BasePreference>(
|
||||
val preferences = setOf(
|
||||
SwitchPreference("revanced_debug"),
|
||||
)
|
||||
|
||||
preferences.addAll(additionalDebugPreferences)
|
||||
|
||||
preferences.addAll(
|
||||
listOf(
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error"),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_export_logs_to_clipboard",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ExportLogToClipboardPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_logs_clear_buffer",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ClearLogBufferPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_feature_flags_manager",
|
||||
tag = "app.revanced.extension.shared.settings.preference.FeatureFlagsManagerPreference",
|
||||
selectable = true
|
||||
)
|
||||
SwitchPreference("revanced_debug_protobuffer"),
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error"),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_export_logs_to_clipboard",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ExportLogToClipboardPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_logs_clear_buffer",
|
||||
tag = "app.revanced.extension.shared.settings.preference.ClearLogBufferPreference",
|
||||
selectable = true
|
||||
),
|
||||
NonInteractivePreference(
|
||||
"revanced_debug_feature_flags_manager",
|
||||
tag = "app.revanced.extension.shared.settings.preference.FeatureFlagsManagerPreference",
|
||||
selectable = true
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package app.revanced.patches.shared.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.containsLiteralInstruction
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val lithoFilterFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR)
|
||||
custom { _, classDef ->
|
||||
classDef.endsWith("/LithoFilterPatch;")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a method that use the protobuf of our component.
|
||||
*/
|
||||
internal val protobufBufferReferenceFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("I", "Ljava/nio/ByteBuffer;")
|
||||
opcodes(
|
||||
Opcode.IPUT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
)
|
||||
}
|
||||
|
||||
internal val componentContextParserFingerprint = fingerprint {
|
||||
strings("Number of bits must be positive")
|
||||
}
|
||||
|
||||
internal val emptyComponentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR)
|
||||
parameters()
|
||||
strings("EmptyComponent")
|
||||
custom { _, classDef ->
|
||||
classDef.methods.filter { AccessFlags.STATIC.isSet(it.accessFlags) }.size == 1
|
||||
}
|
||||
}
|
||||
|
||||
internal val componentCreateFingerprint = fingerprint {
|
||||
strings(
|
||||
"Element missing correct type extension",
|
||||
"Element missing type"
|
||||
)
|
||||
}
|
||||
|
||||
internal val lithoThreadExecutorFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("I", "I", "I")
|
||||
custom { method, classDef ->
|
||||
classDef.superclass == "Ljava/util/concurrent/ThreadPoolExecutor;" &&
|
||||
method.containsLiteralInstruction(1L) // 1L = default thread timeout.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package app.revanced.patches.shared.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.Fingerprint
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatchBuilder
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
/**
|
||||
* Used to add a hook point to the extension stub.
|
||||
*/
|
||||
lateinit var addLithoFilter: (String) -> Unit
|
||||
private set
|
||||
|
||||
/**
|
||||
* Counts the number of filters added to the static field array.
|
||||
*/
|
||||
private var filterCount = 0
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/shared/patches/litho/LithoFilterPatch;"
|
||||
|
||||
/**
|
||||
* A patch that allows to filter Litho components based on their identifier or path.
|
||||
*
|
||||
* @param componentCreateInsertionIndex The index to insert the filtering code in the component create method.
|
||||
* @param conversionContextFingerprintToString The fingerprint of the conversion context to string method.
|
||||
* @param executeBlock The additional execution block of the patch.
|
||||
* @param block The additional block to build the patch.
|
||||
*/
|
||||
internal fun lithoFilterPatch(
|
||||
componentCreateInsertionIndex: Method.() -> Int,
|
||||
conversionContextFingerprintToString: Fingerprint,
|
||||
executeBlock: BytecodePatchContext.() -> Unit = {},
|
||||
block: BytecodePatchBuilder.() -> Unit = {},
|
||||
) = bytecodePatch(
|
||||
description = "Hooks the method which parses the bytes into a ComponentContext to filter components.",
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch(),
|
||||
)
|
||||
|
||||
/**
|
||||
* The following patch inserts a hook into the method that parses the bytes into a ComponentContext.
|
||||
* This method contains a StringBuilder object that represents the pathBuilder of the component.
|
||||
* The pathBuilder is used to filter components by their path.
|
||||
*
|
||||
* Additionally, the method contains a reference to the component's identifier.
|
||||
* The identifier is used to filter components by their identifier.
|
||||
*
|
||||
* The protobuf buffer is passed along from a different injection point before the filtering occurs.
|
||||
* The buffer is a large byte array that represents the component tree.
|
||||
* This byte array is searched for strings that indicate the current component.
|
||||
*
|
||||
* All modifications done here must allow all the original code to still execute
|
||||
* even when filtering, otherwise memory leaks or poor app performance may occur.
|
||||
*
|
||||
* The following pseudocode shows how this patch works:
|
||||
*
|
||||
* class SomeOtherClass {
|
||||
* // Called before ComponentContextParser.parseComponent() method.
|
||||
* public void someOtherMethod(ByteBuffer byteBuffer) {
|
||||
* ExtensionClass.setProtoBuffer(byteBuffer); // Inserted by this patch.
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class CreateComponentClass {
|
||||
* public Component createComponent() {
|
||||
* ...
|
||||
*
|
||||
* if (extensionClass.shouldFilter(identifier, path)) { // Inserted by this patch.
|
||||
* return emptyComponent;
|
||||
* }
|
||||
* return originalUnpatchedComponent; // Original code.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
execute {
|
||||
// Remove dummy filter from extenion static field
|
||||
// and add the filters included during patching.
|
||||
lithoFilterFingerprint.method.apply {
|
||||
removeInstructions(2, 4) // Remove dummy filter.
|
||||
|
||||
addLithoFilter = { classDescriptor ->
|
||||
addInstructions(
|
||||
2,
|
||||
"""
|
||||
new-instance v1, $classDescriptor
|
||||
invoke-direct { v1 }, $classDescriptor-><init>()V
|
||||
const/16 v2, ${filterCount++}
|
||||
aput-object v1, v0, v2
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Add an interceptor to steal the protobuf of our component.
|
||||
protobufBufferReferenceFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V",
|
||||
)
|
||||
|
||||
|
||||
// Hook the method that parses bytes into a ComponentContext.
|
||||
// Allow the method to run to completion, and override the
|
||||
// return value with an empty component if it should be filtered.
|
||||
// It is important to allow the original code to always run to completion,
|
||||
// otherwise high memory usage and poor app performance can occur.
|
||||
|
||||
// Find the identifier/path fields of the conversion context.
|
||||
val conversionContextIdentifierField = componentContextParserFingerprint.let {
|
||||
// Identifier field is loaded just before the string declaration.
|
||||
val index = it.method.indexOfFirstInstructionReversedOrThrow(
|
||||
it.stringMatches!!.first().index
|
||||
) {
|
||||
// Our instruction reads a String from a field of the ConversionContext class.
|
||||
val reference = getReference<FieldReference>()
|
||||
reference?.definingClass == conversionContextFingerprintToString.originalClassDef.type
|
||||
&& reference.type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
it.method.getInstruction<ReferenceInstruction>(index).getReference<FieldReference>()!!
|
||||
}
|
||||
|
||||
val conversionContextPathBuilderField = conversionContextFingerprintToString.originalClassDef
|
||||
.fields.single { field -> field.type == "Ljava/lang/StringBuilder;" }
|
||||
|
||||
// Find class and methods to create an empty component.
|
||||
val builderMethodDescriptor = emptyComponentFingerprint.classDef.methods.single {
|
||||
// The only static method in the class.
|
||||
method ->
|
||||
AccessFlags.STATIC.isSet(method.accessFlags)
|
||||
}
|
||||
|
||||
val emptyComponentField = classBy {
|
||||
// Only one field that matches.
|
||||
it.type == builderMethodDescriptor.returnType
|
||||
}!!.immutableClass.fields.single()
|
||||
|
||||
// Match all component creations methods
|
||||
componentCreateFingerprint.method.apply {
|
||||
val insertIndex = componentCreateInsertionIndex()
|
||||
val freeRegister = findFreeRegister(insertIndex)
|
||||
val identifierRegister = findFreeRegister(insertIndex, freeRegister)
|
||||
val pathRegister = findFreeRegister(insertIndex, freeRegister, identifierRegister)
|
||||
|
||||
addInstructionsAtControlFlowLabel(
|
||||
insertIndex,
|
||||
"""
|
||||
move-object/from16 v$freeRegister, p2 # ConversionContext parameter
|
||||
check-cast v$freeRegister, ${conversionContextFingerprintToString.originalClassDef.type} # Check we got the actual ConversionContext
|
||||
|
||||
# Get identifier and path from ConversionContext
|
||||
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
||||
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
||||
|
||||
# Check if the component should be filtered.
|
||||
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->isFiltered(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :unfiltered
|
||||
|
||||
# Return an empty component
|
||||
move-object/from16 v$freeRegister, p1
|
||||
invoke-static { v$freeRegister }, $builderMethodDescriptor
|
||||
move-result-object v$freeRegister
|
||||
iget-object v$freeRegister, v$freeRegister, $emptyComponentField
|
||||
return-object v$freeRegister
|
||||
|
||||
:unfiltered
|
||||
nop
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Check if needed in music
|
||||
// Change Litho thread executor to 1 thread to fix layout issue in unpatched YouTube.
|
||||
lithoThreadExecutorFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorCorePoolSize(I)I
|
||||
move-result p1
|
||||
invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorMaxThreads(I)I
|
||||
move-result p2
|
||||
"""
|
||||
)
|
||||
|
||||
executeBlock()
|
||||
}
|
||||
|
||||
finalize {
|
||||
// Save the number of filters added.
|
||||
lithoFilterFingerprint.method.replaceInstruction(0, "const/16 v0, $filterCount")
|
||||
}
|
||||
|
||||
block()
|
||||
}
|
||||
|
|
@ -7,13 +7,13 @@ import app.revanced.patcher.patch.resourcePatch
|
|||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.fix.verticalscroll.verticalScrollPatch
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.ad.getpremium.hideGetPremiumPatch
|
||||
import app.revanced.patches.youtube.misc.fix.backtoexitgesture.fixBackToExitGesturePatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import app.revanced.patches.all.misc.resources.addResourcesPatch
|
|||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
|
||||
|
|
|
|||
|
|
@ -9,34 +9,27 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|||
import app.revanced.patcher.extensions.InstructionExtensions.instructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patcher.patch.resourcePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.layout.hide.general.hideLayoutComponentsPatch
|
||||
import app.revanced.patches.shared.misc.mapping.get
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.*
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_09_or_greater
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||
import app.revanced.util.*
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
|
||||
var expandButtonDownId = -1L
|
||||
private set
|
||||
|
|
@ -108,184 +101,170 @@ private const val DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME =
|
|||
private const val COMMENTS_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/CommentsFilter;"
|
||||
private const val CUSTOM_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/CustomFilter;"
|
||||
"Lapp/revanced/extension/shared/patches/components/CustomFilter;"
|
||||
private const val KEYWORD_FILTER_CLASS_NAME =
|
||||
"Lapp/revanced/extension/youtube/patches/components/KeywordContentFilter;"
|
||||
|
||||
val hideLayoutComponentsPatch = bytecodePatch(
|
||||
name = "Hide layout components",
|
||||
description = "Adds options to hide general layout components.",
|
||||
|
||||
) {
|
||||
dependsOn(
|
||||
lithoFilterPatch,
|
||||
settingsPatch,
|
||||
addResourcesPatch,
|
||||
val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
|
||||
lithoFilterPatch = lithoFilterPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
additionalDependencies = setOf(
|
||||
hideLayoutComponentsResourcePatch,
|
||||
navigationBarHookPatch,
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
),
|
||||
filterClasses = setOf(
|
||||
LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR,
|
||||
DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME,
|
||||
COMMENTS_FILTER_CLASS_NAME,
|
||||
KEYWORD_FILTER_CLASS_NAME,
|
||||
CUSTOM_FILTER_CLASS_NAME
|
||||
),
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.youtube" to setOf(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
)
|
||||
) {
|
||||
addResources("youtube", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
|
||||
execute {
|
||||
addResources("youtube", "layout.hide.general.hideLayoutComponentsPatch")
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_description_components_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_ai_generated_video_summary_section"),
|
||||
SwitchPreference("revanced_hide_ask_section"),
|
||||
SwitchPreference("revanced_hide_attributes_section"),
|
||||
SwitchPreference("revanced_hide_chapters_section"),
|
||||
SwitchPreference("revanced_hide_featured_links_section"),
|
||||
SwitchPreference("revanced_hide_featured_videos_section"),
|
||||
SwitchPreference("revanced_hide_info_cards_section"),
|
||||
SwitchPreference("revanced_hide_how_this_was_made_section"),
|
||||
SwitchPreference("revanced_hide_hype_points"),
|
||||
SwitchPreference("revanced_hide_key_concepts_section"),
|
||||
SwitchPreference("revanced_hide_podcast_section"),
|
||||
SwitchPreference("revanced_hide_subscribe_button"),
|
||||
SwitchPreference("revanced_hide_transcript_section"),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
"revanced_comments_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_comments_ai_chat_summary"),
|
||||
SwitchPreference("revanced_hide_comments_ai_summary"),
|
||||
SwitchPreference("revanced_hide_comments_channel_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_by_members_header"),
|
||||
SwitchPreference("revanced_hide_comments_section"),
|
||||
SwitchPreference("revanced_hide_comments_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_create_a_short_button"),
|
||||
SwitchPreference("revanced_hide_comments_emoji_and_timestamp_buttons"),
|
||||
SwitchPreference("revanced_hide_comments_preview_comment"),
|
||||
SwitchPreference("revanced_hide_comments_thanks_button"),
|
||||
),
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
),
|
||||
SwitchPreference("revanced_hide_channel_bar"),
|
||||
SwitchPreference("revanced_hide_channel_watermark"),
|
||||
SwitchPreference("revanced_hide_crowdfunding_box"),
|
||||
SwitchPreference("revanced_hide_emergency_box"),
|
||||
SwitchPreference("revanced_hide_info_panels"),
|
||||
SwitchPreference("revanced_hide_join_membership_button"),
|
||||
SwitchPreference("revanced_hide_medical_panels"),
|
||||
SwitchPreference("revanced_hide_quick_actions"),
|
||||
SwitchPreference("revanced_hide_related_videos"),
|
||||
SwitchPreference("revanced_hide_subscribers_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_timed_reactions"),
|
||||
)
|
||||
|
||||
PreferenceScreen.PLAYER.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_description_components_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_ai_generated_video_summary_section"),
|
||||
SwitchPreference("revanced_hide_ask_section"),
|
||||
SwitchPreference("revanced_hide_attributes_section"),
|
||||
SwitchPreference("revanced_hide_chapters_section"),
|
||||
SwitchPreference("revanced_hide_featured_links_section"),
|
||||
SwitchPreference("revanced_hide_featured_videos_section"),
|
||||
SwitchPreference("revanced_hide_info_cards_section"),
|
||||
SwitchPreference("revanced_hide_how_this_was_made_section"),
|
||||
SwitchPreference("revanced_hide_hype_points"),
|
||||
SwitchPreference("revanced_hide_key_concepts_section"),
|
||||
SwitchPreference("revanced_hide_podcast_section"),
|
||||
SwitchPreference("revanced_hide_subscribe_button"),
|
||||
SwitchPreference("revanced_hide_transcript_section"),
|
||||
PreferenceScreen.FEED.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_keyword_content_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_keyword_content_home"),
|
||||
SwitchPreference("revanced_hide_keyword_content_subscriptions"),
|
||||
SwitchPreference("revanced_hide_keyword_content_search"),
|
||||
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference"
|
||||
),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about_whole_words",
|
||||
tag = "app.revanced.extension.youtube.settings.preference.HtmlPreference",
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
"revanced_comments_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_comments_ai_chat_summary"),
|
||||
SwitchPreference("revanced_hide_comments_ai_summary"),
|
||||
SwitchPreference("revanced_hide_comments_channel_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_by_members_header"),
|
||||
SwitchPreference("revanced_hide_comments_section"),
|
||||
SwitchPreference("revanced_hide_comments_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_comments_create_a_short_button"),
|
||||
SwitchPreference("revanced_hide_comments_emoji_and_timestamp_buttons"),
|
||||
SwitchPreference("revanced_hide_comments_preview_comment"),
|
||||
SwitchPreference("revanced_hide_comments_thanks_button"),
|
||||
),
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_filter_bar_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_history"),
|
||||
),
|
||||
SwitchPreference("revanced_hide_channel_bar"),
|
||||
SwitchPreference("revanced_hide_channel_watermark"),
|
||||
SwitchPreference("revanced_hide_crowdfunding_box"),
|
||||
SwitchPreference("revanced_hide_emergency_box"),
|
||||
SwitchPreference("revanced_hide_info_panels"),
|
||||
SwitchPreference("revanced_hide_join_membership_button"),
|
||||
SwitchPreference("revanced_hide_medical_panels"),
|
||||
SwitchPreference("revanced_hide_quick_actions"),
|
||||
SwitchPreference("revanced_hide_related_videos"),
|
||||
SwitchPreference("revanced_hide_subscribers_community_guidelines"),
|
||||
SwitchPreference("revanced_hide_timed_reactions"),
|
||||
)
|
||||
|
||||
PreferenceScreen.FEED.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_keyword_content_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_keyword_content_home"),
|
||||
SwitchPreference("revanced_hide_keyword_content_subscriptions"),
|
||||
SwitchPreference("revanced_hide_keyword_content_search"),
|
||||
TextPreference("revanced_hide_keyword_content_phrases", inputType = InputType.TEXT_MULTI_LINE),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointPreference"
|
||||
),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_hide_keyword_content_about_whole_words",
|
||||
tag = "app.revanced.extension.youtube.settings.preference.HtmlPreference",
|
||||
),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_channel_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_community_button"),
|
||||
SwitchPreference("revanced_hide_for_you_shelf"),
|
||||
SwitchPreference("revanced_hide_join_button"),
|
||||
SwitchPreference("revanced_hide_links_preview"),
|
||||
SwitchPreference("revanced_hide_members_shelf"),
|
||||
SwitchPreference("revanced_hide_store_button"),
|
||||
SwitchPreference("revanced_hide_subscribe_button_in_channel_page"),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_hide_filter_bar_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_feed"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_related_videos"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_search"),
|
||||
SwitchPreference("revanced_hide_filter_bar_feed_in_history"),
|
||||
),
|
||||
),
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_channel_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_hide_community_button"),
|
||||
SwitchPreference("revanced_hide_for_you_shelf"),
|
||||
SwitchPreference("revanced_hide_join_button"),
|
||||
SwitchPreference("revanced_hide_links_preview"),
|
||||
SwitchPreference("revanced_hide_members_shelf"),
|
||||
SwitchPreference("revanced_hide_store_button"),
|
||||
SwitchPreference("revanced_hide_subscribe_button_in_channel_page"),
|
||||
),
|
||||
),
|
||||
SwitchPreference("revanced_hide_album_cards"),
|
||||
SwitchPreference("revanced_hide_artist_cards"),
|
||||
SwitchPreference("revanced_hide_chips_shelf"),
|
||||
SwitchPreference("revanced_hide_community_posts"),
|
||||
SwitchPreference("revanced_hide_compact_banner"),
|
||||
SwitchPreference("revanced_hide_expandable_card"),
|
||||
SwitchPreference("revanced_hide_floating_microphone_button"),
|
||||
SwitchPreference(
|
||||
key = "revanced_hide_horizontal_shelves",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference"
|
||||
),
|
||||
SwitchPreference("revanced_hide_image_shelf"),
|
||||
SwitchPreference("revanced_hide_latest_posts"),
|
||||
SwitchPreference("revanced_hide_mix_playlists"),
|
||||
SwitchPreference("revanced_hide_movies_section"),
|
||||
SwitchPreference("revanced_hide_notify_me_button"),
|
||||
SwitchPreference("revanced_hide_playables"),
|
||||
SwitchPreference("revanced_hide_show_more_button"),
|
||||
SwitchPreference("revanced_hide_surveys"),
|
||||
SwitchPreference("revanced_hide_ticket_shelf"),
|
||||
SwitchPreference("revanced_hide_upload_time"),
|
||||
SwitchPreference("revanced_hide_video_recommendation_labels"),
|
||||
SwitchPreference("revanced_hide_view_count"),
|
||||
SwitchPreference("revanced_hide_visual_spacer"),
|
||||
SwitchPreference("revanced_hide_doodles"),
|
||||
)
|
||||
),
|
||||
SwitchPreference("revanced_hide_album_cards"),
|
||||
SwitchPreference("revanced_hide_artist_cards"),
|
||||
SwitchPreference("revanced_hide_chips_shelf"),
|
||||
SwitchPreference("revanced_hide_community_posts"),
|
||||
SwitchPreference("revanced_hide_compact_banner"),
|
||||
SwitchPreference("revanced_hide_expandable_card"),
|
||||
SwitchPreference("revanced_hide_floating_microphone_button"),
|
||||
SwitchPreference(
|
||||
key = "revanced_hide_horizontal_shelves",
|
||||
tag = "app.revanced.extension.shared.settings.preference.BulletPointSwitchPreference"
|
||||
),
|
||||
SwitchPreference("revanced_hide_image_shelf"),
|
||||
SwitchPreference("revanced_hide_latest_posts"),
|
||||
SwitchPreference("revanced_hide_mix_playlists"),
|
||||
SwitchPreference("revanced_hide_movies_section"),
|
||||
SwitchPreference("revanced_hide_notify_me_button"),
|
||||
SwitchPreference("revanced_hide_playables"),
|
||||
SwitchPreference("revanced_hide_show_more_button"),
|
||||
SwitchPreference("revanced_hide_surveys"),
|
||||
SwitchPreference("revanced_hide_ticket_shelf"),
|
||||
SwitchPreference("revanced_hide_upload_time"),
|
||||
SwitchPreference("revanced_hide_video_recommendation_labels"),
|
||||
SwitchPreference("revanced_hide_view_count"),
|
||||
SwitchPreference("revanced_hide_visual_spacer"),
|
||||
SwitchPreference("revanced_hide_doodles"),
|
||||
)
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
PreferenceScreenPreference(
|
||||
key = "revanced_custom_filter_screen",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_custom_filter"),
|
||||
TextPreference("revanced_custom_filter_strings", inputType = InputType.TEXT_MULTI_LINE),
|
||||
),
|
||||
),
|
||||
)
|
||||
// region Mix playlists
|
||||
|
||||
addLithoFilter(LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR)
|
||||
addLithoFilter(DESCRIPTION_COMPONENTS_FILTER_CLASS_NAME)
|
||||
addLithoFilter(COMMENTS_FILTER_CLASS_NAME)
|
||||
addLithoFilter(KEYWORD_FILTER_CLASS_NAME)
|
||||
addLithoFilter(CUSTOM_FILTER_CLASS_NAME)
|
||||
(if (is_20_09_or_greater) parseElementFromBufferFingerprint
|
||||
else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint
|
||||
else parseElementFromBufferLegacy1901Fingerprint).let {
|
||||
it.method.apply {
|
||||
val byteArrayParameter = "p3"
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val conversionContextRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
|
||||
val returnEmptyComponentInstruction = instructions.last { it.opcode == Opcode.INVOKE_STATIC }
|
||||
val returnEmptyComponentRegister =
|
||||
(returnEmptyComponentInstruction as FiveRegisterInstruction).registerC
|
||||
val insertIndex = startIndex + 1
|
||||
val freeRegister =
|
||||
findFreeRegister(insertIndex, conversionContextRegister, returnEmptyComponentRegister)
|
||||
|
||||
// region Mix playlists
|
||||
|
||||
(if (is_20_09_or_greater) parseElementFromBufferFingerprint
|
||||
else if (is_20_07_or_greater) parseElementFromBufferLegacy2007Fingerprint
|
||||
else parseElementFromBufferLegacy1901Fingerprint).let {
|
||||
it.method.apply {
|
||||
val byteArrayParameter = "p3"
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val conversionContextRegister = getInstruction<TwoRegisterInstruction>(startIndex).registerA
|
||||
val returnEmptyComponentInstruction = instructions.last { it.opcode == Opcode.INVOKE_STATIC }
|
||||
val returnEmptyComponentRegister = (returnEmptyComponentInstruction as FiveRegisterInstruction).registerC
|
||||
val insertIndex = startIndex + 1
|
||||
val freeRegister = findFreeRegister(insertIndex, conversionContextRegister, returnEmptyComponentRegister)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex,
|
||||
"""
|
||||
addInstructionsWithLabels(
|
||||
insertIndex,
|
||||
"""
|
||||
invoke-static { v$conversionContextRegister, $byteArrayParameter }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :show
|
||||
|
|
@ -294,193 +273,192 @@ val hideLayoutComponentsPatch = bytecodePatch(
|
|||
:show
|
||||
nop
|
||||
""",
|
||||
ExternalLabel("return_empty_component", returnEmptyComponentInstruction),
|
||||
)
|
||||
}
|
||||
ExternalLabel("return_empty_component", returnEmptyComponentInstruction),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region Watermark (legacy code for old versions of YouTube)
|
||||
// region Watermark (legacy code for old versions of YouTube)
|
||||
|
||||
showWatermarkFingerprint.match(
|
||||
playerOverlayFingerprint.originalClassDef,
|
||||
).method.apply {
|
||||
val index = implementation!!.instructions.size - 5
|
||||
showWatermarkFingerprint.match(
|
||||
playerOverlayFingerprint.originalClassDef,
|
||||
).method.apply {
|
||||
val index = implementation!!.instructions.size - 5
|
||||
|
||||
removeInstruction(index)
|
||||
addInstructions(
|
||||
index,
|
||||
"""
|
||||
removeInstruction(index)
|
||||
addInstructions(
|
||||
index,
|
||||
"""
|
||||
invoke-static {}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->showWatermark()Z
|
||||
move-result p2
|
||||
""",
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region Show more button
|
||||
// region Show more button
|
||||
|
||||
hideShowMoreButtonFingerprint.method.apply {
|
||||
val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch!!.endIndex
|
||||
val viewRegister = getInstruction<OneRegisterInstruction>(moveRegisterIndex).registerA
|
||||
hideShowMoreButtonFingerprint.method.apply {
|
||||
val moveRegisterIndex = hideShowMoreButtonFingerprint.patternMatch!!.endIndex
|
||||
val viewRegister = getInstruction<OneRegisterInstruction>(moveRegisterIndex).registerA
|
||||
|
||||
val insertIndex = moveRegisterIndex + 1
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideShowMoreButton(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region crowdfunding box
|
||||
crowdfundingBoxFingerprint.let {
|
||||
it.method.apply {
|
||||
val insertIndex = it.patternMatch!!.endIndex
|
||||
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
val insertIndex = moveRegisterIndex + 1
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideShowMoreButton(Landroid/view/View;)V",
|
||||
"invoke-static {v$objectRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideCrowdfundingBox(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region crowdfunding box
|
||||
crowdfundingBoxFingerprint.let {
|
||||
it.method.apply {
|
||||
val insertIndex = it.patternMatch!!.endIndex
|
||||
val objectRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
// region hide album cards
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v$objectRegister}, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideCrowdfundingBox(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
albumCardsFingerprint.let {
|
||||
it.method.apply {
|
||||
val checkCastAnchorIndex = it.patternMatch!!.endIndex
|
||||
val insertIndex = checkCastAnchorIndex + 1
|
||||
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
|
||||
|
||||
// endregion
|
||||
|
||||
// region hide album cards
|
||||
|
||||
albumCardsFingerprint.let {
|
||||
it.method.apply {
|
||||
val checkCastAnchorIndex = it.patternMatch!!.endIndex
|
||||
val insertIndex = checkCastAnchorIndex + 1
|
||||
val register = getInstruction<OneRegisterInstruction>(checkCastAnchorIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR" +
|
||||
"->hideAlbumCard(Landroid/view/View;)V",
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region hide floating microphone
|
||||
// region hide floating microphone
|
||||
|
||||
showFloatingMicrophoneButtonFingerprint.method.apply {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(fabButtonId)
|
||||
val booleanIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.IGET_BOOLEAN)
|
||||
val register = getInstruction<TwoRegisterInstruction>(booleanIndex).registerA
|
||||
showFloatingMicrophoneButtonFingerprint.method.apply {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(fabButtonId)
|
||||
val booleanIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.IGET_BOOLEAN)
|
||||
val register = getInstruction<TwoRegisterInstruction>(booleanIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
booleanIndex + 1,
|
||||
"""
|
||||
addInstructions(
|
||||
booleanIndex + 1,
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideFloatingMicrophoneButton(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region 'Yoodles'
|
||||
|
||||
yoodlesImageViewFingerprint.method.apply {
|
||||
findInstructionIndicesReversedOrThrow {
|
||||
getReference<MethodReference>()?.name == "setImageDrawable"
|
||||
}.forEach { insertIndex ->
|
||||
val drawableRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
val imageViewRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
|
||||
replaceInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$imageViewRegister, v$drawableRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->" +
|
||||
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region 'Yoodles'
|
||||
|
||||
yoodlesImageViewFingerprint.method.apply {
|
||||
findInstructionIndicesReversedOrThrow {
|
||||
getReference<MethodReference>()?.name == "setImageDrawable"
|
||||
}.forEach { insertIndex ->
|
||||
val drawableRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
val imageViewRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
|
||||
// region hide view count
|
||||
|
||||
replaceInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$imageViewRegister, v$drawableRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->" +
|
||||
"setDoodleDrawable(Landroid/widget/ImageView;Landroid/graphics/drawable/Drawable;)V"
|
||||
)
|
||||
}
|
||||
hideViewCountFingerprint.method.apply {
|
||||
val startIndex = hideViewCountFingerprint.patternMatch!!.startIndex
|
||||
var returnStringRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
||||
|
||||
// Find the instruction where the text dimension is retrieved.
|
||||
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_STATIC &&
|
||||
reference?.definingClass == "Landroid/util/TypedValue;" &&
|
||||
reference.returnType == "F" &&
|
||||
reference.name == "applyDimension" &&
|
||||
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
|
||||
}
|
||||
|
||||
// endregion
|
||||
// A float value is passed which is used to determine subtitle text size.
|
||||
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
|
||||
applyDimensionIndex + 1
|
||||
).registerA
|
||||
|
||||
|
||||
// region hide view count
|
||||
|
||||
hideViewCountFingerprint.method.apply {
|
||||
val startIndex = hideViewCountFingerprint.patternMatch!!.startIndex
|
||||
var returnStringRegister = getInstruction<OneRegisterInstruction>(startIndex).registerA
|
||||
|
||||
// Find the instruction where the text dimension is retrieved.
|
||||
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_STATIC &&
|
||||
reference?.definingClass == "Landroid/util/TypedValue;" &&
|
||||
reference.returnType == "F" &&
|
||||
reference.name == "applyDimension" &&
|
||||
reference.parameterTypes == listOf("I", "F", "Landroid/util/DisplayMetrics;")
|
||||
}
|
||||
|
||||
// A float value is passed which is used to determine subtitle text size.
|
||||
val floatDimensionRegister = getInstruction<OneRegisterInstruction>(
|
||||
applyDimensionIndex + 1
|
||||
).registerA
|
||||
|
||||
addInstructions(
|
||||
applyDimensionIndex - 1,
|
||||
"""
|
||||
addInstructions(
|
||||
applyDimensionIndex - 1,
|
||||
"""
|
||||
invoke-static { v$returnStringRegister, v$floatDimensionRegister }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->modifyFeedSubtitleSpan(Landroid/text/SpannableString;F)Landroid/text/SpannableString;
|
||||
move-result-object v$returnStringRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
// endregion
|
||||
|
||||
// region hide filter bar
|
||||
// region hide filter bar
|
||||
|
||||
/**
|
||||
* Patch a [Method] with a given [instructions].
|
||||
*
|
||||
* @param RegisterInstruction The type of instruction to get the register from.
|
||||
* @param insertIndexOffset The offset to add to the end index of the [Match.patternMatch].
|
||||
* @param hookRegisterOffset The offset to add to the register of the hook.
|
||||
* @param instructions The instructions to add with the register as a parameter.
|
||||
*/
|
||||
fun <RegisterInstruction : OneRegisterInstruction> Fingerprint.patch(
|
||||
insertIndexOffset: Int = 0,
|
||||
hookRegisterOffset: Int = 0,
|
||||
instructions: (Int) -> String,
|
||||
) = method.apply {
|
||||
val endIndex = patternMatch!!.endIndex
|
||||
/**
|
||||
* Patch a [Method] with a given [instructions].
|
||||
*
|
||||
* @param RegisterInstruction The type of instruction to get the register from.
|
||||
* @param insertIndexOffset The offset to add to the end index of the [Match.patternMatch].
|
||||
* @param hookRegisterOffset The offset to add to the register of the hook.
|
||||
* @param instructions The instructions to add with the register as a parameter.
|
||||
*/
|
||||
fun <RegisterInstruction : OneRegisterInstruction> Fingerprint.patch(
|
||||
insertIndexOffset: Int = 0,
|
||||
hookRegisterOffset: Int = 0,
|
||||
instructions: (Int) -> String,
|
||||
) = method.apply {
|
||||
val endIndex = patternMatch!!.endIndex
|
||||
|
||||
val insertIndex = endIndex + insertIndexOffset
|
||||
val register =
|
||||
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
|
||||
val insertIndex = endIndex + insertIndexOffset
|
||||
val register =
|
||||
getInstruction<RegisterInstruction>(endIndex + hookRegisterOffset).registerA
|
||||
|
||||
addInstructions(insertIndex, instructions(register))
|
||||
}
|
||||
addInstructions(insertIndex, instructions(register))
|
||||
}
|
||||
|
||||
filterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
|
||||
"""
|
||||
filterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInFeed(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
searchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
|
||||
"""
|
||||
searchResultsChipBarFingerprint.patch<OneRegisterInstruction>(-1, -2) { register ->
|
||||
"""
|
||||
invoke-static { v$register }, $LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInSearch(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
relatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
|
||||
"invoke-static { v$register }, " +
|
||||
relatedChipCloudFingerprint.patch<OneRegisterInstruction>(1) { register ->
|
||||
"invoke-static { v$register }, " +
|
||||
"$LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR->hideInRelatedVideos(Landroid/view/View;)V"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
|||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import app.revanced.patches.all.misc.resources.addResources
|
|||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappings
|
|||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_41_or_greater
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
|||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_33_or_greater
|
||||
|
|
|
|||
|
|
@ -1,33 +1,22 @@
|
|||
package app.revanced.patches.youtube.misc.debugging
|
||||
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch;
|
||||
import app.revanced.patches.shared.misc.debugging.enableDebuggingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
|
||||
@Suppress("unused")
|
||||
val enableDebuggingPatch = enableDebuggingPatch(
|
||||
block = {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
settingsPatch,
|
||||
sharedExtensionPatch = sharedExtensionPatch,
|
||||
settingsPatch = settingsPatch,
|
||||
compatibleWithPackages = arrayOf(
|
||||
"com.google.android.youtube" to setOf(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
"com.google.android.youtube"(
|
||||
"19.34.42",
|
||||
"20.07.39",
|
||||
"20.13.41",
|
||||
"20.14.43",
|
||||
)
|
||||
)
|
||||
},
|
||||
executeBlock = {
|
||||
addResources("youtube", "misc.debugging.enableDebuggingPatch")
|
||||
},
|
||||
),
|
||||
hookStringFeatureFlag = true,
|
||||
preferenceScreen = PreferenceScreen.MISC,
|
||||
additionalDebugPreferences = listOf(SwitchPreference("revanced_debug_protobuffer"))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,58 +1,8 @@
|
|||
package app.revanced.patches.youtube.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.util.containsLiteralInstruction
|
||||
import app.revanced.util.literal
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal val componentContextParserFingerprint = fingerprint {
|
||||
strings("Number of bits must be positive")
|
||||
}
|
||||
|
||||
internal val componentCreateFingerprint = fingerprint {
|
||||
strings(
|
||||
"Element missing correct type extension",
|
||||
"Element missing type"
|
||||
)
|
||||
}
|
||||
|
||||
internal val lithoFilterFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.STATIC, AccessFlags.CONSTRUCTOR)
|
||||
custom { _, classDef ->
|
||||
classDef.endsWith("/LithoFilterPatch;")
|
||||
}
|
||||
}
|
||||
|
||||
internal val protobufBufferReferenceFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("I", "Ljava/nio/ByteBuffer;")
|
||||
opcodes(
|
||||
Opcode.IPUT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.SUB_INT_2ADDR,
|
||||
)
|
||||
}
|
||||
|
||||
internal val emptyComponentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PRIVATE, AccessFlags.CONSTRUCTOR)
|
||||
parameters()
|
||||
strings("EmptyComponent")
|
||||
custom { _, classDef ->
|
||||
classDef.methods.filter { AccessFlags.STATIC.isSet(it.accessFlags) }.size == 1
|
||||
}
|
||||
}
|
||||
|
||||
internal val lithoThreadExecutorFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||
parameters("I", "I", "I")
|
||||
custom { method, classDef ->
|
||||
classDef.superclass == "Ljava/util/concurrent/ThreadPoolExecutor;" &&
|
||||
method.containsLiteralInstruction(1L) // 1L = default thread timeout.
|
||||
}
|
||||
}
|
||||
|
||||
internal val lithoComponentNameUpbFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
|
|
|
|||
|
|
@ -3,225 +3,68 @@
|
|||
package app.revanced.patches.youtube.misc.litho.filter
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patcher.patch.BytecodePatchContext
|
||||
import app.revanced.patches.shared.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_17_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_05_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.shared.conversionContextFingerprintToString
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Deprecated("Use the shared one instead", ReplaceWith("app.revanced.patches.shared.misc.litho.filter.addLithoFilter"))
|
||||
lateinit var addLithoFilter: (String) -> Unit
|
||||
private set
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/components/LithoFilterPatch;"
|
||||
|
||||
val lithoFilterPatch = bytecodePatch(
|
||||
description = "Hooks the method which parses the bytes into a ComponentContext to filter components.",
|
||||
val lithoFilterPatch = lithoFilterPatch(
|
||||
componentCreateInsertionIndex = {
|
||||
if (is_19_17_or_greater) {
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
} else {
|
||||
// 19.16 clobbers p2 so must check at start of the method
|
||||
0
|
||||
}
|
||||
},
|
||||
conversionContextFingerprintToString = conversionContextFingerprintToString,
|
||||
executeBlock = BytecodePatchContext::executeBlock,
|
||||
) {
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
versionCheckPatch,
|
||||
)
|
||||
|
||||
var filterCount = 0
|
||||
|
||||
/**
|
||||
* The following patch inserts a hook into the method that parses the bytes into a ComponentContext.
|
||||
* This method contains a StringBuilder object that represents the pathBuilder of the component.
|
||||
* The pathBuilder is used to filter components by their path.
|
||||
*
|
||||
* Additionally, the method contains a reference to the component's identifier.
|
||||
* The identifier is used to filter components by their identifier.
|
||||
*
|
||||
* The protobuf buffer is passed along from a different injection point before the filtering occurs.
|
||||
* The buffer is a large byte array that represents the component tree.
|
||||
* This byte array is searched for strings that indicate the current component.
|
||||
*
|
||||
* All modifications done here must allow all the original code to still execute
|
||||
* even when filtering, otherwise memory leaks or poor app performance may occur.
|
||||
*
|
||||
* The following pseudocode shows how this patch works:
|
||||
*
|
||||
* class SomeOtherClass {
|
||||
* // Called before ComponentContextParser.parseComponent() method.
|
||||
* public void someOtherMethod(ByteBuffer byteBuffer) {
|
||||
* ExtensionClass.setProtoBuffer(byteBuffer); // Inserted by this patch.
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class CreateComponentClass {
|
||||
* public Component createComponent() {
|
||||
* ...
|
||||
*
|
||||
* if (extensionClass.shouldFilter(identifier, path)) { // Inserted by this patch.
|
||||
* return emptyComponent;
|
||||
* }
|
||||
* return originalUnpatchedComponent; // Original code.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
execute {
|
||||
// Remove dummy filter from extenion static field
|
||||
// and add the filters included during patching.
|
||||
lithoFilterFingerprint.method.apply {
|
||||
removeInstructions(2, 4) // Remove dummy filter.
|
||||
|
||||
addLithoFilter = { classDescriptor ->
|
||||
addInstructions(
|
||||
2,
|
||||
"""
|
||||
new-instance v1, $classDescriptor
|
||||
invoke-direct { v1 }, $classDescriptor-><init>()V
|
||||
const/16 v2, ${filterCount++}
|
||||
aput-object v1, v0, v2
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region Pass the buffer into extension.
|
||||
|
||||
protobufBufferReferenceFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V",
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Hook the method that parses bytes into a ComponentContext.
|
||||
|
||||
// Allow the method to run to completion, and override the
|
||||
// return value with an empty component if it should be filtered.
|
||||
// It is important to allow the original code to always run to completion,
|
||||
// otherwise high memory usage and poor app performance can occur.
|
||||
|
||||
// Find the identifier/path fields of the conversion context.
|
||||
val conversionContextIdentifierField = componentContextParserFingerprint.let {
|
||||
// Identifier field is loaded just before the string declaration.
|
||||
val index = it.method.indexOfFirstInstructionReversedOrThrow(
|
||||
it.stringMatches!!.first().index
|
||||
) {
|
||||
val reference = getReference<FieldReference>()
|
||||
reference?.definingClass == conversionContextFingerprintToString.originalClassDef.type
|
||||
&& reference.type == "Ljava/lang/String;"
|
||||
}
|
||||
|
||||
it.method.getInstruction<ReferenceInstruction>(index).getReference<FieldReference>()!!
|
||||
}
|
||||
|
||||
val conversionContextPathBuilderField = conversionContextFingerprintToString.originalClassDef
|
||||
.fields.single { field -> field.type == "Ljava/lang/StringBuilder;" }
|
||||
|
||||
// Find class and methods to create an empty component.
|
||||
val builderMethodDescriptor = emptyComponentFingerprint.classDef.methods.single {
|
||||
// The only static method in the class.
|
||||
method -> AccessFlags.STATIC.isSet(method.accessFlags)
|
||||
}
|
||||
val emptyComponentField = classBy {
|
||||
// Only one field that matches.
|
||||
it.type == builderMethodDescriptor.returnType
|
||||
}!!.immutableClass.fields.single()
|
||||
|
||||
componentCreateFingerprint.method.apply {
|
||||
val insertIndex = if (is_19_17_or_greater) {
|
||||
indexOfFirstInstructionOrThrow(Opcode.RETURN_OBJECT)
|
||||
} else {
|
||||
// 19.16 clobbers p2 so must check at start of the method and not at the return index.
|
||||
0
|
||||
}
|
||||
|
||||
val freeRegister = findFreeRegister(insertIndex)
|
||||
val identifierRegister = findFreeRegister(insertIndex, freeRegister)
|
||||
val pathRegister = findFreeRegister(insertIndex, freeRegister, identifierRegister)
|
||||
|
||||
addInstructionsAtControlFlowLabel(
|
||||
insertIndex,
|
||||
"""
|
||||
move-object/from16 v$freeRegister, p2
|
||||
iget-object v$identifierRegister, v$freeRegister, $conversionContextIdentifierField
|
||||
iget-object v$pathRegister, v$freeRegister, $conversionContextPathBuilderField
|
||||
invoke-static { v$identifierRegister, v$pathRegister }, $EXTENSION_CLASS_DESCRIPTOR->isFiltered(Ljava/lang/String;Ljava/lang/StringBuilder;)Z
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :unfiltered
|
||||
|
||||
# Return an empty component
|
||||
move-object/from16 v$freeRegister, p1
|
||||
invoke-static { v$freeRegister }, $builderMethodDescriptor
|
||||
move-result-object v$freeRegister
|
||||
iget-object v$freeRegister, v$freeRegister, $emptyComponentField
|
||||
return-object v$freeRegister
|
||||
|
||||
:unfiltered
|
||||
nop
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
// region Change Litho thread executor to 1 thread to fix layout issue in unpatched YouTube.
|
||||
|
||||
lithoThreadExecutorFingerprint.method.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorCorePoolSize(I)I
|
||||
move-result p1
|
||||
invoke-static { p2 }, $EXTENSION_CLASS_DESCRIPTOR->getExecutorMaxThreads(I)I
|
||||
move-result p2
|
||||
"""
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
// region A/B test of new Litho native code.
|
||||
|
||||
// Turn off native code that handles litho component names. If this feature is on then nearly
|
||||
// all litho components have a null name and identifier/path filtering is completely broken.
|
||||
//
|
||||
// Flag was removed in 20.05. It appears a new flag might be used instead (45660109L),
|
||||
// but if the flag is forced on then litho filtering still works correctly.
|
||||
if (is_19_25_or_greater && !is_20_05_or_greater) {
|
||||
lithoComponentNameUpbFeatureFlagFingerprint.method.apply {
|
||||
// Don't use return early, so the debug patch logs if this was originally on.
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN)
|
||||
val register = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(insertIndex, "const/4 v$register, 0x0")
|
||||
}
|
||||
}
|
||||
|
||||
// Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf).
|
||||
// If this is enabled, then the litho protobuffer hook will always show an empty buffer
|
||||
// since it's no longer handled by the hooked Java code.
|
||||
lithoConverterBufferUpbFeatureFlagFingerprint.method.apply {
|
||||
val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstruction(index + 1, "const/4 v$register, 0x0")
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
finalize {
|
||||
lithoFilterFingerprint.method.replaceInstruction(0, "const/16 v0, $filterCount")
|
||||
}
|
||||
dependsOn(versionCheckPatch)
|
||||
}
|
||||
|
||||
private fun BytecodePatchContext.executeBlock() {
|
||||
// region A/B test of new Litho native code.
|
||||
|
||||
// Turn off native code that handles litho component names. If this feature is on then nearly
|
||||
// all litho components have a null name and identifier/path filtering is completely broken.
|
||||
//
|
||||
// Flag was removed in 20.05. It appears a new flag might be used instead (45660109L),
|
||||
// but if the flag is forced on then litho filtering still works correctly.
|
||||
if (is_19_25_or_greater && !is_20_05_or_greater) {
|
||||
lithoComponentNameUpbFeatureFlagFingerprint.method.apply {
|
||||
// Don't use return early, so the debug patch logs if this was originally on.
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(Opcode.RETURN)
|
||||
val register = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstruction(insertIndex, "const/4 v$register, 0x0")
|
||||
}
|
||||
}
|
||||
|
||||
// Turn off a feature flag that enables native code of protobuf parsing (Upb protobuf).
|
||||
// If this is enabled, then the litho protobuffer hook will always show an empty buffer
|
||||
// since it's no longer handled by the hooked Java code.
|
||||
lithoConverterBufferUpbFeatureFlagFingerprint.method.apply {
|
||||
val index = indexOfFirstInstructionOrThrow(Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
|
||||
addInstruction(index + 1, "const/4 v$register, 0x0")
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// Set the addLithoFilter function to the one from the shared patch.
|
||||
// This is done for backwards compatibility.
|
||||
addLithoFilter = app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
|||
import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.addRecyclerViewTreeHook
|
||||
import app.revanced.patches.youtube.misc.recyclerviewtree.hook.recyclerViewTreeHookPatch
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import app.revanced.patches.shared.misc.settings.preference.InputType
|
|||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.shared.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
|
|
|
|||
|
|
@ -173,6 +173,14 @@ You will not be notified of any unexpected events."</string>
|
|||
<string name="revanced_debug_feature_flags_manager_toast_saved">Flags saved</string>
|
||||
<string name="revanced_debug_feature_flags_manager_toast_reset">Flags reset</string>
|
||||
<string name="revanced_debug_feature_flags_manager_toast_copied">Flags copied to clipboard</string>
|
||||
<string name="revanced_debug_protobuffer_title">Log protocol buffer</string>
|
||||
<string name="revanced_debug_protobuffer_summary_on">Debug logs include proto buffer</string>
|
||||
<string name="revanced_debug_protobuffer_summary_off">Debug logs do not include proto buffer</string>
|
||||
<string name="revanced_debug_protobuffer_user_dialog_message">"Enabling this setting will log additional layout data, including on-screen text for some UI components.
|
||||
|
||||
This can help identify components when creating custom filters.
|
||||
|
||||
However, enabling this will also log some user data such as your IP address."</string>
|
||||
</patch>
|
||||
<patch id="misc.privacy.sanitizeSharingLinksPatch">
|
||||
<string name="revanced_sanitize_sharing_links_title">Sanitize sharing links</string>
|
||||
|
|
@ -182,6 +190,17 @@ You will not be notified of any unexpected events."</string>
|
|||
<string name="revanced_replace_music_with_youtube_summary_on">Shared links use youtube.com</string>
|
||||
<string name="revanced_replace_music_with_youtube_summary_off">Shared links use music.youtube.com</string>
|
||||
</patch>
|
||||
<patch id="layout.hide.general.hideLayoutComponentsPatch">
|
||||
<string name="revanced_custom_filter_screen_title">Custom filter</string>
|
||||
<string name="revanced_custom_filter_screen_summary">Hide components using custom filters</string>
|
||||
<string name="revanced_custom_filter_title">Enable custom filter</string>
|
||||
<string name="revanced_custom_filter_summary_on">Custom filter is enabled</string>
|
||||
<string name="revanced_custom_filter_summary_off">Custom filter is disabled</string>
|
||||
<string name="revanced_custom_filter_strings_title">Custom filter</string>
|
||||
<!-- 'Component path builder strings' is the technical name for identifying the Litho UI layout items to hide. This is an advanced feature and most users will never use this. -->
|
||||
<string name="revanced_custom_filter_strings_summary">List of component path builder strings to filter separated by new line</string>
|
||||
<string name="revanced_custom_filter_toast_invalid_syntax">Invalid custom filter: %s</string>
|
||||
</patch>
|
||||
</app>
|
||||
<app id="youtube">
|
||||
<patch id="misc.settings.settingsPatch">
|
||||
|
|
@ -206,16 +225,6 @@ You will not be notified of any unexpected events."</string>
|
|||
<string name="revanced_shorts_disable_background_playback_summary_on">Shorts background play is disabled</string>
|
||||
<string name="revanced_shorts_disable_background_playback_summary_off">Shorts background play is enabled</string>
|
||||
</patch>
|
||||
<patch id="misc.debugging.enableDebuggingPatch">
|
||||
<string name="revanced_debug_protobuffer_title">Log protocol buffer</string>
|
||||
<string name="revanced_debug_protobuffer_summary_on">Debug logs include proto buffer</string>
|
||||
<string name="revanced_debug_protobuffer_summary_off">Debug logs do not include proto buffer</string>
|
||||
<string name="revanced_debug_protobuffer_user_dialog_message">"Enabling this setting will log additional layout data, including on-screen text for some UI components.
|
||||
|
||||
This can help identify components when creating custom filters.
|
||||
|
||||
However, enabling this will also log some user data such as your IP address."</string>
|
||||
</patch>
|
||||
<patch id="layout.hide.general.hideLayoutComponentsPatch">
|
||||
<string name="revanced_hide_album_cards_title">Hide album cards</string>
|
||||
<string name="revanced_hide_album_cards_summary_on">Album cards are hidden</string>
|
||||
|
|
@ -446,15 +455,6 @@ If a Doodle is currently showing in your region and this hide setting is on, the
|
|||
<string name="revanced_hide_comments_thanks_button_title">Hide Thanks button</string>
|
||||
<string name="revanced_hide_comments_thanks_button_summary_on">Thanks button is hidden</string>
|
||||
<string name="revanced_hide_comments_thanks_button_summary_off">Thanks button is shown</string>
|
||||
<string name="revanced_custom_filter_screen_title">Custom filter</string>
|
||||
<string name="revanced_custom_filter_screen_summary">Hide components using custom filters</string>
|
||||
<string name="revanced_custom_filter_title">Enable custom filter</string>
|
||||
<string name="revanced_custom_filter_summary_on">Custom filter is enabled</string>
|
||||
<string name="revanced_custom_filter_summary_off">Custom filter is disabled</string>
|
||||
<string name="revanced_custom_filter_strings_title">Custom filter</string>
|
||||
<!-- 'Component path builder strings' is the technical name for identifying the Litho UI layout items to hide. This is an advanced feature and most users will never use this. -->
|
||||
<string name="revanced_custom_filter_strings_summary">List of component path builder strings to filter separated by new line</string>
|
||||
<string name="revanced_custom_filter_toast_invalid_syntax">Invalid custom filter: %s</string>
|
||||
<string name="revanced_hide_view_count_title">Hide view count</string>
|
||||
<string name="revanced_hide_view_count_summary_on">View count is hidden in feed and search results</string>
|
||||
<string name="revanced_hide_view_count_summary_off">View count is shown in feed and search results</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue